-
Notifications
You must be signed in to change notification settings - Fork 14
/
TJCOverallFHIR.cql
82 lines (65 loc) · 4.49 KB
/
TJCOverallFHIR.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
library TJCOverallFHIR version '1.1.000'
/*@update: @@BTR 2020-03-31 ->
Incremented version to 5.0.000
Updated FHIR version to 4.0.1
@@*/
using FHIR version '4.0.1'
include FHIRHelpers version '4.0.001' called FHIRHelpers
include MATGlobalCommonFunctionsFHIR4 version '6.0.000' called Global
include SupplementalDataElementsFHIR4 version '2.0.000' called SDE
codesystem "LOINC": 'http://loinc.org'
valueset "Comfort Measures": 'http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45'
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 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 "Emergency Department Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292'
valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
valueset "Hemorrhagic Stroke": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.212'
valueset "Ischemic Stroke": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.247'
valueset "Left Against Medical Advice": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308'
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 "Patient Expired": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309'
valueset "Ticagrelor Therapy": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.39'
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 "Intervention Comfort Measures":
(["ServiceRequest": "Comfort Measures"] P
where P.intent = 'order')
union
(["Procedure": "Comfort Measures"] InterventionPerformed
where InterventionPerformed.status = 'completed')
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 "Ischemic Stroke Encounter":
"Encounter with Principal Diagnosis and Age" EncounterWithAge
where Global.PrincipalDiagnosis(EncounterWithAge).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 "Ischemic Stroke Encounters with Discharge Disposition":
"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"
// Translator issue with 1.4.9-SNAPSHOT: https://github.com/cqframework/clinical_quality_language/issues/511
define "Encounter with Principal Diagnosis and Age":
"All Stroke Encounter" AllStrokeEncounter
with ["Patient"] BirthDate
such that AgeInYearsAt(start of FHIRHelpers.ToInterval(AllStrokeEncounter.period)) >= 18
define "Comfort Measures during Hospitalization":
"Ischemic Stroke Encounter" IschemicStrokeEncounter
with "Intervention Comfort Measures" ComfortMeasure
such that FHIRHelpers.ToDateTime(Coalesce(ComfortMeasure.performed as dateTime,ComfortMeasure.authoredOn)) during Global."HospitalizationWithObservation"(IschemicStrokeEncounter)
/*
Global.ToDate no longer exists and FHIRHelpers.ToDate does not take a System.DateTime
define function "CalendarDayOfOrDayAfter"(StartValue DateTime ):
Interval(FHIRHelpers."ToDate"(StartValue), Global."ToDate"(StartValue + 2 days))
*/