I recently installed and tested the cohort module and it works great. I created a PR here to help solve some of the issues I was facing while trying to load it onto OpenMRS v2.1.2. I have the following questions:
We want to extend the cohort data model by adding some additional data that we need. For example, I would like to add a unique identifier for each cohort and I’d like to be able to search using the rest api with this identifier. What would be the best way to achieve this without modifying the existing data model?
We want to be able to track the leaders of a cohort over time, how long a current leader has been the leader and if the current leader is a patient or not, what would be the way to go about this?
@maimoonak and team looking forward to your response on the above.
To add to what @fali has written, we were thinking we might add functionality to allow for search of cohort attributes via the rest API. In addition, we’d like to modify the rest endpoint for getting cohorts to include any attributes about the cohort. Thanks for your feedback.
However, if you find no way other than creating your own data model (example SubwayTravelersGroup), then I can think of adding another maven submodule, add your POJO (extend or nest Cohort class), hbm liquibase mappings. Then extend or add REST service as well (the url has to be different)
We would need to add another Table,POJO,hbm, DAO,Service,REST which would keep track of GroupHead/CohortHead with required fields i.e. startDate, endDate, etc. Adding it to cohort module would be great as this could be the usecase for almost everyone.
@jdick Cohort attributes can be searched by Cohort and CohortAttributeType like here. However, to make Cohort REST Resource we may need to modify the search method a little bit (let me get back on this after a while).
Thanks for your detailed response. In our case, we want go with option number 2, use the CohortAttribute and CohortAttributeType. What would be the best way to search for a cohort using its cohort attribute? Is it advisable?
@fali I have committed the code for this in branch 2.1.0. The cohort can be searched via attributes in json without curly brackets like ?attributes=“a”:“va”,“b”:“v2”,“e”:“e” . This would initiate a ‘OR’ on attributes list i.e. if any of the pair matches cohort would be fetched.