forked from cqframework/ecqm-content-qicore-2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEXM165v8QICore4.cql
173 lines (141 loc) · 7.39 KB
/
EXM165v8QICore4.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
166
167
168
169
170
171
172
173
library EXM165v8QICore4 version '8.5.000'
/*
Controlling High Blood Pressure (CBP)
*/
using QICore version '4.1.1'
include FHIRHelpers version '4.1.000'
include CQMCommon version '1.0.000' called CQMCommon
include QICoreCommon version '1.2.000' called QICoreCommon
include AdultOutpatientEncountersQICore4 version '3.0.000' called AdultOutpatientEncounters
include SupplementalDataElements version '3.0.000' called SDE
include AdvancedIllnessandFrailtyExclusionQICore4 version '6.0.000' called FrailtyLTI
include HospiceQICore4 version '3.0.000' called Hospice
//include NCQACommon_FHIR version '3.10.000' called Common
//include Participation_FHIR version '1.0.0'
codesystem "LOINC": 'urn:oid:2.16.840.1.113883.6.1'
valueset "Chronic Kidney Disease, Stage 5": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1002'
valueset "Dialysis Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.109.12.1013'
valueset "ED": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1085'
valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
valueset "End Stage Renal Disease": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.353'
valueset "ESRD Monthly Outpatient Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.109.12.1014'
valueset "Essential Hypertension": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.104.12.1011'
valueset "Ethnicity": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.837'
valueset "Kidney Transplant": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.109.12.1012'
valueset "Kidney Transplant Recipient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.109.12.1029'
valueset "ONC Administrative Sex": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1'
valueset "Payer": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591'
valueset "Pregnancy": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.378'
valueset "Race": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.836'
valueset "Vascular Access for Dialysis": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.109.12.1011'
code "Birth date": '21112-8' from "LOINC" display 'Birth date'
code "Blood pressure": '85354-9' from "LOINC" display 'blood pressure'
code "Diastolic blood pressure": '8462-4' from "LOINC" display 'Diastolic blood pressure'
code "Systolic blood pressure": '8480-6' from "LOINC" display 'Systolic blood pressure'
parameter "Measurement Period" Interval<DateTime>
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 "Has Diastolic Blood Pressure Less Than 90":
"Lowest Diastolic Reading on Most Recent Blood Pressure Day".value < 90
define "Has Systolic Blood Pressure Less Than 140":
"Lowest Systolic Reading on Most Recent Blood Pressure Day".value < 140
define "Lowest Diastolic Reading on Most Recent Blood Pressure Day":
First(
"Qualifying Diastolic Blood Pressure Reading" DBPReading
where DBPReading.effective same day as "Most Recent Blood Pressure Day"
return singleton from (
DBPReading.component C
where C.code ~ "Diastolic blood pressure"
return C.value as Quantity
)
sort ascending
)
define "Lowest Systolic Reading on Most Recent Blood Pressure Day":
First(
"Qualifying Systolic Blood Pressure Reading" SBPReading
where SBPReading.effective same day as "Most Recent Blood Pressure Day"
return singleton from (
SBPReading.component C
where C.code ~ "Systolic blood pressure"
return C.value as Quantity
)
sort ascending
)
define "Blood Pressure Days":
( ( "Qualifying Diastolic Blood Pressure Reading" DBPExam
return date from DBPExam.effective
)
intersect ( "Qualifying Systolic Blood Pressure Reading" SBPExam
return date from SBPExam.effective
)
)
define "Most Recent Blood Pressure Day":
Max("Blood Pressure Days")
define "Qualifying Diastolic Blood Pressure Reading":
["observation-bp"] BloodPressure
where BloodPressure.DiastolicBP.value is not null
and BloodPressure.status in {'final', 'amended'}
and BloodPressure.effective during "Measurement Period"
// TODO: Turn this into a value set
and not (GetEncounter(BloodPressure.encounter).class.code in { 'EMER', 'IMP', 'ACUTE', 'NONAC', 'PRENC', 'SS'})
// TODO: Move to Common Functions
define function GetEncounter(reference Reference):
singleton from ( [Encounter: id in QICoreCommon.GetId(reference.reference)] )
define "Qualifying Systolic Blood Pressure Reading":
["observation-bp"] BloodPressure
where BloodPressure.status in {'final', 'amended'}
and BloodPressure.effective during "Measurement Period"
// TODO: Turn this into a value set
and not (GetEncounter(BloodPressure.encounter).class.code in { 'EMER', 'IMP', 'ACUTE', 'NONAC', 'PRENC', 'SS'})
//Note: Once we can specify that the FHIR BP Profile must be used, then status, code, and unit will not be required
define "Numerator":
"Has Diastolic Blood Pressure Less Than 90"
and "Has Systolic Blood Pressure Less Than 140"
define "Initial Population":
CalculateAgeInYearsAt(ToDate(Patient.birthDate), end of "Measurement Period") between 18 and 85
and exists "Essential Hypertension Diagnosis"
and exists AdultOutpatientEncounters."Qualifying Encounters"
define "Pregnancy Or Renal Diagnosis Exclusions":
( ["Condition": "Pregnancy"]
union ["Condition": "End Stage Renal Disease"]
union ["Condition": "Kidney Transplant Recipient"]
union ["Condition": "Chronic Kidney Disease, Stage 5"] ) PregnancyESRDDiagnosis
where PregnancyESRDDiagnosis.verificationStatus = QICoreCommon."confirmed"
and PregnancyESRDDiagnosis.recordedDate before end of "Measurement Period"
define "Denominator":
"Initial Population"
define "End Stage Renal Disease Encounter":
["Encounter": "ESRD Monthly Outpatient Services"] ESRDEncounter
where ESRDEncounter.status in { 'arrived', 'triaged', 'in-progress', 'onleave', 'finished' }
and ESRDEncounter.period starts before end of "Measurement Period"
define "End Stage Renal Disease Procedures":
( ["Procedure": "Vascular Access for Dialysis"]
union ["Procedure": "Kidney Transplant"]
union ["Procedure": "Dialysis Services"] ) ESRDProcedure
where ESRDProcedure.status = 'completed'
and (ESRDProcedure.performed starts before end of "Measurement Period")
define "Essential Hypertension Diagnosis":
["Condition": "Essential Hypertension"] Hypertension
where Hypertension.verificationStatus = ToConcept(QICoreCommon."confirmed")
and (Hypertension.recordedDate 6 months or less on or after start of "Measurement Period"
or Hypertension.recordedDate before end of "Measurement Period"
)
// TODO: Translate exclusions
/*
define "Denominator Exclusions":
Hospice."Has Hospice"
or exists "Pregnancy Or Renal Diagnosis Exclusions"
or ( exists "End Stage Renal Disease Procedures"
or exists "End Stage Renal Disease Encounter"
)
or (Common."CalendarAgeInYearsAt"(ToDateTime(Patient.birthDate), start of "Measurement Period")>= 65 )
and FrailtyLTI."Has Spent More Than 90 Days in Long Term Care"
or FrailtyLTI."Advanced Illness and Frailty Exclusion Including Over Age 80"
*/