OpenSRP-DHIS2 Integration, BD Example

This integration involves sending data from OpenSRP to DHIS2. OpenSRP can push both individual records/tracker level details data and aggregated data into DHIS2.

1. Aggregate Data: OpenSRP publishes different aggregated summary of vaccine information (i.e. total number of new child register from a facility, total number of child given BCG,OPV, Penta etc from a facility by weekly/monthly) into DHIS2.

2. Individual data records / Tracker: OpenSRP also transfer details information of registered clients (woman, child) into DHIS2.

Technical Descriptions:

Aggregate Data:

A scheduler job runs in OpenSRP server once in a month which invoke

class="org.opensrp.web.listener.DHIS2ConnectorListener.java"

Method Name

Descriptions

method="vaccinationAggregatorDataCountForSendingToDHIS2"

This listener method first call “getAggregatedDataCount” which generate aggregated data set as a json . Next it call another method “aggredateDataSendToDHIS2” which actually push records into DHIS2.

class="org.opensrp.connector.dhis2.DHIS2AggregateConnector.java"

method="getAggregatedDataCount"

This method do the aggregated counts of different vaccine indicators (total BCG, OPV ) and generate a data set in json format using these counts. Following is a sample generated data set with BCG, OPV, PENTA vaccine counts.

{

 "dataSet": "pBOMPrpg1QX",
 "completeData": "2014-02-03",
 "period": "201401",
 "orgUnit": "DiszpKrYNg8",
 "dataValues": [
 { "dataElement": "f7n9E0hX8qk", "value": "1" },
 { "dataElement": "Ix2HsbDMLea", "value": "2" },
 { "dataElement": "eY5ehpbEsB7", "value": "3" }
 ]
}

method="aggredateDataSendToDHIS2"

This method makes a POST request against dhis2 /DHIS2host/api/dataValueSets .

class="org.opensrp.connector.dhis2.Dhis2HttpUtils.java"

method="post"

Header: [username: ****, password:****]

data- Json formatted as String

           {

              "dataSet": "pBOMPrpg1QX",

 "completeData": "2014-02-03",
 "period": "201401",
"orgUnit": "DiszpKrYNg8",
"dataValues": [
 { "dataElement": "f7n9E0hX8qk", "value": "1" },
 { "dataElement": "Ix2HsbDMLea", "value": "2" },
{ "dataElement": "eY5ehpbEsB7", "value": "3" }
 ]
}



Track Capture Data:

A Motech driven scheduler job runs in OpenSRP server which invoke.

class="org.opensrp.connector.dhis2.DHIS2SyncerListener.java"

Method Name

Descriptions

method="pushToDHIS2"

This method find all available beneficiaries/clients in OpenSRP that are not sync with DHIS2. Next it call method “sentTrackCaptureDataToDHIS2

method="sentTrackCaptureDataToDHIS2"

This method prepare client data json for sending to DHIS2, then pass the call to method “trackCaptureDataSendToDHIS2”

class="org.opensrp.connector.dhis2.Dhis2TrackCaptureConnector.java"

Method Name

Descriptions

method="trackCaptureDataSendToDHIS2"

This method makes two “POST” request into DHIS2. In first call it sends track capture data and in second call enroll this data into a program.

class="org.opensrp.connector.dhis2.Dhis2HttpUtils.java"

Method Name

Descriptions

method="post"

First POST Request:

API: /DHIS2host/api/trackedEntityInstances

Header:[username: ****, password:*****]

data- Json formatted as String “{

 "trackedEntity": "tracked-entity-id",
 "orgUnit": "org-unit-id",
 "attributes": [ {
 "attribute": "attribute-id",
 "value": "attribute-value"
 } ]
}”

Response: {

"httpStatus": "OK",

"httpStatusCode": 200,

"status": "OK",

"message": "Import was successful.",

"response": {

"responseType": "ImportSummary",

"status": "SUCCESS",

"importCount": {

"imported": 1,

"updated": 0,

"ignored": 0,

"deleted": 0

},

"reference": "UWdxyR7FNFo"

}

},

{

"reference": "UWdxyR7FNFo",

"responseType": "ImportSummary",

"importCount": {

"ignored": 0,

"deleted": 0,

"imported": 1,

"updated": 0

},

"status": "SUCCESS"

}

Second POST Request:

This request enrolled a tracked entity instance into a program. The reference keys value from the first call response use as a “trackedEntityInstance” in second call for enrollment into program.

API: /dhis2host/api/enrollments

data- Json formatted as String

{

"trackedEntityInstance": "UWdxyR7FNFo",

"orgUnit": "ImspTQPwCqd",

"program": "S8uo8AlvYMz",

"enrollmentDate": "2013-09-17",

"incidentDate": "2013-09-17"

}

Related Source Links:

1.https://github.com/OpenSRP/opensrp-server/blob/dhis2_integration/opensrp-web/src/main/webapp/WEB-INF/spring/listener-context.xml

2.https://github.com/OpenSRP/opensrp-server/blob/dhis2_integration/opensrp-web/src/main/java/org/opensrp/web/listener/DHIS2ConnectorListener.java

3.https://github.com/OpenSRP/opensrp-server/blob/dhis2_integration/opensrp-connector/src/main/java/org/opensrp/connector/dhis2/DHIS2AggregateConnector.java

4.https://github.com/OpenSRP/opensrp-server/blob/dhis2_integration/opensrp-connector/src/main/java/org/opensrp/connector/dhis2/DHIS2Service.java

5. https://github.com/OpenSRP/opensrp-server/blob/dhis2_integration/opensrp-connector/src/main/java/org/opensrp/connector/dhis2/DHIS2SyncerListener.java

6. https://github.com/OpenSRP/opensrp-server/blob/dhis2_integration/opensrp-connector/src/main/java/org/opensrp/connector/dhis2/Dhis2HttpUtils.java

7. https://github.com/OpenSRP/opensrp-server/blob/dhis2_integration/opensrp-connector/src/main/java/org/opensrp/connector/dhis2/Dhis2TrackCaptureConnector.java

Related pages