Curriculum 'User Guide Viedoc 4'

Calculating the age of a patient Download PDF

1 Age

  • To derive the age from the date of informed consent and date of birth variables, the below code can be used:

    var a = BRTHDAT;
    var b = ICDAT;
    var ret = '';
    //Checking for the null conditions
    if(a != null && b != null)
    {
    ret = 0;
    //Calculating AGE
    ret = b.getFullYear()-a.getFullYear();
    ret--;
    if(a.getMonth() < b.getMonth())
    {
    ret++;
    }
    if(b.getMonth() == a.getMonth() &&
    a.getDate() <= b.getDate())
    {
    ret++;
    }
    return ret;}

Was this information helpful?