-
Notifications
You must be signed in to change notification settings - Fork 24
QA Returning a List Versus a First Element
Please see the following CQL logic:
define "Denominator":
First (
["Encounter, Performed": "ICU Admission or Transfer"] ICU
with "Initial Population" E
such that ICU.relevantPeriod during E.relevantPeriod
sort by start of relevantPeriod
)
define "Procedures":
"Denominator" D
with (
(
["Procedure, Performed": "General Surgery"]
union
["Procedure, Performed": "Gynecological Surgery"]
) Procedure
where Procedure.ordinality in "Principal"
) P
such that P.relevantPeriod ends 1 day or less on or after day of start of D.relevantPeriod
and P.relevantPeriod ends on or after start of D.relevantPeriod
It seems that the way First() is applied to the "Denominator" definition causes an error when it is called by the "Procedures" definition. When I tried not using First() in "Denominator", then "Procedures" can be saved successfully. I assume that there is something wrong in the "Denominator" definition.
A solution I tried for the issue was adding { } as:
define "Denominator":
{First(
["Encounter, Performed": "ICU Admission or Transfer"] ICU
with "Initial Population" E
such that ICU.relevantPeriod during E.relevantPeriod
sort by start of relevantPeriod
)}
It works in MAT. However, it causes measure calculation error. When a case without ICU, this statement still returns TRUE due to {Null}. How to solve this problem?
So, taking a step back, is this an Episode-based measure? And if so, is it really the case that only the first encounter contributes to the measure?
Yes. It is EOC measure and looking for first of ICU during Encounter. With {}, it seems work as exporting. But it causes measure calculation error when there is no ICU occurs in Encounter. {NILL} return true so measure counts as 1 eligible denominator. Do you have any solution for this?
So the inpatient encounter is in the denominator if it has a first ICU during the encounter, but that first ICU encounter isn't what we're actually counting. So reorder the expressions to return the inpatient encounter as the encounter in the denominator:
define "Denominator":
"Initial Population" E
with ["Encounter, Performed": "ICU Admission or Transfer"] ICU
such that ICU.relevantPeriod during E.relevantPeriod
Then it only matters that there is an ICU during the encounter, not that it's the first one. If you need the first one for subsequent criteria, introduce a different expression to find the first ICU.
I've already taken same approach for Denominator section and made "First ICU" as a separate definition.
Now we get back to the original question I have, does "First ICU" need {} or not? Apparently without {}, "First ICU" will cause "internal translator error" when it is called by other definition.
I believe it should work without {}, but it does not work as expected.
define "First ICU":
{First (
["Encounter, Performed": "ICU Admission or Transfer"] ICU
with "Initial Population" E
such that ICU.relevantPeriod during E.relevantPeriod
sort by start of relevantPeriod
)}
No, the braces are not required in the definition, but it means that the result of First ICU is a single encounter, not a list of encounters. I translated the attached and don't see any errors, is there somewhere that is still causing an issue for you?
For subsequent use, we don't want the first ICU for any encounter during the measurement period, we want the first ICU for each encounter, so we can use a return to give the first ICU for every encounter in the Initial Population:
define "First ICU":
"Initial Population" E
return
First(
["Encounter, Performed": "ICU Admission or Transfer"] ICU
where ICU.relevantPeriod during E.relevantPeriod
sort by start of relevantPeriod
)
With this change the translation completes, and I think this is actual intent of the First ICU expression.
Authoring Patterns - QICore v4.1.1
Authoring Patterns - QICore v5.0.0
Authoring Patterns - QICore v6.0.0
Cooking with CQL Q&A All Categories
Additional Q&A Examples
Developers Introduction to CQL
Specifying Population Criteria