cqframework / cql-execution

A JavaScript framework for executing CQL
Apache License 2.0
65 stars 30 forks source link

Fix AgeInYears/AgeInMonths when birthday is today #275

Closed cmoesel closed 2 years ago

cmoesel commented 2 years ago

This PR updates the CalculateAge logic to perform calculations using Date-based birthday and Today() when the precision is years or months. This is based on the following language in the spec:

Note that for AgeInYears and AgeInMonths, the birthDate is specified as a Date and Today() is used to obtain the current date; whereas with the other precisions, birthDate is specified as a DateTime, and Now() is used to obtain the current DateTime.

Prior to this change, results for AgeInYears and AgeInMonths could be uncertainties when the birthday is today (since it was considering time components in the calculation).

As part of this change, I've updated some of the existing tests to use a fixed execution datetime, as that makes the tests more reliable (and insusceptible to DST issues). This allowed me to also unskip some previously skipped tests. I've also introduced new tests to ensure the behavior is as expected when using year and month precision.

Fixes #273

Submitter:

Reviewer:

Name: