cqframework / clinical_quality_language

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.
https://confluence.hl7.org/display/CDS/Clinical+Quality+Language
Apache License 2.0
262 stars 121 forks source link

[do not merge!] Align CQL's grammar with that of FHIRPath to fix operator precedence inconsistencies #1385

Open antvaset opened 2 months ago

antvaset commented 2 months ago

This branch contains proposed changes to CQL's grammar (and therefore spec) to make operator precedence work the same way it does in FHIRPath.

...some background on this issue

The following is a valid FHIRPath expression:

(0 | 1 | 2).take(2) = 0 | 1

which evaluates to true (you can use this https://hl7.github.io/fhirpath.js/ to confirm). But in CQL it currently throws an error because = takes precedence over |, so it's trying to parse ((0 | 1 | 2).take(2) = 0) | 1 and not (0 | 1 | 2).take(2) = (0 | 1). The pipe operator is defined to be equivalent to union, and union is currently explicitly below = in CQL's operator precedence table (https://cql.hl7.org/03-developersguide.html#operator-precedence). In FHIRPath however, the pipe has higher precedence than = (https://build.fhir.org/ig/HL7/FHIRPath/#operator-precedence).

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 63.71%. Comparing base (179c762) to head (7efaada).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1385 +/- ## ============================================ + Coverage 63.69% 63.71% +0.01% Complexity 2666 2666 ============================================ Files 492 492 Lines 27738 27738 Branches 5511 5511 ============================================ + Hits 17669 17672 +3 + Misses 7828 7825 -3 Partials 2241 2241 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.