API query for Last Event for a Program Stage for TEI

Dear All,

Is it possible to query an event for a TEI for a particular program stage depending on last updated time. I want to obtain the records of an event that was updated last for a program stage for a TEI.

Thank you.

···

Regards,
Pamod Amarakoon

Confidentiality Notice: the information contained in this email and any attachments may be legally privileged and confidential. If you are not an intended recipient, you are hereby notified that any dissemination, distribution, or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender and permanently delete the e-mail and any attachments immediately. You should not retain, copy or use this e-mail or any attachments for any purpose, nor disclose all or any part of the contents to any other person.

Hi team,
I do have a similar case
how can I do this: API query a program with multiple stages but return only the following:
org unit, program, 4 selected attributes, one selected program stage, and selected data elements and events values, and filter by event date.

I am not sure you can filter to select only specific dataElements, maybe someone can explain better, I would probably filter out in a later stage.

But for example, the following query gets almost what you want:

https://play.dhis2.org/2.36.0/api/events?program=IpHINAT79UW&trackedEntityInstance=r2FEXpX6ize&programStage=ZzYYXq4fJie&startDate=2021-02-09&endDate=2021-03-01&fields=orgUnit,program,dataValues

Just a complement to @jaime.bosque, add &order=eventDate:desc&pageSize=1&page=1 to be more specific. :slight_smile:

1 Like

Thank you all, I used *trackedEntityInstances and paging and I was able to get what I wanted.

1 Like