GSoC 2022: Redo Legacy UI Cohort Builder - Project Updates

Hello everyone :raised_hands:! I will be working on the project “Redo Legacy UI Cohort Builder” for GSoC 2022. In this project, Cohort Builder will be rebuilt for OpenMRS 3.0 as a micro frontend module.

The Cohort Builder is a tool in OpenMRS 1.0 in the Reporting Compatibility module (included with most OpenMRS installations) that lets the user perform ad-hoc queries for patients with defined characteristics, and combines multiple queries into more complex ones.

Primary mentor: @bistenes Secondary mentor: @jayasanka

Follow this link for more details on the project.


Thanks for initiating the thread, @anjisvj !


Great to have you working on this project Anjula!!

FWIW, I connected w/ @jdick on Friday, and he confirmed that rebuilding the Cohort Builder as a react, carbon microfrontend is exactly what he had envisioned. I’m sorry as I think I may have previously introduced confusion in that regard.

Apparently though one of the needs has been that there is no REST API to support the Cohort Builder (if I understand correctly). But adding this REST support would require some Java work specifically. @bistenes or @jayasanka or @ibacher or @dkayiwa do you know if there is a plan for this?

The thing JJ had been hoping we could accomplish one day (which is probably outside the scope of this GSOC project) is to use the Cohort Builder to build patient lists which self-update. So you’re not just saving the SQL, nor are you saving a list of specific patients from one-point-in-time, but you could also save a dynamic query that will update itself when a new patient appears who matches the original criteria. E.g. this would be useful for dynamically generating patients meeting “Lost to Follow Up” criteria, for example. This would then be connected to the O3 Patient Lists functionality, so a non-admin user could just click “show me all pts who meet LTFU criteria” and it would magically work. (@slubwama I wrote a note to myself that you may have thoughts on this, though I can’t remember why…?)

CCing as well @mseaton who was originally involved in writing this module.


Thanks a lot @grace!

Regarding the REST API, we could leverage the ‘Adhoc API’ for the initial version. But we might need to write some minor endpoints to achieve some tasks, ex: to save a search. @anjisvj Correct me if I’m wrong.

I think you already proposed a plan for this right?

P.S. Link to @anjisvj 's proposal: Redo Legacy UI Cohort Builder - Google Docs

1 Like

Thank you @grace for the clarification. According to my project proposal, there is a feature called “Cohort Run Scheduler” to schedule run the cohorts. Which is similar to the schedule task runner.

1 Like

yes, you are correct @jayasanka, I’m planning to use the “Adhoc API” for this version and planning to create APIs as an improvement.

1 Like

Do you mean the one that @darius built as a replacement for the cohort builder?

I’m going to use the reportingrest module’s Adhoc API. Which is already being used by the OWA Cohort Builder.

1 Like

@anjisvj I created a new repo for your project :innocent:

@bistenes I’m not sure about the repo naming convention. Could you please check it? I named it after /openmrs/openmrs-owa-cohortbuilder and /openmrs/openmrs-module-cohortbuilder


Thank you! @jayasanka So how are we going to move the existing code base? Can we transfer the repo? I’m currently working on this ticket on a separate branch.

You can send the initial version as a PR. Then we can continue working on it iteratively. Feel free to suggest an easy way for you. :blush:

1 Like

I made the initial PR and it’s ready for review. cc: @jayasanka @bistenes

1 Like

Merged! Good job @anjisvj !

1 Like

Hello guys :raised_hands:, I made the second PR. Which is going to give the user the ability to search for patients based on the concepts and observations.

I will create smaller PRs moving forward to make it easier for the reviewers.


Kapture 2022-06-23 at 12.19.01

After this, I will start working on the search history component.

cc: @bistenes @jayasanka


I love the gif/demo video! Very helpful way to see the progress. Thank you for these updates Anjula!

1 Like

Good job @anjisvj ! I left some comments on your updated PR. DM me if you need to have a chat for any further clarifications.

1 Like

I made the requested changes @jayasanka. Can you review it again?

@Ciarán Duffy offered me some help regarding the UI/UX of the cohort builder. So I shared with him the mockups I drew for the cohort builder. He gave me some suggestions and most importantly he was kind enough to give me a whole new design.

IMO this proposed UI is way clearer and easy to use. I would like to have some feedback from you as well.

cc: @grace @jayasanka @bistenes @ibacher


This looks awesome! :smiley:

1 Like

@slubwama & @jdick what do you think of this?

(FYI @anjisvj - Samuel Lubwama is a leader of the UgandaEMR implementation of OpenMRS with over 1,500 sites, and he sees users using the Cohort Module in the field quite often, so thought he’d be a great resource for specific feedback :slight_smile: )

1 Like