REST API, Data Integrity Module & OpenMRS

This week I worked on DINT-82 — a task related to design and implementation of REST API. As of now, data integrity module don’t have any API support for showing rules and results or generating results by running rules.

This task is particularly challenging as well as important as by exposing data integrity module APIs, other services can easily use this module. OpenMRS Android Client or other such apps can use these APIs to check the validity of data received.

The design basically involved two resources in terms of REST API design conventions which are:

Data Integrity Rules

  • Hosted at /dataintgrityrules which supports getting list of all rules, all rules belongs to same category or a single rule.
  • Users can also fetch list of results generated for a particular rule. As it can be very huge list, the server will send data in chunks. In other words, it will be paginated.
  • Similar to other APIs in OpenMRS, rules can also be fetched by uuid instead of rule-id.

Data Integrity Results

  • Hosted at /dataintgrityresults. Returns paginated list of results.
  • This API call will also support fetching results which generated for a patient or a program. You can get list of results generated for a particular program/patient.

This task involved an interesting design challenge on which the discussion still going on. The set of above API will also support running a rule for an API call — so the question raised where it should be hosted ? If we host it under /dataintegrityrule then it violates the REST conventions. Basically, it will be a POST call which will add new resources and hosting it under the rules APIs call would be misleading as it is not adding any new rule. Hosting it under /dataintegrityresults is fine according to REST conventions but we it also doesn’t seems okay as we aren’t generating results directly by this call. Hopefully we’ll find a good solution — you can find the ongoing discussion link below.

Another interesting stuff I came across while working on this task is swagger — its a framework for APIs. I didn’t explored it much but will do. More information can be found here.


  • You can find related post here.
  • A very nicely written blog about REST APIs and how one should use them share with me by @dkayiwa can be found here.