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

Hi Lorill,

I think you have found the best approach to the problem.

I have added support in trunk now for a “limit” query parameter that puts a limit on the number of records to return. So you can now append “&limit=1” to your query and check if any records are returned.

I have updated the docs here.

Will see if this can be backported to 2.19 later.

regards,

Lars

···

On Mon, Jun 8, 2015 at 11:30 PM, Lorill Crees lcrees@2paths.com wrote:

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


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

This has been backported to 2.19 now.

···

On Tue, Jun 9, 2015 at 11:07 AM, Lars Helge Øverland larshelge@gmail.com wrote:

Hi Lorill,

I think you have found the best approach to the problem.

I have added support in trunk now for a “limit” query parameter that puts a limit on the number of records to return. So you can now append “&limit=1” to your query and check if any records are returned.

I have updated the docs here.

Will see if this can be backported to 2.19 later.

regards,

Lars

On Mon, Jun 8, 2015 at 11:30 PM, Lorill Crees lcrees@2paths.com wrote:

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


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

Hi Lars

I wonder if you also have any suggestions for checking if data has been imported for Programs and ProgramStages.

For Programs, I have been doing the following:

/api/enrollments?program=

Get the orgUnit from the first enrollment

/api/trackedEntityInstances?ou=&program=

However, this has poor performance and a large number of records can be returned.

For ProgramStages, I have been doing the following:

/api/events?programStage=

Again, poor performance and a large number of records can be returned.

One thing I need to display a listing page with all Programs/ProgramStages and show whether there is data assigned. A faster method of querying this is essential.

Any suggestions for more performant queries would be greatly appreciated.

Many thanks

Alan

···

On Tue, Jun 9, 2015 at 3:18 AM, Lars Helge Øverland larshelge@gmail.com wrote:

This has been backported to 2.19 now.


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

On Tue, Jun 9, 2015 at 11:07 AM, Lars Helge Øverland larshelge@gmail.com wrote:

Hi Lorill,

I think you have found the best approach to the problem.

I have added support in trunk now for a “limit” query parameter that puts a limit on the number of records to return. So you can now append “&limit=1” to your query and check if any records are returned.

I have updated the docs here.

Will see if this can be backported to 2.19 later.

regards,

Lars


Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

On Mon, Jun 8, 2015 at 11:30 PM, Lorill Crees lcrees@2paths.com wrote:

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


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

Hi Lars,

Thanks for this. I’ve tried it out and it’s working well in terms of functionality, but the performance is very poor. Even if I’m limiting to just one record, one api call is taking 5-7 seconds. When needing to iterate over 17 datasets this means two minutes for my page load which would not be acceptable.

Are there any performance improvements that can be made for this?

Let me know. Thanks,

Lorill

···

On Tue, Jun 9, 2015 at 3:18 AM, Lars Helge Øverland larshelge@gmail.com wrote:

This has been backported to 2.19 now.

On Tue, Jun 9, 2015 at 11:07 AM, Lars Helge Øverland larshelge@gmail.com wrote:

Hi Lorill,

I think you have found the best approach to the problem.

I have added support in trunk now for a “limit” query parameter that puts a limit on the number of records to return. So you can now append “&limit=1” to your query and check if any records are returned.

I have updated the docs here.

Will see if this can be backported to 2.19 later.

regards,

Lars


Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

On Mon, Jun 8, 2015 at 11:30 PM, Lorill Crees lcrees@2paths.com wrote:

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


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

Hi again,

I have done an optimization now in trunk r 19326 and 2.19. It seems we unnecessarily loaded persisted periods for the time span when start and end dates were used. Please try again on latest trunk and see if it works better now.

Lars

···

On Tue, Jun 9, 2015 at 8:21 PM, Lorill Crees lcrees@2paths.com wrote:

Hi Lars,

Thanks for this. I’ve tried it out and it’s working well in terms of functionality, but the performance is very poor. Even if I’m limiting to just one record, one api call is taking 5-7 seconds. When needing to iterate over 17 datasets this means two minutes for my page load which would not be acceptable.

Are there any performance improvements that can be made for this?

Let me know. Thanks,

Lorill

On Tue, Jun 9, 2015 at 3:18 AM, Lars Helge Øverland larshelge@gmail.com wrote:

This has been backported to 2.19 now.

On Tue, Jun 9, 2015 at 11:07 AM, Lars Helge Øverland larshelge@gmail.com wrote:

Hi Lorill,

I think you have found the best approach to the problem.

I have added support in trunk now for a “limit” query parameter that puts a limit on the number of records to return. So you can now append “&limit=1” to your query and check if any records are returned.

I have updated the docs here.

Will see if this can be backported to 2.19 later.

regards,

Lars


Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

On Mon, Jun 8, 2015 at 11:30 PM, Lorill Crees lcrees@2paths.com wrote:

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


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org

Lars Helge Øverland

Lead developer, DHIS 2

University of Oslo

Skype: larshelgeoverland

http://www.dhis2.org