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

Madie production FQM-Execution-Execution bug #227

Closed mcmcphillips closed 1 year ago

mcmcphillips commented 1 year ago

Summary

When running FQM execution with the provided measure bundle and patient bundle, an error is thrown specifying an iterable. Elm for supporting libraries does not appear to have any issues.

` error occurred in FQM-Execution TypeError: The following error occurred in the cql-execution engine: intervals is not iterable

- Inspect the content of the ELM and ensure the data types in the expressions are correct

at collapseIntervals (interval.js:606:1)
at Collapse.exec (interval.js:599:1)
at async Collapse.execute (expression.js:24:1)
at async Promise.all (index 0)
at async Query.exec (query.js:196:1)
at async First.exec (list.js:224:1)
at async First.execute (expression.js:24:1)
at async Promise.all (index 0)
at async OverlapsAfter.exec (interval.js:165:1)
at async OverlapsAfter.execute (expression.js:24:1)

o`

Expected Behavior

FQM-Execution Calculate.calculate runs without error

Version or Commit

Inputs (e.g. Measure Bundle, Patient Bundle, CQL Library)

measure bundle ATM-v0.0.000-FHIR.txt patient bundle patientBundle.txt

Relevant Calculation Options (e.g. Measurement Period, meta.profile Validation)

cql-to-elm Version Used for Measure Logic Translation (if known)

Any Additional Info

@mgramigna

JSRankins commented 1 year ago

Attached is the JSON. patientBundle.txt

natjoe4 commented 1 year ago

@JSRankins, @mcmcphillips Thank you for bringing this to our attention. @elsaperelli and I traced this error back to an issue in cql-execution that caused calculation to fail when collapsing a null interval.

From AHAOverall.cql Library:

when Event is MedicationRequest then
                  First( ( collapse (Event.dosageInstruction.timing.repeat.bounds DoseTime
                                        return DoseTime.toInterval()) ) DrugPeriods
                           sort by start of $this ) overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period 

The MedicationRequests included in the Patient Bundle do not have values for dosageInstruction.timing.repeat.bounds[x], so DoseTime.toInterval() was evaluating to null. Cql-execution's interpretation of collapse had a small logic issue that caused the argument of the collapse function to be iterated over before checking if it was null hence the intervals is not iterable message. We submitted the above PR to cql-execution, and were able to successfully run calculation with your bundles after these changes.

hossenlopp commented 1 year ago

This has been fixed and published to npm in cql-execution v3.0.0-beta.5 and fqm-execution v1.1.0.