cqframework/opioid-cds

Modify Prescription Queries to avoid unfiltered Medication retrieve.

sliver007 opened this issue · 1 comments

The following statements in the OpioidCDSCommon.cql library, need to be updated to avoid querying the target FHIR for Medication unrestricted/unfiltered:

"Active Ambulatory Opioid Rx"
"Active Ambulatory Benzodiazepine Rx"
"Active Ambulatory Naloxone Rx"

The current implementation will result in an unfiltered retrieve of Medication if the MedicationRequest.medication is not reference. This needs to be modified to only retrieve Medication if the MedicationRequest.medication[x] is a reference. Like so:

let Med: [Medication: id in (Last(Split((Rx.medication as FHIR.Reference).reference, '/')))]

becomes

let Med: if Rx.medication is Reference then [Medication: id in (Last(Split((Rx.medication as FHIR.Reference).reference, '/')))] else null

Completed