-
Notifications
You must be signed in to change notification settings - Fork 8
/
ColorectalCancerScreeningsFHIR.cql
318 lines (264 loc) · 16.7 KB
/
ColorectalCancerScreeningsFHIR.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
library ColorectalCancerScreeningsFHIR version '0.0.003'
/* 20220609 modified from ColorectalCancerScreeningsFHIR
default Interval, colonoscopy with inappropriate status, MP 2021,
display order and test case content definitions to assist edge testing, may need to increment increment version number */
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.1.000' called Global
include AdultOutpatientEncountersFHIR4 version '2.2.000' called AdultOutpatientEncounters
include HospiceFHIR4 version '2.3.000' called Hospice
include AdvancedIllnessandFrailtyExclusionECQMFHIR4 version '5.17.000' called FrailtyLTI
include PalliativeCareFHIR version '0.6.000' called PalliativeCare
include CumulativeMedicationDurationFHIR4 version '1.0.000' called CMD
codesystem "ObservationCategoryCodes": 'http://terminology.hl7.org/CodeSystem/observation-category'
valueset "Acute Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1083'
valueset "Advanced Illness": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.110.12.1082'
valueset "Annual Wellness Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1240'
valueset "Care Services in Long-Term Residential Facility": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1014'
valueset "Colonoscopy": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.108.12.1020'
valueset "CT Colonography": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.108.12.1038'
valueset "Dementia Medications": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.196.12.1510'
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 "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 "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
valueset "Fecal Occult Blood Test (FOBT)": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.198.12.1011'
valueset "FIT DNA": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.108.12.1039'
valueset "Flexible Sigmoidoscopy": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.198.12.1010'
valueset "Frailty Device": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.118.12.1300'
valueset "Frailty Diagnosis": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1074'
valueset "Frailty Encounter": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1088'
valueset "Frailty Symptom": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1075'
valueset "Home Healthcare Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1016'
valueset "Hospice care ambulatory": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1108.15'
valueset "Malignant Neoplasm of Colon": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.108.12.1001'
valueset "Nonacute Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1084'
valueset "Nursing Facility Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012'
valueset "Observation": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1086'
valueset "Office Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001'
valueset "Online Assessments": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1089'
valueset "Outpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1087'
valueset "Preventive Care Services - Established Office Visit, 18 and Up": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1025'
valueset "Preventive Care Services-Initial Office Visit, 18 and Up": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1023'
valueset "Telephone Visits": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1080'
valueset "Total Colectomy": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.198.12.1019'
// add for Condition
valueset "Total Colectomy ICD9": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.198.11.1136'
code "laboratory": 'laboratory' from "ObservationCategoryCodes" display 'laboratory'
parameter "Measurement Period" Interval<DateTime>
default Interval[@2021-01-01T00:00:00.0, @2022-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 "Telehealth Services":
( [Encounter: "Online Assessments"]
union [Encounter: "Telephone Visits"] ) TelehealthEncounter
where TelehealthEncounter.status = 'finished'
and Global."Normalize Interval" ( TelehealthEncounter.period ) during "Measurement Period"
/* add display of age to result output for edge testing*/
define "Age at start of Measurement Period":
AgeInYearsAt(date from start of "Measurement Period")
define "Initial Population":
AgeInYearsAt(date from start of "Measurement Period")in Interval[51, 75 )
and exists ( AdultOutpatientEncounters."Qualifying Encounters"
union "Telehealth Services"
)
define "Denominator":
"Initial Population"
// add "Total Colectomy Condition" for DxCodes
define "Denominator Exclusions":
Hospice."Has Hospice"
or exists "Malignant Neoplasm"
or exists "Total Colectomy Performed"
or exists "Total Colectomy Condition"
or FrailtyLTI."Advanced Illness and Frailty Exclusion Not Including Over Age 80"
or ( AgeInYearsAt(date from start of "Measurement Period")>= 65
and FrailtyLTI."Has Long Term Care Periods Longer Than 90 Consecutive Days"
)
or PalliativeCare."Palliative Care in the Measurement Period"
define "Malignant Neoplasm":
[Condition: "Malignant Neoplasm of Colon"] ColorectalCancer
where Global."Prevalence Period" ( ColorectalCancer ) starts on or before
end of "Measurement Period"
define "Total Colectomy Performed":
[Procedure: "Total Colectomy"] Colectomy
where Colectomy.status = 'completed'
and Global."Normalize Interval" ( Colectomy.performed ) ends on or before
end of "Measurement Period"
// add Condition for DxCodes
define "Total Colectomy Condition":
[Condition: "Total Colectomy ICD9"] ColectomyDx
where Global."Prevalence Period" ( ColectomyDx ) starts on or before
end of "Measurement Period"
// --- Fecal Occult Blood Test ---
// add definition to Display Date, Result, Category, Status of hemoccult, 2 year for edge testing
define "Fecal Occult Blood Test Display Date, Result, Category, Status":
[Observation: "Fecal Occult Blood Test (FOBT)"] FecalOccult
where Global."Latest" ( FecalOccult.effective ) during Interval ( start of "Measurement Period" - 1 year, end of "Measurement Period" )
return Tuple {
occultDate: Global."Latest" ( FecalOccult.effective ),
occultResult: FecalOccult.value.coding.display,
occultCategoryCode: FecalOccult.category.coding.code.value,
occultStatus: FecalOccult.status
}
// add- PROBLEM - category evaluation was not working - THIS WORKS
define "Fecal Occult Blood Test Performed":
[Observation: "Fecal Occult Blood Test (FOBT)"] FecalOccult
where FecalOccult.status in { 'final', 'amended', 'corrected' }
and exists ( FecalOccult.category FecalOccultCategory
where FecalOccultCategory.coding.code.value ~ { 'laboratory' } )
and FecalOccult.value is not null
and Global."Latest" ( FecalOccult.effective ) during "Measurement Period"
// add - PROBLEM - TZoffset issue corrected by use of 'day of' - THIS WORKS
define "Fecal Occult Blood Test Performed, day of TZoffset":
[Observation: "Fecal Occult Blood Test (FOBT)"] FecalOccult
where FecalOccult.status in { 'final', 'amended', 'corrected' }
and exists ( FecalOccult.category FecalOccultCategory
where FecalOccultCategory.coding.code.value ~ { 'laboratory' } )
and FecalOccult.value is not null
and Global."Latest" ( FecalOccult.effective ) during day of "Measurement Period"
// add for edge testing of category but ignore status, use day of for TZoffset issue
// consider potential for presence of EHR data as category 'exam', 'procedure', 'survey' ???
define "Fecal Occult Blood Test Performed without appropriate category, ignore status, day of TZoffset":
[Observation: "Fecal Occult Blood Test (FOBT)"] FecalOccult
where
// FecalOccult.status in { 'final', 'amended', 'corrected' }
// and
exists ( FecalOccult.category FecalOccultCategory
where FecalOccultCategory.coding.code.value !~ { 'laboratory' } )
and FecalOccult.value is not null
and Global."Latest" ( FecalOccult.effective ) during day of "Measurement Period"
// add for edge testing of status but ignore category, use day of for TZoffset issue
define "Fecal Occult Blood Test Performed without appropriate status, ignore category, day of TZoffset":
[Observation: "Fecal Occult Blood Test (FOBT)"] FecalOccult
where not ( FecalOccult.status in { 'final', 'amended', 'corrected' } )
// and exists ( FecalOccult.category FecalOccultCategory
// where FecalOccultCategory.coding.code.value ~ { 'laboratory' } )
and FecalOccult.value is not null
and Global."Latest" ( FecalOccult.effective ) during day of "Measurement Period"
// --- Fecal Immunochemical Test DNA ---
// add definition to Display Date, Result, Category, Status of FitDNA, 4 year for edge testing
define "Fecal Immunochemical Test DNA Display Date, Result, Category, Status":
[Observation: "FIT DNA"] FitDNA
where Global."Latest" ( FitDNA.effective ) 4 years or less on or before
end of "Measurement Period"
return Tuple {
occultDate: Global."Latest" ( FitDNA.effective ),
occultResult: FitDNA.value.coding.display,
occultCategoryCode: FitDNA.category.coding.code.value,
occultStatus: FitDNA.status
}
// add - PROBLEM - category evaluation was not working - THIS WORKS
define "Fecal Immunochemical Test DNA Performed":
[Observation: "FIT DNA"] FitDNA
where FitDNA.status in { 'final', 'amended', 'corrected' }
and exists ( FitDNA.category FitDNACategory
where FitDNACategory.coding.code.value ~ { 'laboratory' } )
and FitDNA.value is not null
and Global."Latest" ( FitDNA.effective ) 3 years or less on or before
end of "Measurement Period"
// add - PROBLEM - TZoffset issue corrected by use of 'day of' - THIS WORKS
define "Fecal Immunochemical Test DNA Performed, day of TZoffset":
[Observation: "FIT DNA"] FitDNA
where FitDNA.status in { 'final', 'amended', 'corrected' }
and exists ( FitDNA.category FitDNACategory
where FitDNACategory.coding.code.value ~ { 'laboratory' } )
and FitDNA.value is not null
and Global."Latest" ( FitDNA.effective ) 3 years or less on or before
day of end of "Measurement Period"
// add for edge testing of category but ignore status, use day of for TZoffset issue
// consider potential for presence of EHR data as category 'exam', 'procedure', 'survey' ???
define "Fecal Immunochemical Test DNA Performed without appropriate category, ignore status, day of TZoffset":
[Observation: "FIT DNA"] FitDNA
where
// FitDNA.status in { 'final', 'amended', 'corrected' }
// and
exists ( FitDNA.category FitDNACategory
where FitDNACategory.coding.code.value !~ { 'laboratory' } )
and FitDNA.value is not null
and Global."Latest" ( FitDNA.effective ) 3 years or less on or before
day of end of "Measurement Period"
/* add for edge testing of status but ignore category, use day of for TZoffset issue*/
define "Fecal Immunochemical Test DNA Performed without appropriate status, ignore category, day of TZoffset":
[Observation: "FIT DNA"] FitDNA
where not ( FitDNA.status in { 'final', 'amended', 'corrected' } )
// and exists ( FitDNA.category FitDNACategory
// where FitDNACategory.coding.code.value ~ { 'laboratory' } )
and FitDNA.value is not null
and Global."Latest" ( FitDNA.effective ) 3 years or less on or before
day of end of "Measurement Period"
// --- CT Colonography ---
// add definition to Display Date of Colonography as 6 years for edge testing
define "CT Colonography Display Date":
[Observation: "CT Colonography"] Colonography
let ctDate: Global."Latest" ( Colonography.effective )
where Global."Normalize Interval" ( Colonography.effective ) ends 6 years or less on or before
end of "Measurement Period"
return ctDate
define "CT Colonography Performed":
[Observation: "CT Colonography"] Colonography
where Colonography.status in { 'final', 'amended', 'corrected', 'appended' }
and Global."Normalize Interval" ( Colonography.effective ) ends 5 years or less on or before
end of "Measurement Period"
// add for edge testing of status, caution re status
define "CT Colonography Performed without appropriate status":
[Observation: "CT Colonography"] Colonography
where not ( Colonography.status in { 'final', 'amended', 'corrected', 'appended' } )
and Global."Normalize Interval" ( Colonography.effective ) ends 5 years or less on or before
end of "Measurement Period"
// --- Flexible Sigmoidoscopy ---
// add definition to Display Date of sigmoidoscopy as 6 years for edge testing
define "Flexible Sigmoidoscopy Display Date":
[Procedure: "Flexible Sigmoidoscopy"] FlexibleSigmoidoscopy
let sigmoidDate: Global."Latest" ( FlexibleSigmoidoscopy.performed )
where Global."Normalize Interval" ( FlexibleSigmoidoscopy.performed ) ends 6 years or less on or before
end of "Measurement Period"
return sigmoidDate
define "Flexible Sigmoidoscopy Performed":
[Procedure: "Flexible Sigmoidoscopy"] FlexibleSigmoidoscopy
where FlexibleSigmoidoscopy.status = 'completed'
and Global."Normalize Interval" ( FlexibleSigmoidoscopy.performed ) ends 5 years or less on or before
end of "Measurement Period"
// add for edge testing of status, caution re status
define "Flexible Sigmoidoscopy Performed without appropriate status":
[Procedure: "Flexible Sigmoidoscopy"] FlexibleSigmoidoscopy
where not ( FlexibleSigmoidoscopy.status = 'completed' )
and Global."Normalize Interval" ( FlexibleSigmoidoscopy.performed ) ends 5 years or less on or before
end of "Measurement Period"
// --- Colonoscopy ---
// add definition to Display Date of colonoscopy as 11 years for edge testing
define "Colonoscopy Display Date":
[Procedure: "Colonoscopy"] Colonoscopy
let colonoscopyDate: Global."Latest" ( Colonoscopy.performed )
where Global."Normalize Interval" ( Colonoscopy.performed ) ends 11 years or less on or before
end of "Measurement Period"
return colonoscopyDate
define "Colonoscopy Performed":
[Procedure: "Colonoscopy"] Colonoscopy
where Colonoscopy.status = 'completed'
and Global."Normalize Interval" ( Colonoscopy.performed ) ends 10 years or less on or before
end of "Measurement Period"
// add for edge testing of status
define "Colonoscopy Performed without appropriate status":
[Procedure: "Colonoscopy"] Colonoscopy
where not ( Colonoscopy.status = 'completed' )
and Global."Normalize Interval" ( Colonoscopy.performed ) ends 10 years or less on or before
end of "Measurement Period"
define "Numerator":
exists "Colonoscopy Performed"
or exists "Fecal Occult Blood Test Performed"
or exists "Flexible Sigmoidoscopy Performed"
or exists "Fecal Immunochemical Test DNA Performed"
or exists "CT Colonography Performed"
// add Final Numerator Population in IP DENOM not in DENEX
define "Final Numerator Population":
"Numerator"
and "Initial Population"
and "Denominator"
and not "Denominator Exclusions"