← Back to team overview

dhis2-devs team mailing list archive

How to determine if a dataset has any data values in it

 

Hi,

I am trying to craft a web api call to determine if a dataset has at least
one data value in it or not. I am not interested in the data values
themselves, just if any data has been uploaded / inputted into the system
yet or not.

If data values did exist, I would not know what org units or periods were
chosen so would not be able to supply those parameters.

I would also prefer to do this in one api call instead of having to iterate
through data elements until finding data (if any).

I've been digging around the api and the best I can find right now in one
call is this:

dhis/api/dataValueSets?dataSet=QnhNNSNFE0M&startDate=1980-01-01&endDate=2020-01-01&orgUnit=
lZsCb6y0KDX&children=true

where I set the start date to a far past, the end date to the future, and
the org unit to the level 1 parent org unit.

This could potentially return a very large number of records which is a
heavy overhead when only wanting to know if dataValues > 0.

I also tried this:

dhis/api/dataValueSets?dataSet=QnhNNSNFE0M&startDate=1980-01-01&endDate=2020-01-01&orgUnit=
lZsCb6y0KDX&children=true&fields=dataValues:: isNotEmpty

but the "::isNotEmpty" does not seem to be in place for this call. I also
could not seem to return paged data to reduce the payload.

Do you have any other suggestions of how I can do this? To give context, I
will be iterating through all Datasets in the system and displaying them in
a list, so I need something that is fairly efficient. I wouldn't want to
have to iterate through each data element individually unless necessary.

Thanks,

Lorill

Follow ups