Stream: cql
Topic: population criteria in Patient-based measure
Tien Thai (Dec 04 2019 at 20:09):
Supposed I have defined an expression that returns a single tuple containing a decimal number such as one below:
define "Active Prescriptions In The Opioid Episode with Average MME":
"Opioid Prescriptions With Total MME" ActiveMedication
return {
averageMME: Round(ActiveMedication.totalMME / "Length Of The Opioid Episode", 2)
}
Assuming my measure is a patient-based measure, how would I identify a patient with averageMME > 50 in the numerator? I have added the above expression in the Numerator and it compiles OK (see below) but failed when saving grouping with the following error:
Numerator 1 : For Patient-based Measures, all definitions directly added to populations must return a Boolean.
define "Numerator":
"Active Prescriptions In The Opioid Episode with Average MME" A
where A.averageMME > 50.0
Can you please let me know how to get around this issue? Your help is appreciated.
TT
Chris Moesel (Dec 04 2019 at 21:29):
Hi @Tien Thai. Your Numerator is a query -- so it will actually return a list of "Active Prescriptions In The Opioid Episode with Average MME" that have the averageMME > 50.0. A list is not a boolean, so it doesn't work as a numerator. I think what you really want to know is if the patient has any episodes that met that criteria. If I correctly understand what you're trying to do, it's as simple as wrapping that query with exists
:
define "Numerator": exists ("Active Prescriptions In The Opioid Episode with Average MME" A where A.averageMME > 50.0)
Tien Thai (Dec 04 2019 at 21:37):
Chris,
Thank you very much for your quick response. Yes, that is exactly what I am trying to do. I have tried your approach before and it gave me a validation error because the "Active Prescriptions In The Opioid Episode with Average MME" expression returns a single tuple (i.e. averageMME) and so exists will not work in this case. I have been trying several approaches so far none is working. Many thanks.
TT
Chris Moesel (Dec 04 2019 at 21:51):
Oh. OK -- without the full source, it was hard to tell that it returned a singleton. If that's the case, have you tried:
define "Numerator": "Active Prescriptions In The Opioid Episode with Average MME".averageMME > 50.0
Tien Thai (Dec 05 2019 at 14:36):
Yes, it works. Thank you very much for your help, Chris!
TT
Last updated: Apr 12 2022 at 19:14 UTC