Skip to content

Patient.js.coffee calculates age incorrectly. #1

@rrusk

Description

@rrusk

The current implementation of hquery/patientapi doesn't account for leap years. Consequently, a patient within about 16 days of their 65th birthday is 65 rather than 64 according to patient.age. The code should have 365.25 rather than 365 in the calculation of oneYear, as in the snippet below taken from https://github.com/scoophealth/patientapi/blob/scoop-develop/app/assets/javascripts/patient.js.coffee

*

@param (Date) date the date at which the patient age is calculated, defaults to now.
@returns {number} the patient age in years

age: (date = new Date()) ->
oneDay = 24_60_60_1000;
oneYear = 365.25_oneDay;
return (date.getTime()-this.birthtime().getTime())/oneYear;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions