Add tests for the CalculateAgeAt operators (clinical operators have none)
Maintainers usually reply within 5 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- testing-qa
Research direction
Work in tests/cql/CqlClinicalOperatorsTest.xml, using the proposed XML structure and CalculateAgeAt expressions as the starting point. Compare nearby CQL test files and verify the new clinical-operators capability is accepted by the test suite. Done means the listed precision, birthday, DateTime, and null cases are represented and pass validation.
Written by the indexing model from the issue text.
Description
Gap
tests/cql has no test for any operator in Appendix B, section "Clinical Operators": there is no CalculateAge…At expression anywhere in the suite (grep -r CalculateAge tests/cql is empty at 9e92193), and none of the open pull requests adds one. The CalculateAgeAt family is one of the most used operators in real measure logic (every age-band population criterion), and it has its own edge cases (birthday not yet reached in the asOf year, null operands, the coarser-precision uncertainty the specification describes).
Proposal
A new file tests/cql/CqlClinicalOperatorsTest.xml with one group per precision. The values below are for someone born 1976-01-01 as of 2020-01-02: 44 years; 528 months; 16072 days (2296 weeks); 385728 hours, 23143680 minutes, 1388620800 seconds. Following the specification (CQL 1.5.3, Appendix B, "CalculateAgeAt": "if the given birthDate or asOf are not specified to the level of precision corresponding to the operator being invoked, the result will be an uncertainty"), the hour/minute/second cases use full DateTime literals, so their results are single values; the year/month/week/day cases use Date literals, which are precise enough for those precisions.
<?xml version="1.0" encoding="utf-8"?>
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://hl7.org/fhirpath/tests" xsi:schemaLocation="http://hl7.org/fhirpath/tests ../../testSchema/testSchema.xsd"
name="CqlClinicalOperatorsTest" reference="https://cql.hl7.org/09-b-cqlreference.html#clinical-operators-3" version="1.0">
<capability code="clinical-operators" />
<group name="CalculateAgeAt" version="1.0" reference="https://cql.hl7.org/09-b-cqlreference.html#calculateageat">
<capability code="clinical-operators" />
<test name="CalculateAgeInYearsAtSpecExample" version="1.0">
<!-- the specification's own example -->
<expression>CalculateAgeInYearsAt(@2000-01-01, @2015-01-01)</expression>
<output>15</output>
</test>
<test name="CalculateAgeInYearsAt" version="1.0">
<expression>CalculateAgeInYearsAt(@1976-01-01, @2020-01-02)</expression>
<output>44</output>
</test>
<test name="CalculateAgeInYearsAtDayBeforeBirthday" version="1.0">
<!-- the birthday in the asOf year has not been reached -->
<expression>CalculateAgeInYearsAt(@1976-01-02, @2020-01-01)</expression>
<output>43</output>
</test>
<test name="CalculateAgeInYearsAtDateTime" version="1.0">
<expression>CalculateAgeInYearsAt(@1976-01-01T00:00:00.000, @2020-01-02T00:00:00.000)</expression>
<output>44</output>
</test>
<test name="CalculateAgeInYearsAtNullAsOf" version="1.0">
<expression>CalculateAgeInYearsAt(@2000-01-01, null)</expression>
<output>null</output>
</test>
<test name="CalculateAgeInYearsAtNullBirthDate" version="1.0">
<expression>CalculateAgeInYearsAt(null, @2015-01-01)</expression>
<output>null</output>
</test>
<test name="CalculateAgeInMonthsAt" version="1.0">
<expression>CalculateAgeInMonthsAt(@1976-01-01, @2020-01-02)</expression>
<output>528</output>
</test>
<test name="CalculateAgeInWeeksAt" version="1.0">
<expression>CalculateAgeInWeeksAt(@1976-01-01, @2020-01-02)</expression>
<output>2296</output>
</test>
<test name="CalculateAgeInDaysAt" version="1.0">
<expression>CalculateAgeInDaysAt(@1976-01-01, @2020-01-02)</expression>
<output>16072</output>
</test>
<test name="CalculateAgeInHoursAt" version="1.0">
<expression>CalculateAgeInHoursAt(@1976-01-01T00:00:00.000, @2020-01-02T00:00:00.000)</expression>
<output>385728</output>
</test>
<test name="CalculateAgeInMinutesAt" version="1.0">
<expression>CalculateAgeInMinutesAt(@1976-01-01T00:00:00.000, @2020-01-02T00:00:00.000)</expression>
<output>23143680</output>
</test>
<test name="CalculateAgeInSecondsAt" version="1.0">
<expression>CalculateAgeInSecondsAt(@1976-01-01T00:00:00.000, @2020-01-02T00:00:00.000)</expression>
<output>1388620800</output>
</test>
</group>
</tests>
Notes:
clinical-operatorswould be a new capability code; none of the existing codes covers this section.AgeInYearsAtand the otherAge…operators without a birth date need aPatientcontext and a data model, so they are out of reach of this expression-only format; theCalculateAge…Atoverloads exercise the same duration logic without that dependency.- A case where the birth date is 29 February and
asOfis 28 February of a non-leap year would exercise the same rule asYearsBetweenLeapYearDatesEquals2; I left it out to keep this proposal independent of that test.
If the committers prefer a pull request, I can open one with this file.
- Dominant language
- No language data
- Stars
- 8
- Forks
- 9
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 3
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cqframework/cql-tests
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
cqframework/cql-tests#182 ·
Maintainers usually reply within 5 days
-
CqlComparisonOperatorsTest: NotEquivalentNullNull marks `null !~ null` invalid, where the specification gives it as falsePossibly taken @leftonmars claimed this 13 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 78/100
cqframework/cql-tests#172 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
cqframework/cql-tests#170 ·
Maintainers usually reply within 5 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
cqframework/cql-tests#158 ·
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
cqframework/cql-tests#153 · 2 comments ·
Maintainers usually reply within 5 days
All issues in cqframework/cql-tests
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
hermes hooks doctor smoke test never checks the hook exit code — a crashing hook (exit=1) renders ✓ "ran clean" and "All shell hooks look healthy"Possibly taken @cestercian claimed this today. Opencomp/cli P2 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NousResearch/hermes-agent#162259 · 1 comment ·
Maintainers usually reply within 1 day