Hi all.
I am trying to pull data values from a dataset in xls format that include data element ID, data element name, data element Value and attribute Option Combo, but the API code is not.
Below the API code I am currently using on demo:
Thanks
Hi all.
I am trying to pull data values from a dataset in xls format that include data element ID, data element name, data element Value and attribute Option Combo, but the API code is not.
Below the API code I am currently using on demo:
Thanks
Hey @hernandezmachava,
You can download the data in CSV format, which you can then open with excel. Your call would look something like this: /api/29/dataValueSets.csv?dataSet=eZDhcZi6FLP&period=202101&orgUnit=DiszpKrYNg8
Regards,
Gintare
Hi @Gintare,
The API is working and I have managed to downloaded data in csv format, but it is showing codes for data elements, category an attribute option combos; not names. What Can I do to show names and not codes?
I’d also love to if I’m not disturbing you to know how I can query for Tracked Entity attributes (name, age, gender, etc) and data elements of a specific program stage or program in the same request.
Thanks
For the first question, you can try the following query params: dataElementIdScheme
and attributeIdScheme
in addition to the ones you already use. Eg: /api/29/dataValueSets.csv?dataSet=eZDhcZi6FLP&period=202101&orgUnit=DiszpKrYNg8&dataElementIdScheme=name&attributeIdScheme=name
. You can find more idSchemes here.
Could you please provide more information about your use case in second question?
Gintare
Hi @Gintare,
For my second question:
I have a tracker capture structed as below:
Personal details (tracked entity attributes)
Name, age, gender, etc
Program stage 1
DE1, DE2, DE3 ,
Program stage 2
DEa, DEb, DEc, etc
What I want is a nested API to query all the tracked entity attributes together with data elements DE1, DE2, DE3 belonging to program stage 1. Also I want an API that query entity attributes and data from both program stages (program stages 1 and 2)
Thanks
Hey @hernandezmachava,
I’m not sure if you want to get the metadata or the data, so I’ll answer for both.
Metadata:
You can approach it from different directions: you can use /programs endpoint, or /programStages endpoint. Example query: /api/programStages/A03MvHHogjR?fields=programStageDataElements,program[programTrackedEntityAttributes,trackedEntityType[trackedEntityTypeAttributes]]
Data:
You should probably use /trackedEntityInstances endpoint, since you need both event data values and tracked entity instance attributes. There is no easy way to filter by program stage though.
API call: /api/trackedEntityInstances?fields=trackedEntityInstance,attributes,enrollments[events[dataValues]]
or just fileds=*. See the docs for more query params.