forked from DBCG/connectathon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEXM105_FHIR3-8.0.000.cql
165 lines (134 loc) · 7.56 KB
/
EXM105_FHIR3-8.0.000.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
library EXM105_FHIR3 version '8.0.000'
/*
Based on CMS105v8 - Discharged on Statin Medication
Author: TJC
*/
using FHIR version '3.0.0'
include FHIRHelpers version '3.0.0'
include MATGlobalCommonFunctions_FHIR3 version '4.0.000' called Global
include SupplementalDataElements_FHIR3 version '1.0.0' called SDE
include TJCOverall_FHIR3 version '3.6.000' called TJC
codesystem "LOINC": 'http://loinc.org'
codesystem "SNOMEDCT": 'http://snomed.info/sct/731000124108'
codesystem "Diagnosis Role": 'http://hl7.org/fhir/diagnosis-role'
codesystem "RequestIntent": 'http://hl7.org/fhir/request-intent'
valueset "Comfort Measures": 'http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45'
valueset "Discharged to Health Care Facility for Hospice Care": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.207'
valueset "Discharge To Acute Care Facility": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.87'
valueset "Discharged to Home for Hospice Care": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.209'
valueset "Emergency Department Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292'
valueset "Ethnicity": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.837'
valueset "Ischemic Stroke": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.247'
valueset "Hemorrhagic Stroke": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.212'
valueset "LDL-c": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.215'
valueset "Left Against Medical Advice": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308'
valueset "Medical Reason": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.473'
valueset "Non-Elective Inpatient Encounter": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.424'
valueset "Observation Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143'
valueset "ONC Administrative Sex": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1'
valueset "Patient Expired": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309'
valueset "Patient Refusal": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.93'
valueset "Payer": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591'
valueset "Race": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.836'
valueset "Statin Allergen": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.423'
valueset "Statin Grouper": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.19'
// TODO: Use NLM VSAC Canonical URLs
code "Birthdate": '21112-8' from "LOINC" display 'Birth date'
code "Dead": '419099009' from "SNOMEDCT" display 'Dead'
//code "Medication-dischargeMedication": '8654-6' from "LOINC" display 'Hospital Discharge medications'
code "Billing": 'billing' from "Diagnosis Role" display 'Billing'
code "Order": 'order' from "RequestIntent" display 'Order'
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 "Initial Population":
"Encounter with Principal Diagnosis and Age"
define "Encounter with Principal Diagnosis and Age":
"All Stroke Encounter" AllStrokeEncounter
with ["Patient"] BirthDate
such that AgeInYearsAt(AllStrokeEncounter.period.start) >= 18
define "All Stroke Encounter":
"Non Elective Inpatient Encounter" NonElectiveEncounter
where Global.PrincipalDiagnosis(NonElectiveEncounter).code in "Hemorrhagic Stroke"
or Global.PrincipalDiagnosis(NonElectiveEncounter).code in "Ischemic Stroke"
define "Non Elective Inpatient Encounter":
["Encounter": "Non-Elective Inpatient Encounter"] NonElectiveEncounter
where Global."LengthInDays"(NonElectiveEncounter.period)<= 120
and NonElectiveEncounter.period ends during "Measurement Period"
define "Denominator":
TJC."Ischemic Stroke Encounter"
define "Statin Allergy":
["AllergyIntolerance": "Statin Allergen"]
define "Numerator":
"Ischemic Stroke Encounter" IschemicStrokeEncounter
with "Statin at Discharge" DischargeStatin
such that DischargeStatin.authoredOn during IschemicStrokeEncounter.period
define "Ischemic Stroke Encounter":
"Encounter with Principal Diagnosis and Age" EncounterWithAge
where Global.PrincipalDiagnosis(EncounterWithAge).code in "Ischemic Stroke"
// Medication orders at discharge, how do we know that these are ordered with the intent to be taken discharge rather than the inpatient stay.
define "Statin at Discharge":
["MedicationRequest"] Statin
where (Statin.medication as CodeableConcept) in "Statin Grouper"
and Statin.intent = 'order'
define "Statin Not Given at Discharge":
["MedicationRequest"] NoStatin
where (NoStatin.medication as CodeableConcept) in "Statin Grouper"
and (singleton from NoStatin.reasonCode in "Medical Reason"
or singleton from NoStatin.reasonCode in "Patient Refusal")
//Folling function copied from MATGlobalCommonFunctions 2.0 in cqf-measures github repo
define function "Normalize Onset"(onset Choice<FHIR.dateTime, FHIR.Age, FHIR.Period, FHIR.Range, FHIR.string>):
if onset is FHIR.dateTime then Interval[onset.value, onset.value]
else if onset is FHIR.Period then FHIRHelpers.ToInterval(onset as FHIR.Period)
else null
define "Encounter with Max LDL less than 70 mg per dL":
"Ischemic Stroke Encounter" IschemicStrokeEncounter
where Max(["Observation": "LDL-c"] Ldl
where Ldl.issued during Interval[IschemicStrokeEncounter.period.start - 30 days,IschemicStrokeEncounter.period.end]
return (Ldl.value as Quantity)
) < 70
define "Denominator Exception":
("Ischemic Stroke Encounter" IschemicStrokeEncounter
with "Statin Not Given at Discharge" NoDischargeStatin
such that NoDischargeStatin.authoredOn during IschemicStrokeEncounter.period
)
union
("Ischemic Stroke Encounter" IschemicStrokeEncounter
with "Statin Allergy" StatinAllergy
such that "Normalize Onset"(StatinAllergy.onset) on or before end of IschemicStrokeEncounter.period)
define "Denominator Exclusion":
"Ischemic Stroke Encounters with Discharge Status"
union
"Comfort Measures during Hospitalization"
define "Ischemic Stroke Encounters with Discharge Status":
("Ischemic Stroke Encounter" IschemicStrokeEncounter
where IschemicStrokeEncounter.hospitalization.dischargeDisposition in "Discharge To Acute Care Facility"
or IschemicStrokeEncounter.hospitalization.dischargeDisposition in "Left Against Medical Advice"
or IschemicStrokeEncounter.hospitalization.dischargeDisposition in "Patient Expired"
or IschemicStrokeEncounter.hospitalization.dischargeDisposition in "Discharged to Home for Hospice Care"
or IschemicStrokeEncounter.hospitalization.dischargeDisposition in "Discharged to Health Care Facility for Hospice Care"
)
define "Comfort Measures during Hospitalization":
"Ischemic Stroke Encounter" IschemicStrokeEncounter
with "Intervention Comfort Measures" ComfortMeasure
such that ComfortMeasure.authoredOn during Global."Hospitalization"(IschemicStrokeEncounter)
/*
define "Intervention Comfort Measures":
(["ProcedureRequest": "Comfort Measures"] P
where P.intent = 'order')
union ["Procedure": "Comfort Measures"]
*/
define "Intervention Comfort Measures":
(["ProcedureRequest": "Comfort Measures"] P
where P.intent in {'plan', 'order'})
union
(["Procedure": "Comfort Measures"] IntervetionPerformed
where IntervetionPerformed.status in {'complete', 'in progress'})