Restriction on age

Good morning,
I want to put a restriction on the age on a tracker entity attribute (date of birth) so the users have warning when entrying a date which will make the patient more than 15 years old:
I created a program rule for that
this is the program rule expression:
d2:yearsBetween(V{incident_date}, A{EMR_Date_of_birth})>β€˜15’
and the action is to show error.

But this is not working it still allow the user to write a date which will make the patient more than 15 years old and there are no error shown. What will be your advise please?

Use just numbers, without ’ signs

2 Likes

Hello Cleia,

As Ulanbek mentionned, you should drop the ’ in your expression but also invert your two factors as d2:yearsBetween(a,b)>15 is actually checking a-b >15 which means in your case that it will always be β€œfalse” unless the date of birth is at least 15 years in the future :wink:

You should try with: d2:yearsBetween(A{EMR_Date_of_birth},V{incident_date})>15

Also, mind the difference between V{incident_date}, V{event_date} & V{current_date} (if you didn’t yet ofc :slight_smile: )

Cheers,

Thomas

1 Like

Thank you very much, for your help @Ulanbek and @Thomas_Warichet i have tried this d2:yearsBetween(A{EMR_Date_of_birth},V{incident_date})>15

and it is well functionning

1 Like