# Expanded cohort and delta synchronization proposal

**URL:** <https://talk.openmrs.org/t/expanded-cohort-and-delta-synchronization-proposal/5604>\
**Category:** Development\
**Created:** [April 1, 2016, 6:14am UTC](https://talk.openmrs.org/t/expanded-cohort-and-delta-synchronization-proposal/5604 "2016-04-01T06:14:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vshankar](https://talk.openmrs.org/letter_avatar/vshankar/32/5_5575768a8748004e209b776fc1b2916d.png) [@vshankar](https://talk.openmrs.org/u/vshankar)\
**Post date:** [April 1, 2016, 6:14am UTC](https://talk.openmrs.org/t/expanded-cohort-and-delta-synchronization-proposal/5604/1 "2016-04-01T06:14:14Z")

</div>

I’m a graduate student from San Francisco State University. Thanks for @ayeung, I’ll be contributing and helping develop OpenMRS beginning with this: [Expanded Cohort Features - Projects - OpenMRS Wiki](https://wiki.openmrs.org/display/projects/Expanded+Cohort+Features)

As per our discussion with @ayeung and several others, I would like to begin a conversation for the proposal that will go towards the Expanded Cohort module starting with the data model that will incorporate Cohort membership information as per the link above. In addition, in the UI part we plan to add options for the user to define a time interval to run the scheduled tasks in the Expanded Cohort.

I have outlined the changes that are needed to the data model in the ER diagram below:

![](https://talk.openmrs.org/uploads/default/original/2X/f/fb0ac328e1f4f6c294cd5a4b6cff1599ecdcb9a1.png)

Membership information is added to the cohort\_member table and scheduled\_interval for the scheduled tasks is added to the expanded\_cohort\_definition table because it seemed appropriate to accompany it with the sql query.

This is definitely up for discussion, because I would love some input on how to store the time intervals for the scheduled tasks. As per the diagram, I suppose one way to store them is 6h, 7d, 3w, 4m and use MySQL events to run the queries?!

---

<div class="post-metadata">

**Author:** ![vshankar](https://talk.openmrs.org/letter_avatar/vshankar/32/5_5575768a8748004e209b776fc1b2916d.png) [@vshankar](https://talk.openmrs.org/u/vshankar)\
**Post date:** [April 8, 2016, 5:40pm UTC](https://talk.openmrs.org/t/expanded-cohort-and-delta-synchronization-proposal/5604/2 "2016-04-08T17:40:58Z")

</div>

Copying to @darius and @burke

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [April 8, 2016, 7:24pm UTC](https://talk.openmrs.org/t/expanded-cohort-and-delta-synchronization-proposal/5604/3 "2016-04-08T19:24:44Z")

</div>

@vshankar, glad to hear you’re interested in this project! Sorry for the slow reply, you caught us while I was in an all-week workshop and Burke is on service in the hospital.

The initial question I have is whether you’re aiming to make these changes directly in openmrs-core for future release (that’s what the project page says), or via a module that could run against existing OpenMRS installations. Assuming it goes in openmrs-core, I would not expect an `expanded_cohort_definition` table, but rather I’d expect you to add columns to the existing `cohort` table.

Also, you’ve described a specific implementation of how dynamic cohorts could work (e.g. there’s a `sql_definition` column), however openmrs-core actually need to support a more extensible mechanism than this. E.g. openmrs-core might support the functionality:

```
cohort_calculation_handler = "org.openmrs.cohort.SqlCohortHandler"
cohort_calculation_config = "select person_id as patient_id from person where gender = 'M' "

```

but it should also allow the reporting module to provide alternative functionality like

```
cohort_calculation_handler = "org.openmrs.module.reporting.cohort.ReportingCohortHandler"
cohort_calculation_config = "uuid-of-some-reporting-module-definition"

```

Basically, openmrs-core needs to provide an API by which dynamic cohorts can be evaluated on some schedule, and have their results automatically populate the cohort\_member tables, but the specific method by which the evaluation happens should be extensible.

One option for the schedule format would be a cron format. As far as what format, one option is a cron format

---

<div class="post-metadata">

**Author:** ![vshankar](https://talk.openmrs.org/letter_avatar/vshankar/32/5_5575768a8748004e209b776fc1b2916d.png) [@vshankar](https://talk.openmrs.org/u/vshankar)\
**Post date:** [April 8, 2016, 8:05pm UTC](https://talk.openmrs.org/t/expanded-cohort-and-delta-synchronization-proposal/5604/4 "2016-04-08T20:05:08Z")

</div>

Thanks Darius for your reply.

> [@darius](#):
>
> The initial question I have is whether you’re aiming to make these changes directly in openmrs-core for future release (that’s what the project page says), or via a module that could run against existing OpenMRS installations.

expanded\_cohort\_definition table exists in the [Expanded Cohort](https://github.com/muzima/openmrs-module-expandedcohort) module. Considering the cohort definitions exists in the reporting compatibility module, shouldn’t it be better to extend the reporting compatibility module? That way we can consolidate the expanded cohort features into the reporting compatibility module. I am open for more ideas, since I only have limited exposure to openmrs.

---

<div class="post-metadata">

**Author:** ![darius](https://talk.openmrs.org/user_avatar/talk.openmrs.org/darius/32/8082_2.png) [@darius](https://talk.openmrs.org/u/darius)\
**Post date:** [April 8, 2016, 11:35pm UTC](https://talk.openmrs.org/t/expanded-cohort-and-delta-synchronization-proposal/5604/5 "2016-04-08T23:35:24Z")

</div>

@vshankar, I believe the idea with this project is that you’re supposed to be bringing some of the functionality that was previously only available in add-on modules (expandedcohort, reporting, reportingcompatibility) into openmrs-core.

But you should talk with @burke (who I think will be available again on Monday) and @ayeung about that.

---

<div class="post-metadata">

**Author:** ![michael](https://talk.openmrs.org/user_avatar/talk.openmrs.org/michael/32/15070_2.png) [@michael](https://talk.openmrs.org/u/michael)\
**Post date:** [April 9, 2016, 3:42am UTC](https://talk.openmrs.org/t/expanded-cohort-and-delta-synchronization-proposal/5604/6 "2016-04-09T03:42:11Z")

</div>

This is a GSoC 2016 project to be mentored by @burke (not @ayeung).

If you’re just now working on your proposal, it’s too late because the deadline has already passed. If this is a not a GSoC proposal, please know that someone has likely already applied to work on this project and will likely be selected.

Sorry if I misunderstood your original message.

---

<div class="post-metadata">

**Author:** ![ayeung](https://talk.openmrs.org/user_avatar/talk.openmrs.org/ayeung/32/16_2.png) [@ayeung](https://talk.openmrs.org/u/ayeung)\
**Post date:** [April 15, 2016, 2:35pm UTC](https://talk.openmrs.org/t/expanded-cohort-and-delta-synchronization-proposal/5604/7 "2016-04-15T14:35:47Z")

</div>

Thanks, @darius and @michael.

I just chatted with @burke and explained to him what @vshankar is working on is a different project from [https://wiki.openmrs.org/display/projects/Expanded+Cohort+Features](https://wiki.openmrs.org/display/projects/Expanded+Cohort+Features).

For @vshankar’s project, he will create the columns based on the suggested naming convention from [https://notes.openmrs.org/2016-02-17-Design-Forum](https://notes.openmrs.org/2016-02-17-Design-Forum) and it will be created under a separate module (not as core as it’s stated in GSOC project).

I hope that has clarified the confusion.
