We are looking into an approach to OpenMRS - DHIS2 integration in Bahmni. We have looked into the current approach being followed in the module being developed in OpenMRS. There are few things where we would like to have a different approach with respect to the current module. Namely-
- Having lesser number of SQL queries
- Using output from the pre-packaged aka canned reports and transforming it to the data elements used in DHIS2 (these pre-packaged reports can be configured per deployment and they are tested for performance, correctness)
- Reduce effort needed per implementation
- We want it to be flexible too, so that people can plugin there own queries but we would like to reduce them to minimum
We are considering of below approach. Request to share your opinions or suggestions on this.
Consider the case where it is required to report HIV data (HIV tests, HIV tests positive, HIV tests negative based on age groups and gender)
Consider simple data for example-
encounter_id | encounter_datetime | concept_name | obs_id | value_coded | age | gender
1 2015-01-01 ANC HIV Tested 1 YES 40 M
2 2015-01-01 ANC HIV Tested 1 NO 50 F
3 2015-01-01 ANC HIV Tested 1 NO 28 M
4 2015-01-01 ANC HIV Tested 1 NOT TESTED 38 M
5 2015-01-01 ANC HIV Tested 1 YES 27 F
6 2015-01-01 ANC HIV Tested 1 YES 39 M
The DHIS2 data model is represented below (also this represents the format for posting to DHIS2) -
{
"dataSet": "dataSetID",
"completeDate": "date",
"period": "period",
"orgUnit": "orgUnitID",
"attributeOptionCombo", "aocID",
"dataValues": [
{ "dataElement": "dataElementID", "categoryOptionCombo": "cocID", "value": "1", "comment": "comment1" },
{ "dataElement": "dataElementID", "categoryOptionCombo": "cocID", "value": "2", "comment": "comment2" },
{ "dataElement": "dataElementID", "categoryOptionCombo": "cocID", "value": "3", "comment": "comment3" }
]
}
So, we need to post the data in the above format. In the example we are considering, the data to be posted would look like -
{
"dataSet": "pBOMPrpg1QX",
"completeDate": "2014-02-03",
"period": "201401",
"orgUnit": "DiszpKrYNg8",
"attributeOptionCombo", "aocID",
"dataValues": [
// repeated for : number of times = genders * number of age group
{ "dataElement": "ANC8153", "categoryOptionCombo": "g10n391n", value: "12"},
{ "dataElement": "ANC8153", "categoryOptionCombo": "h167n2", value: "1"},
{ "dataElement": "ANC8153", "categoryOptionCombo": "a199b2", value: "2"},
{ "dataElement": "ANC8153", "categoryOptionCombo": "m167n2", value: "1"},
{ "dataElement": "ANC8153", "categoryOptionCombo": "p267n2", value: "1"},
{ "dataElement": "ANC8154", "categoryOptionCombo": "g10n391n", value: "12"},
{ "dataElement": "ANC8154", "categoryOptionCombo": "h167n2", value: "0"},
{ "dataElement": "ANC8154", "categoryOptionCombo": "a199b2", value: "2"},
{ "dataElement": "ANC8154", "categoryOptionCombo": "m167n2", value: "1"},
{ "dataElement": "ANC8154", "categoryOptionCombo": "p267n2", value: "0"},
]
}
Query output from DB would look like this-
Number of tests done, Age Group (Code), Gender
6, 56, M
2, 56, F
4, 57, M
11, 57, F
To achieve this output we need to know the relations between DHIS2 data model and the data we obtained by querying. And, also the types of reports/forms to be submitted to DHIS2 need to be known. This is explained in brief below-
To map the data which we obtained by querying OpenMRS DB to data model of DHIS2, we need to know the mapping between elements in DHIS2 with Bahmni names. An example of this mapping would look as shown below-
type="category", id="f8n3o2n", maps_to="Gender"
type="category option", id="g10n391n", maps_to="M"
Also, we need to have a configuration for the kind of reports that need to be generated. An example of this configuration would be like-
{
"data set": "pBOMPrpg1QX"
"value column": "Number of tests done" //optional
"canned report config" : {
"type" : "Obs Count",
"concept name" : "EILSA"
"age group name" : "general"
}
}
This is a simple example, but given that DHIS2 has fact/dimensions model, this can be applied for complex examples too.