DHIS2 API get dataset instead of individual data elements

734 views Asked by At

I'm already able to fetch json back from the API related to DATA ELEMENTS. I'd like to get DATA SET results instead (containing all DATA ELEMENTS that are part of this particular DATA SET) Thanks!

3

There are 3 answers

0
fredes On

To fetch dataSets you can use /api/dataSets.json or /api/dataSets.json?fields=dataSetElements[dataSet].

You can find more information on the Web API documentation.

0
dh762 On

To fetch data elements that are assigned to a particular dataSet you query for the dataSetElements:

In the example of the dataSet ART monthly summary (lyLU2wR22tC):

/api/dataSets/lyLU2wR22tC?fields=id,name,dataSetElements[dataElement[id,name]]

or as a specific play.dhis2.org link:

https://play.dhis2.org/2.35.1/api/dataSets/lyLU2wR22tC?fields=id,name,dataSetElements[dataElement[id,name]]

would return:

<dataSet xmlns="http://dhis2.org/schema/dxf/2.0" name="ART monthly summary" id="lyLU2wR22tC">
<dataSetElements>
<dataSetElement>
<dataElement name="ART entry point: No PMTCT" id="kVOiLDV4OC6"/>
</dataSetElement>
<dataSetElement>
<dataElement name="New on ABC 300mg + ddI 200mg + LPV/r 133.3/33.3mg" id="la1f7sqY9sb"/>
</dataSetElement>
<dataSetElement>
<dataElement name="Shift to d4T 30mg + 3TC 150mg + EFV 600mg" id="qUY0i7PnaLS"/>
</dataSetElement>
<dataSetElement>
<dataElement name="Prev. month on NVP + AZT + 3TC 10mg/ml (2mg/kg) + 10mg/ml + 10mg/ml for 7 days" id="CUVDjGzRmmU"/>
</dataSetElement>
...
</dataSet>
0
captain_a On

Please use this API for fetching all data elements of a dataset :

/api/33/dataValueSets