Auto Calculation for Age

I want to automate age calculation. For instance, if a patient is 20 years old at the time of registration, and they return for a follow-up two years later, their age should automatically update to 22 years in the follow-up form. How can I get this?

Hello @Swe,

I would recommend collecting a date of birth during registration and then recalculating age within subsequent forms as needed. This date of birth would be saved as a case property.

If this is not feasible, you can generate an approximate date of birth based off age at the time of registration and save it as a case property. This could be done by either assuming that the registration date is the birthday (minus their age in years) or assuming their birthday was 6 months previous (minus their age in years) so that in this case the patient was 20.5 at the time of registration.

You'll need to use CommCare functions to do this: https://dimagi.atlassian.net/wiki/spaces/commcarepublic/pages/2143957589/CommCare+Functions

This post may be helpful as well since it shows how to use some of the date functions: Calculation Age from DOB

-Alejandro