Program indicators - "datediff", custom forms ++

Hi, the new program indicators are great, but I have a couple of questions/requests.

First of all, it does not look like it is possible to add them to custom forms currently (and I didn't find a blueprint for it). Would be great if that could be supported.

Secondly, it would be great with some basic "date calculations", essentially to get the number of days/years between two dates. As far as I can see this is not possible currently with program indicators. I think this would also be very useful for the program rules, e.g. you have two dates and would like to enable/disabled fields or sections based on the different between them. In my particular case, I'm looking at cause of death registration and would like certain fields to be active only if the age is < 1 year based on date of birth and death.

Regards,
Olav

Hi Olav,

···

On Mon, Sep 21, 2015 at 4:30 PM, Olav Poppe olav.poppe@me.com wrote:

Hi, the new program indicators are great, but I have a couple of questions/requests.

First of all, it does not look like it is possible to add them to custom forms currently (and I didn’t find a blueprint for it). Would be great if that could be supported.

Yes agree, we should add this.

Secondly, it would be great with some basic “date calculations”, essentially to get the number of days/years between two dates. As far as I can see this is not possible currently with program indicators. I think this would also be very useful for the program rules, e.g. you have two dates and would like to enable/disabled fields or sections based on the different between them. In my particular case, I’m looking at cause of death registration and would like certain fields to be active only if the age is < 1 year based on date of birth and death.

That is possible in trunk, see docs for the d2:daysBetween function:

https://www.dhis2.org/doc/snapshot/en/user/html/ch30s03.html

Function
Arguments
Description
d2:daysBetween
(date, date)
Produces the number of days between two data elements/attributes of type date. The static date format is ‘yyyy-MM-dd’.

An example expression that uses the “daysBetween” function looks like this:

d2:daysBetween(#{mCXR7u4kNBW.k8ja2Aif1Ae},'2015-06-01')

regards,

Lars

Regards,

Olav


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,

should I add a blueprint for the first one (indicators in custom forms)?

The indicator functions for 2.21 looks great. I’d like to suggest as well “floor” (similar to Math.floor()) - combined with daysBetween, you can then also calculate other period types as in age in years = d2.floor(d2.daysBetween(birth, death)/365), duration of pregnancy in weeks etc etc.

Similarly, I imagine “ceil” and “round” (or some function where you specify number of decimal digits) could we very useful.

Thanks

Olav

···

On Mon, Sep 21, 2015 at 4:30 PM, Olav Poppe olav.poppe@me.com wrote:

Hi, the new program indicators are great, but I have a couple of questions/requests.

First of all, it does not look like it is possible to add them to custom forms currently (and I didn’t find a blueprint for it). Would be great if that could be supported.

Yes agree, we should add this.

Secondly, it would be great with some basic “date calculations”, essentially to get the number of days/years between two dates. As far as I can see this is not possible currently with program indicators. I think this would also be very useful for the program rules, e.g. you have two dates and would like to enable/disabled fields or sections based on the different between them. In my particular case, I’m looking at cause of death registration and would like certain fields to be active only if the age is < 1 year based on date of birth and death.

That is possible in trunk, see docs for the d2:daysBetween function:

https://www.dhis2.org/doc/snapshot/en/user/html/ch30s03.html

Function
Arguments
Description
d2:daysBetween
(date, date)
Produces the number of days between two data elements/attributes of type date. The static date format is ‘yyyy-MM-dd’.

An example expression that uses the “daysBetween” function looks like this:

d2:daysBetween(#{mCXR7u4kNBW.k8ja2Aif1Ae},'2015-06-01')

regards,

Lars

Regards,

Olav


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