Return number of records in a program stage

Hi Devs,

Is there an api call that returns a count of records in the tracker in a program stage. I am using a custom form to generate an alpha numeric ID based on a count of program stage records e.g. no. Of mothers attending ANC. I wanted to use a count returned from an sql view but am wondering if there is another way to this.

rgds

David

Hi Muturi,

one approach is using the event analytics API. Of course this means that the result will depend on when analytics tables were generated last time.

Docs: http://dhis2.github.io/dhis2-docs/master/en/developer/html/ch01s33.html

A query that will give you the number of events for a given program, program stage, entire country (see ou dimension) and between a start and end date looks like this:

https://play.dhis2.org/demo/api/analytics/events/aggregate/eBAyeGv0exc.json?stage=Zj7UnCAulEk&dimension=ou:ImspTQPwCqd&startDate=2015-03-01&endDate=2016-06-30&outputType=EVENT

Will return a single row with the count of events:

  • rows:

    [

    • [

      • “ImspTQPwCqd”,

      • “71676”

      ]

    ],

regards,

Lars

···

On Thu, Jun 23, 2016 at 6:40 AM, David Muturi dnmuturi@gmail.com wrote:

Hi Devs,

Is there an api call that returns a count of records in the tracker in a program stage. I am using a custom form to generate an alpha numeric ID based on a count of program stage records e.g. no. Of mothers attending ANC. I wanted to use a count returned from an sql view but am wondering if there is another way to this.

rgds

David


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

lars@dhis2.org

http://www.dhis2.org

Hi Lars,

Many thanks for this. Its definitely useful, I was looking for a method that doesnt rely on analytics because I am using the ID as a field in a custom reg form for a program.

rgds

Da

Hi Muturi,

one approach is using the event analytics API. Of course this means that the result will depend on when analytics tables were generated last time.

Docs: http://dhis2.github.io/dhis2-docs/master/en/developer/html/ch01s33.html

A query that will give you the number of events for a given program, program stage, entire country (see ou dimension) and between a start and end date looks like this:

https://play.dhis2.org/demo/api/analytics/events/aggregate/eBAyeGv0exc.json?stage=Zj7UnCAulEk&dimension=ou:ImspTQPwCqd&startDate=2015-03-01&endDate=2016-06-30&outputType=EVENT

Will return a single row with the count of events:

  • rows:

    [

    • [

      • “ImspTQPwCqd”,

      • “71676”

      ]

    ],

regards,

Lars

···

On Thu, Jun 23, 2016 at 6:40 AM, David Muturi dnmuturi@gmail.com wrote:

Hi Devs,

Is there an api call that returns a count of records in the tracker in a program stage. I am using a custom form to generate an alpha numeric ID based on a count of program stage records e.g. no. Of mothers attending ANC. I wanted to use a count returned from an sql view but am wondering if there is another way to this.

rgds

David


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

lars@dhis2.org

http://www.dhis2.org