@Natalie_Tibbels
Firstly, program rules are not executed when you run analytics (you are mixing it up with program INDICATORS, which ARE executed during any analytics run). They are only executed when opening or editing cases in the Tracker Capture or Capture Apps.
Secondly, you must set the ASSIGN rules up so that they use the Date of Birth and e.g. the enrollment date, which both stay as they are, unless any of them is edited to fix a capturing error (DoB can of course be corrected in the dashboard - enrollment date mistakes are currently not editable in the UI, you have to update it directly in the database. Ref JIRA #5942).
We use the following rules:
Program rules:
1.
Name: Calculate age in days for children less than one month old
Expression: d2:hasValue(‘enrollment_date’) && d2:hasValue(‘dateOfBirth’) && d2:monthsBetween(A{dateOfBirth},V{enrollment_date}) < 1
Action items:
Assign value to Age (years), expression: d2:floor(1/2) (returns 0)
Assign value to Age (months), expression: d2:floor(1/2) (returns 0)
Assign value to Age (days), expression: d2:daysBetween(A{dateOfBirth},V{enrollment_date})
-
Name: Calculate age in months for children 1-11 months
Expression: d2:hasValue(‘enrollment_date’) && d2:hasValue(‘dateOfBirth’) && d2:monthsBetween(A{dateOfBirth},V{enrollment_date}) >= 1 && d2:yearsBetween(A{dateOfBirth},V{enrollment_date}) < 1
Action items:
Assign value to Age (years), expression: d2:floor(1/2) (returns 0)
Assign value to Age (months), expression: d2:monthsBetween(A{dateOfBirth},V{enrollment_date})
Assign value to Age (days), expression: d2:floor(1/2) (returns 0)
-
Name: Calculate age in years and months for patients 1 year and older
Expression: d2:hasValue(‘enrollment_date’) && d2:hasValue(‘dateOfBirth’) && d2:yearsBetween(A{dateOfBirth},V{enrollment_date}) >= 1
Action items:
Assign value to Age (years), expression: d2:yearsBetween(A{dateOfBirth},V{enrollment_date})
Assign value to Age (months), expression: d2:monthsBetween(A{dateOfBirth},V{enrollment_date}) - (d2:yearsBetween(A{dateOfBirth},V{enrollment_date}) * 12)
Assign value to Age (days), expression: d2:floor(1/2) (returns 0)
Best regards
Calle