The endpoint /api/trackedEntityInstances returns soft-deleted events [fixed]

Hi Team,

I need help filtering out soft-deleted events while using the /api/trackedEntityInstances endpoint of DHIS2 web API, It returns all events including soft-deleted, and I can’t find a way of ignoring them.

On the screenshots below, you will see an example of one request that returns over 15 events, and another using /api/event which returns just 2 events for the same person.

Though this option of ignoring soft-deleted events is available on the endpoint /epi/events (by setting includeDeleted to false), it has the disadvantage of not bringing a TEI’s profile (attributes) and events at once. Which then requires a developer to make two HTTP requests; one to get the TEI’s profile and another to get clean events.

Thank you.

Hi @mauricejm ,

soft-deleted data should not be retrievable, unless there is a special parameter to include soft-deleted values. In other words, the includeDeleted=false is already the default and is not needed.

Just to clarify: Of the 15 events that are returned for you, are they all in the same program? I see in your events request, you request events of a single program only. It would also be great if you could verify that at least one of the returned events in the other endpoint is actually marked as deleted=true in the database :slight_smile:

If this is indeed the case, please write a jira issue for this problem, including your version of DHIS2 (major and patch version).

1 Like

Hi @Stian ,

Thank you for your swift reply,

Yes, they are of the same program covid vaccination and Yes, the events are marked as deleted ("deleted": true,) as you see on the screenshot below.

I am gonna go ahead and write an issue on Jira as you suggested.

Thanks @mauricejm for creating the jira bug issue: DHIS2-12285 | The endpoint /api/trackedEntityInstances returns soft-deleted events

I added the CoP label and a comment with a link to this topic. :+1: