clinical_quality_language icon indicating copy to clipboard operation
clinical_quality_language copied to clipboard

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

Open antvaset opened this issue 1 year ago • 1 comments

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).

antvaset avatar Jul 18 '24 03:07 antvaset

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). Report is 34 commits behind head on master.

Additional details and impacted files
@@             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.

codecov[bot] avatar Jul 18 '24 03:07 codecov[bot]

Superseded by https://github.com/cqframework/clinical_quality_language/pull/1436

antvaset avatar Nov 05 '24 20:11 antvaset