Hi Edouard Lavaud,

Thanks for your guide. Actually I want the system to show an error message
if user enters value < 5 for the input field.
It's very easy to check if we use value type is Number or Date (for Date of
birth). But I really want to use Age value type because it's nice feature
for Tracker capture or Event capture.

Thanks,

On Wed, Apr 11, 2018 at 5:57 PM, Edouard Lavaud <edouard.lav...@gmail.com>
wrote:

> Hi Em Le Hong,
>
> If I well understand:
> You capture the age at a different moment than you would like the
> program rule to be executed?
>
> If no, program rule executed on the same stage as you capture the age:
>
>         To be checked (never used the age value type so far), but age
> should
> be an integer. So you could just do: #{age_value_type} < 5
>
> If yes, program rule executed later on a different program stage:
>
>         Well, first you would be better off taking a date rather than the
> age. The d2 functions you mentioned are only for comparing dates, but
> age is not a date.
>
>         If you really want to use the age type, you have to convert it
> first
> in a date following the DHIS2 date pattern: YYYY-MM-DD
>
>         For that, you need to choose how to approximate a date of birth.
> Will
> you use the first day of the year? the last day? the 30 of June? The
> day you collected the information?
>         Then you have to use the diverse d2 functions to create your date
> of birth.
>
>         As an example, in an enrollment form of a program I calculate the
> date of birth automatically (note that the age here is just a value
> type integer, and here all the program rules are performed in the same
> event: the enrollment):
>
>         Program rule, priority 1, I calculate the age in days:
>                 A{Age at enrollment} * 365.25
>         Program rule, priority 2, I calculate the date of birth according
> to
> the day of data capture
>                 d2:addDays(V{enrollment_date}, -#{Age at enrollment in
> days})
>         Program rule, priority 3, I round the date of birth to the 15 of
> June
>                 d2:concatenate(d2:substring(#{Date of birth calculated},
> 0, 4), '-06-15')
>
>
>         After that I obtain an approximate date of birth I can use in the
> d2
> date functions.
>
> Best,
>
> Edouard
>
> 2018-04-11 11:59 UTC+02:00, Em Le Hong <em.hispviet...@gmail.com>:
> > Dear all,
> >
> > I create a tracker data element value type: Age
> >
> > For event program, I want to use program to check and show error if Age
> is
> > under 5
> > I tried 2 functions d2:yearsBetween; d2:daysBetween with the expression
> as
> > below but it doesn't work:
> >
> > d2:daysBetween(#{age_value_type}, V{event_date})
> > d2:yearsBetween(#{age_value_type}, V{event_date})
> >
> > I check the manual Table 21.13. Custom functions to use in a program rule
> > expression
> > https://docs.dhis2.org/2.29/en/user/html/configure_
> program_rule.html#create_program_rule
> >  and don't see any functions for Age value type.
> >
> > I created a ticket on DHIS2 Jira https://jira.dhis2.org/browse/
> DHIS2-3381
> >
> >
> > I'm really appreciated if anyone has experience on this can share.
> >
> >
> > Regards,
> >
> >
> >
> > --
> > *Em Le Hong*
> > DHIS2 Implementation| *HISP Vietnam *
> > em.hispviet...@gmail.com | *Skype:* em.hispviet...@gmail.com
> >
>
>
> --
> *Edouard Lavaud, *
>
>
>
> *MSc in Health Policy, Planning & FinancingMEng in
> TelecommunicationUniversity Diploma in ICT for Health*
> *Email:* edouard.lav...@gmail.com
> *Mobile:* 0033 6 7210 23 59
>



-- 
*Em Le Hong*
DHIS2 Implementation| *HISP Vietnam *
em.hispviet...@gmail.com | *Skype:* em.hispviet...@gmail.com
_______________________________________________
Mailing list: https://launchpad.net/~dhis2-users
Post to     : dhis2-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to