Wiki Spaces


Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack


Page tree
Skip to end of metadata
Go to start of metadata


This module provides a mechanism for filtering persistent data on a configurable and customisable basis. In a nutshell it enforces metadata-based access to users and/or roles.

For instance, out of the box, the module supports location-based and program-based access control to patient records and their clinical data. The initial implementation for those two use cases is restricted to the patients and their visits, encounters and observations.

Architectural Overview

The data model has been kept simple deliberately such that only two concepts matter: 1) which entity is being restricted by the filtering and 2) on what basis does this filtering restriction operate?

  1. The basis is the metadata on which the data access is based.
    Eg. Program  for program-based access, Location  for location-based access, ... etc.

  2. The entity is what is authorised to access the data.
    Eg. Role  or User .

This is all controlled and stored in a single table modelled by EntityBasisMap  and can be configured through DataFilterService .



There are a couple of end-to-end tests in place showing the module's mechanics, see for instance PatientFilterTest .


We envision adding filtering of other patient clinical data like orders, encounter diagnoses, appointments, ...etc.

We also envision a scenario where another module can leverage this module's functionality to limit access by some other criteria e.g. role-based access.

With that said, we hope to strip the location-based and program-based functionality out of this module leaving it as a very thin lightweight and reusable module purely for data filtering. The location-based access filtering should be moved to the existing Location based access module for instance.

Developer Guide

User Guide




To guarantee proper functionality of OpenMRS, it's highly recommended to install the module by stopping OpenMRS, drop the .omod file in the module repository and start OpenMRS again, this also applies to uninstall it, you need to stop OpenMRS, remove the .omod from the local module repository and start OpenMRS.


  • Set the value for the global property named datafilter.personAttributeTypeUuids, it should be a comma separated list of uuids for the person attribute types to use as the basis for filtering,
    The format property of the matching person attribute type(s) MUST match valid java class names and should match values in the basis_type column in the datafilter_user_basis_map table. E.g. if you want to add location based filtering, you would filter by Location meaning the format of the person attribute type with the uuid to set for the global property would be org.openmrs.Location.
  • Every patient in the database should be assigned a person attribute type that ties them to a location, the attribute type should be the one that was set in above.
  • Assign users to a location by adding entries for them in the datafilter_user_basis_map table, the user_id column is the database id of the user, the basis_id column is the id of the Object to filter on e.g. a location Id in case you are filtering by location. The basis_type column value should be a fully qualified java class name of the objects to filter on, e.g. in case of location based filtering it would org.openmrs.Location.
  • No labels