...
When adding an App to the home screen (see System Administration: Manage Apps) you have access to a require property, whose ContextModel contains :
- sessionContext (which contains:)
- currentUser
- currentProvider
- sessionLocation
sessionContext.
Example: (only shows this app if the user logged in with the Outpatient Clinic session location)
sessionContext.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).
hasMemberWithProperty(sessionLocation.tags, 'display', 'Admission Location')
To show a form if the logged in user has the Organizational: Nurse role, you would use the expression below:
hasMemberWithProperty (user.roles, 'display', 'Organizational: Nurse')
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.
...
Example: (only show this form for inpatients)
visit.admitted
Helper Functions
hasMemberWithProperty(list, propertyName, valueToLookFor)
... true if any item in list has item[propertyName] == valueToLookFor
See this code for full details.
Available Properties
sessionContext
Properties available:
- currentUser
- currentProvider
- sessionLocation
See this code for full details.
patient
Properties available:
...
- uuid
- birthdate
- birthdateEstimated
- gender
- dead
- deathdate
See this code for full details.
...
See this code for full details.
More details for how this is put together.