Clinical Quality Language (CQL) is an HL7 specification for the expression of clinical knowledge that can be used within both the Clinical Decision Support (CDS) and Clinical Quality Measurement (CQM) domains. This repository contains complementary tooling in support of that specification.
This PR deduplicates the conditional and date/time operator tests in this codebase.
Conditional operator tests
Removed engine/.../CqlConditionalOperatorsTest.cql, all tests already exist in CqlConditionalOperatorsTest.xml.
Date/time operator tests
Merged all tests from engine/.../CqlDateTimeOperatorsTest.cql into CqlDateTimeOperatorsTest.xml.
Note that:
1) I updated the DateTimeComponentFromTimezone test to expect it to raise a translation error due to the use of the timezone keyword which is no longer supported. Added the new DateTimeComponentFromTimezone2 test which uses the new timezoneoffset keyword. The CQL library was using the timezoneoffset keyword.
2) I updated the TimeDurationBetweenHourDiffPrecision test to expect it to raise a translation error due to the syntax error at Z. Added the new TimeDurationBetweenHourDiffPrecision21 test which does not haveZ, as in the CQL library. 3) TheTimeSameOrBeforeHourFalse0andTimeSameOrBeforeMillisTrue2already existed inCqlDateTimeOperatorsTest.xmlasTimeSameOrBeforeHourTrue2andTimeSameOrBeforeMillisFalse0respectively. 4) I didn't touch theIssue34A,TimeOfDayTest, andIssue34B` tests because they should remain as Java-native tests.
Note also that some of the library-based tests used the equivalence semantics when comparing the evaluation result against the expected result. E.g. for this define in the CQL library:
define DateTimeAdd5Years: DateTime(2005, 10, 10) + 5 years
the Java test case was:
var value = engine.expression(library, "DateTimeAdd5Years").value();
assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2010, 10, 10)));
This PR deduplicates the conditional and date/time operator tests in this codebase.
Conditional operator tests
Removed
engine/.../CqlConditionalOperatorsTest.cql
, all tests already exist inCqlConditionalOperatorsTest.xml
.Date/time operator tests
Merged all tests from
engine/.../CqlDateTimeOperatorsTest.cql
intoCqlDateTimeOperatorsTest.xml
.Note that: 1) I updated the
DateTimeComponentFromTimezone
test to expect it to raise a translation error due to the use of thetimezone
keyword which is no longer supported. Added the newDateTimeComponentFromTimezone2
test which uses the newtimezoneoffset
keyword. The CQL library was using thetimezoneoffset
keyword. 2) I updated theTimeDurationBetweenHourDiffPrecision
test to expect it to raise a translation error due to the syntax error atZ
. Added the newTimeDurationBetweenHourDiffPrecision21 test which does not have
Z, as in the CQL library. 3) The
TimeSameOrBeforeHourFalse0and
TimeSameOrBeforeMillisTrue2already existed in
CqlDateTimeOperatorsTest.xmlas
TimeSameOrBeforeHourTrue2and
TimeSameOrBeforeMillisFalse0respectively. 4) I didn't touch the
Issue34A,
TimeOfDayTest, and
Issue34B` tests because they should remain as Java-native tests.Note also that some of the library-based tests used the equivalence semantics when comparing the evaluation result against the expected result. E.g. for this define in the CQL library:
the Java test case was:
However the corresponding XML test case:
tests that this is CQL evaluates to true which uses the
=
operator`:I still consider these tests to be duplicates because the XML tests that we keep use the narrower semantics.
For all the tests that I added to the XML file that were missing, I used CVL in the output unless the test wasn't passing. For example this:
didn't pass but this did (both with the
=
and~
operators):so I used the equality operator in the expression for these tests (also for consistency with other existing XML tests).
Also, these tests exist both in the CQL library and XML file but have different expected values:
and the XML versions of these tests are currently skipped - something to look into in the future.
All additions to
CqlDateTimeOperatorsTest.xml
are mirrored in https://github.com/cqframework/cql-tests/pull/47.