projecttacoma / fqm-execution

fqm-execution is a library that allows users to calculate FHIR-based electronic Clinical Quality Measures (eCQMs) and retrieve the results in a variety of formats
https://projecttacoma.github.io/fqm-execution/
Apache License 2.0
18 stars 6 forks source link

Age highlighting issue #207

Closed elsaperelli closed 1 year ago

elsaperelli commented 1 year ago

Summary

Fixes #202 Even though we deduced that this error was the result of how the cql-to-elm translator works (see cql-to-elm translator issue here), this PR provides a work around for this issue in fqm-execution (see Matt's explanation on the fqm-execution issue here).

New behavior

The cql-to-elm translator causes the ELM Binary Expressions where one side of the comparison is of type Literal to result in the operator (in the case of the issue, <=) being grouped in with the literal it is being compared to. Regardless of whether or not this is intentional or a mistake, this PR creates a workaround that makes sure the expression with the literal and comparison operator in it does not use its localId, but rather the localId of the actual comparison expression itself. Doing so makes sure that the highlighting is correct. In order to do this, special handling is added for cql comparison operations.

Code changes

Testing guidance

  1. npm run check
  2. Download the below zip file and unzip it in the main directory of fqm-execution. It includes a highlighting-issue folder, age-highlighting.ts file, and a run.sh script. The highlighting-issue folder contains two patient bundles, patient-bundle-fail.json has a patient who is younger than 66 and patient-bundle-pass.json has a patient who is older than 66, literal-on-left.json elm json file where the CQL comparison expression has the literal on the left side, literal-on-right.json elm json file where the CQL comparison expression has the literal on the right side (the example in the issue), highlightIssue.cql file that contains minimum cql to replicate the issue, and FHIRHelpers.cql. I included the last two files incase anyone wanted to test another situation and bundle it using ecqm-bundler.
  3. ./run.sh This runs the detailed calculation on four different measure/patient bundle combinations and puts the resulting logic highlighting html in a folder called html.
  4. cd html
  5. Look at the four resulting html files. They should look as follows:

right-fail.html

image

left-fail.html

image

These both make sense because the patient in patient-bundle-fail.json is younger than 66, so we want to make sure that the comparison is highlighted in red. This is the solution that was agreed upon in the issue thread.

right-pass.html & left-pass.html

image

This makes sense because the patient in patient-bundle-pass.json is older than 66 so it should be highlighted green.

  1. If you want to use the cli instead of the script, you can run the following and then navigate to the debug html folder to see the html: npm run cli -- detailed -m highlight-issue/literal-on-right.json -p highlight-issue/patient-bundle-fail.json -o --debug -s 2023-01-01 -e 2023-12-31

age-highlighting-testing.zip

github-actions[bot] commented 1 year ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟢 Statements
85.04% (+0.04% 🔼)
1996/2347
🟡 Branches
73.79% (+0.14% 🔼)
1768/2396
🟢 Functions
87.13% (+0.03% 🔼)
352/404
🟢 Lines
85.33% (+0.04% 🔼)
1926/2257

Test suite run success

366 tests passing in 28 suites.

Report generated by 🧪jest coverage report action from fd67bf485ff3cf4a409cc66e45120c181353b814

sarahmcdougall commented 1 year ago

I'm not an official reviewer on this, but I wanted to leave a comment to give kudos for such a well-written PR description. The testing guidance is very detailed, and linking all the related Github issues will make it easy for us to use this as a reference for why we implemented this workaround. Good work!