-
Notifications
You must be signed in to change notification settings - Fork 14
/
EXM506.cql
99 lines (76 loc) · 4.8 KB
/
EXM506.cql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
library EXM506 version '0.0.002'
using FHIR version '4.0.1'
include FHIRHelpers version '4.0.001' called FHIRHelpers
include SupplementalDataElementsFHIR4 version '2.0.000' called SDE
include MATGlobalCommonFunctionsFHIR4 version '6.0.000' called Global
codesystem "LOINC": 'http://loinc.org'
valueset "All Primary and Secondary Cancer": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.161'
valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
valueset "Ethnicity": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.837'
valueset "Hospice Care": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.3157.1004.20'
valueset "ONC Administrative Sex": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1'
valueset "Palliative Care": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.162'
valueset "Payer": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591'
valueset "Schedule II and Schedule III Opioids": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.2'
valueset "Schedule IV Benzodiazepines": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1125.1'
code "Birth date": '21112-8' from "LOINC" display 'Birth date'
parameter "Measurement Period" Interval<DateTime>
default Interval[@2019-01-01T00:00:00.0, @2020-01-01T00:00:00.0)
context Patient
define "SDE Ethnicity":
SDE."SDE Ethnicity"
define "SDE Payer":
SDE."SDE Payer"
define "SDE Race":
SDE."SDE Race"
define "SDE Sex":
SDE."SDE Sex"
define "Encounter with an Opioid or Benzodiazepine at Discharge":
"Inpatient Encounter with Age Greater than or Equal to 18" InpatientEncounter
with ("Opioid at Discharge" union "Benzodiazepine at Discharge") OpioidBenzodiazepine
such that FHIRHelpers.ToDateTime(OpioidBenzodiazepine.authoredOn) during (InpatientEncounter.period)
define "Initial Population":
"Encounter with an Opioid or Benzodiazepine at Discharge"
define "Denominator":
"Initial Population"
define "Encounter with Two or More Concurrent Opioids at Discharge":
"Inpatient Encounter with Age Greater than or Equal to 18" InpatientEncounter
where Count(
[MedicationRequest: "Schedule II and Schedule III Opioids"] Opioids
where FHIRHelpers.ToDateTime (Opioids.authoredOn) during (InpatientEncounter.period)
) >= 2
define "Numerator":
"Encounter with Two or More Concurrent Opioids at Discharge"
union "Encounter with a Concurrent Opioid and Benzodiazepine at Discharge"
define "Opioid at Discharge":
["MedicationRequest": "Schedule II and Schedule III Opioids"] OpioidsDischarge
where exists (OpioidsDischarge.category C where FHIRHelpers.ToConcept(C) ~ Global."Discharge")
and OpioidsDischarge.intent = 'plan'
define "Inpatient Encounter with Age Greater than or Equal to 18":
Global."Inpatient Encounter" EncounterInpatient
with ["Patient"] BirthDate
such that AgeInYearsAt(start of FHIRHelpers.ToInterval(EncounterInpatient.period)) >= 18
define "Benzodiazepine at Discharge":
["MedicationRequest": "Schedule IV Benzodiazepines"] BenzodiazepineDischarge
where exists (BenzodiazepineDischarge.category C where FHIRHelpers."ToConcept"(C) ~ Global."Discharge")
and BenzodiazepineDischarge.intent = 'plan'
define "Encounter with a Concurrent Opioid and Benzodiazepine at Discharge":
"Inpatient Encounter with Age Greater than or Equal to 18" InpatientEncounter
with ("Opioid at Discharge") OpioidDischarge
such that FHIRHelpers.ToDateTime(OpioidDischarge.authoredOn) during (InpatientEncounter.period)
with ("Benzodiazepine at Discharge") BenzodiazepineDischarge
such that FHIRHelpers.ToDateTime(BenzodiazepineDischarge.authoredOn) during (InpatientEncounter.period)
define "Denominator Exclusion":
("Inpatient Encounter with Age Greater than or Equal to 18" InpatientEncounter
with [Condition: "All Primary and Secondary Cancer"]Cancer
such that Global."Prevalence Period"(Cancer) overlaps InpatientEncounter.period)
union ("Inpatient Encounter with Age Greater than or Equal to 18" InpatientEncounter
with (["ServiceRequest": "Palliative Care"]
union ["ServiceRequest": "Hospice Care"] ) PalliativeOrHospiceCareOrder
such that PalliativeOrHospiceCareOrder.intent = 'order'
and FHIRHelpers.ToDateTime(PalliativeOrHospiceCareOrder.authoredOn) during InpatientEncounter.period)
union ("Inpatient Encounter with Age Greater than or Equal to 18" InpatientEncounter
with (["Procedure": "Palliative Care"]
union ["Procedure": "Hospice Care"] ) PalliativeOrHospiceCarePerformed
such that Global."Normalize Interval"(PalliativeOrHospiceCarePerformed.performed)
overlaps InpatientEncounter.period)