Several places in the Reference Application allow you to provide a logical expression that determines whether an App or Extension is displayed. (For example, require under Manage Apps, or Show If on Manage Forms.)

These allow the administrator to provide a snippet of JavaScript that will be evaluated against a given ContextModel that reflects the state of the app at that given time.

Where Conditional Includes are Supported

Home Page Apps

Example: (only shows this app if the user logged in with the Outpatient Clinic session location)

sessionLocation.uuid == '58c57d25-8d39-41ab-8422-108a0c277d98'

Hardcoding a specific uuid is not a good approach if you want your code to work across multiple OpenMRS implementations. A better approach would be to do this based on location tags, e.g. this app would only be available if the user logged in with a session location that has the "Admission Location" tag (on our demo server this would be Inpatient Ward or Isolation Ward).

Patient Summary and Visit Dashboard

The Patient screen has two list of available actions: one for General Actions, another for Current Visit Actions (if there is an active visit). When viewing a specific visit, you have access to Visit Actions. When you add a custom form (see Configure Metadata: Manage Forms) this is added as a Visit Action.

General Actions have patient available in the context.

Current Visit Actions and Visit Actions have patient and visit available in the context.