clinical-reasoning icon indicating copy to clipboard operation
clinical-reasoning copied to clipboard

collapse of integer intervals fails in 2.4.0

Open revans2023 opened this issue 1 year ago • 3 comments

the example in CQL reference appendix B for collapse (see http://cql.hl7.org/09-b-cqlreference.html#collapse) throws an error in 2.4.0. Example is define "Collapse1To9": collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] } // { Interval[1, 9] }

Using the CQL IDE web site with this CQL (https://cql-runner.dataphoria.org/): library Welcome version '1.0.0' define CollapseIntegerIntervals: collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] }

results in this error message:

evaluation error: { "resourceType": "OperationOutcome", "text": { "status": "generated", "div": "<div xmlns="http://www.w3.org/1999/xhtml">

Operation Outcome

<table border="0"><td style="font-weight: bold;">ERROR[]
\n\t\t\t\n\t\t\n\t"
},
"issue": [
{
"severity": "error",
"details": {
"text": "Unsupported interval point type for FHIR conversion java.lang.Integer"
}
}
]
}

revans2023 avatar Jan 12 '23 16:01 revans2023

This works in CQL Unit test so maybe CQL IDE is an older version of CQL evaluator?

define AssertCanCollapseIntegerIntervals: Message(collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] }, (collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] }) != { Interval[1, 9] }, 'Integer Intervals were not collapsed correctly', 'Error', 'Expected {Interval[1, 9]} but found start=' & ToString(start of First(collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] })) & ' end=' & ToString(end of First(collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] })) )

revans2023 avatar Jan 12 '23 16:01 revans2023

In CQL Author's guide for interval values (see http://cql.hl7.org/02-authorsguide.html#interval-values), the following also do not work in CQL IDE (see https://cql-runner.dataphoria.org/):

  • Interval[3, 5) fails with "Unsupported interval point type for FHIR conversion java.lang.Integer"
  • Interval[3.0, 5.0) fails with "Unsupported interval point type for FHIR conversion java.math.BigDecimal"
  • point from Interval[1, 5] fails with "Cannot perform PointFrom operation on intervals that are not unit intervals."
  • Interval[1, 4] except Interval[3, 6] fails with "Unsupported interval point type for FHIR conversion java.lang.Integer"

revans2023 avatar Jan 12 '23 16:01 revans2023

These all work in 2.4.0:

// see see http://cql.hl7.org/09-b-cqlreference.html#collapse define AssertCanCollapseIntegerIntervals: Message(collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] }, (collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] }) != { Interval[1, 9] }, 'Integer Intervals were not collapsed correctly', 'Error', 'Expected {Interval[1, 9]} but found start=' & ToString(start of First(collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] })) & ' end=' & ToString(end of First(collapse { Interval[1, 4], Interval[4, 8], Interval[7, 9] })) )

// see http://cql.hl7.org/02-authorsguide.html#interval-values define AssertCanUsePointONIntegerIntervals: Message(point from Interval[1, 1], point from Interval[1, 1] != 1, 'Integer Intervals were not correct after using point', 'Error', 'Expected 1 but found start=' & ToString(point from Interval[1, 1]) )

// see http://cql.hl7.org/02-authorsguide.html#computing-intervals define AssertCanUseUnionOnIntegerIntervals: Message(Interval[1, 4] union Interval[3, 6], start of (Interval[1, 4] union Interval[3, 6]) != 1 or end of (Interval[1, 4] union Interval[3, 6]) != 6, 'Integer Intervals were not correct after using union', 'Error', 'Expected Interval[1, 6] but found start=' & ToString(start of (Interval[1, 4] except Interval[3, 6])) & ' end=' & ToString(end of (Interval[1, 4] except Interval[3, 6])) )

define AssertCanUseIntersectOnIntegerIntervals: Message(Interval[1, 4] intersect Interval[3, 6], start of (Interval[1, 4] intersect Interval[3, 6]) != 3 or end of (Interval[1, 4] intersect Interval[3, 6]) != 4, 'Integer Intervals were not correct after using intersect', 'Error', 'Expected Interval[3, 4] but found start=' & ToString(start of (Interval[1, 4] except Interval[3, 6])) & ' end=' & ToString(end of (Interval[1, 4] except Interval[3, 6])) )

define AssertCanUseExceptOnIntegerIntervals: Message(Interval[1, 4] except Interval[3, 6], start of (Interval[1, 4] except Interval[3, 6]) != 1 or end of (Interval[1, 4] except Interval[3, 6]) != 2, 'Integer Intervals were not correctly after using except', 'Error', 'Expected Interval[1, 2] but found start=' & ToString(start of (Interval[1, 4] except Interval[3, 6])) & ' end=' & ToString(end of (Interval[1, 4] except Interval[3, 6])) )

revans2023 avatar Jan 12 '23 17:01 revans2023