Get data from all program stages using an API

Hi all,

I am trying to get data from all program stages in a program. On dhis2 demo, I used the following API query to read all data from child programme tracker. The org unit is Id of sierra Leone. I was able to get the data, but I would like to view the program name, program stage and data element names. The csv file is showing IDS. Also, I would like to show tracked entity attributes in the file (name, gender, age).

https://play.dhis2.org/2.34.4/api/29/events.json?ou=ImspTQPwCqd&program=IpHINAT79UW

CSV file

How can I improve the API query to achieve this?

Thanks

Thank you for your question @dmbantu! I have assigned this topic to the right person to answer your question. Please, anyone in the community with answers and discussion can contribute as well. Thank you!

Hey @dmbantu !
To better support and advice on which endpoint(s) to use ad how, it would be great with some extra information on the use case you are supporting. Do you want to somehow dump all the data in the database? Are you interested in grouping the information in enrollments(you mention attributes)? Are you importing the data in some other tool for analysis?

Markus

1 Like

Hi @Markus,

What I would like to view is all in the same file: First enrollment attributes followed by data elements from stage 1 and stage 2 side by side.

image

I am just data in excel for analysis.

Thanks

Hey @dmbantu - thanks. Producing the exact output that you are mentioning here is not possible with one API call, and you would have to do several and fit them together, or do one call and reformat/restructure the output a bit.

In your example it seems to imply that you would have one excel sheet for one person, and another excel sheet for another person? And in your analysis would be looking at one individual at a time?

Markus

Hi @Markus,

I would like to have one excel sheet for all persons and not a separate sheet for each person.

Thanks

Ok, in that case, perhaps a format better suited for excel would be to have one row per person, and the data element and attributes as columns?

1 Like