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?
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
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 )