Age calculation check

Calculate an age using Informed Consent and Date of Birth.

Rule description: calculate age using Date of Informed Consent Signed and Date of Birth.

Rule expression

//Returns the age value as the difference infconst-dob
return dateDiffInYears(infconst,dob);

Definitions

infconst

Corresponds to the Informed Consent item form rule description.

dob

Corresponds to the Date of Birth item from rule description.

Return value

Number

Returns a calculated numerical value with the difference in years between the two given dates.

Verification steps

  1. Using a subject for testing, go to the given visit and form containing the items to check, in this example the date of birth <dob> and date of inform consent signed <infconst>.
  2. Update the form items dob and infconst as in the following table and verify the result is as listed:
    dob infconst Result
    2-Jan-1942 2-Jan-2021 79
    3-Jan-1942 2-Jan-2021 78
    1-Jan-1942 2-Jan-2021 79
    1-Jan-1993 2-Jan-2021 28
    3-Jan-1993 2-Jan-2021 27
    3-Jan-1993 3-Jan-2021 28
    3-Jan-1993 Null Null