-
Notifications
You must be signed in to change notification settings - Fork 23
/
50_CMS169.cql
169 lines (143 loc) · 8.17 KB
/
50_CMS169.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
library Test169 version '0.0.040'
// This example is an excerpt of CMS169
// Only the relevant logic is included
using QDM version '5.3'
valueset "BH Antidepressant Medication": 'urn:oid:2.16.840.1.113883.3.1257.1.972'
valueset "BH Assessment for Alcohol or Other Drugs": 'urn:oid:2.16.840.1.113883.3.1257.1.1604'
valueset "BH Condition Involving Bipolar Disorder": 'urn:oid:2.16.840.1.113883.3.1257.1.1504'
valueset "BH Condition Involving Unipolar Depression": 'urn:oid:2.16.840.1.113883.3.1257.1.1505'
valueset "BH Counseling for Depression": 'urn:oid:2.16.840.1.113883.3.1257.1.1616'
valueset "BH Electroconvulsive Therapy": 'urn:oid:2.16.840.1.113883.3.1257.1.1533'
valueset "BH Mood Stabilizer Medication": 'urn:oid:2.16.840.1.113883.3.1257.1.950'
valueset "BH Outpatient encounter": 'urn:oid:2.16.840.1.113883.3.464.1.49'
valueset "BH Outpatient Psychotherapy": 'urn:oid:2.16.840.1.113883.3.1257.1.973'
parameter "Measurement Period" Interval<DateTime>
context Patient
define "Bipolar Disorder Or Unipolar Depression":
["Diagnosis": "BH Condition Involving Bipolar Disorder"]
union ["Diagnosis": "BH Condition Involving Unipolar Depression"]
define "BH Outpatient Encounters":
["Encounter, Performed": "BH Outpatient encounter"]
union ["Encounter, Performed": "BH Outpatient Psychotherapy"]
// Use an expression for "BH Outpatient Encounters"
// It appears throughout the measure and would simplify many of the expressions
define "Diagnoses Start During Encounters":
"Bipolar Disorder Or Unipolar Depression" Diagnoses
with "BH Outpatient Encounters" Encounters
such that Diagnoses.prevalencePeriod starts during Encounters.relevantPeriod
define "Index Behavioral Health Outpatient Encounter":
"BH Outpatient Encounters" Encounter
with "Bipolar Disorder Or Unipolar Depression" Diagnoses
such that Encounter.relevantPeriod overlaps before Diagnoses.prevalencePeriod
where Encounter.relevantPeriod starts during Interval[start of "Measurement Period", start of "Measurement Period" + 323 days]
/*
define "Index Behavioral Health Outpatient Encounter":
["Encounter, Performed": "BH Outpatient encounter"] Encounter
with "Bipolar Disorder Or Unipolar Depression" Diagnoses
such that Encounter.relevantPeriod overlaps before Diagnoses.prevalencePeriod
where Encounter.relevantPeriod starts during Interval[start of "Measurement Period", start of "Measurement Period" + 323 days]
define "Index Behavioral Health Outpatient Psychotherapy":
["Encounter, Performed": "BH Outpatient Psychotherapy"] Encounter
with "Bipolar Disorder Or Unipolar Depression" Diagnoses
such that Encounter.relevantPeriod overlaps before Diagnoses.prevalencePeriod
where Encounter.relevantPeriod starts during Interval[start of "Measurement Period", start of "Measurement Period" + 323 days]
*/
define "Index Outpatient Encounter Before Treatment or Psychotherapy":
(
"Index Behavioral Health Outpatient Encounter" Encounter
with ["Encounter, Performed": "BH Outpatient Psychotherapy"] Psychotherapy
such that Encounter.relevantPeriod starts 42 days or less before start of Psychotherapy.relevantPeriod
)
union ( "Index Behavioral Health Outpatient Encounter" Encounter
with "Treatments" Treatment
such that Encounter.relevantPeriod starts 42 days or less before Treatment.authorDatetime
/*
define "Index Outpatient Encounter Before Treatment or Psychotherapy":
( "Index Behavioral Health Outpatient Encounter" Encounter
with ["Encounter, Performed": "BH Outpatient Psychotherapy"] Psychotherapy
such that Encounter.relevantPeriod starts 42 days or less before start of Psychotherapy.relevantPeriod
)
union ( "Index Behavioral Health Outpatient Encounter" Encounter
with "Treatments" Treatment
such that Encounter.relevantPeriod starts 42 days or less before Treatment.authorDatetime
)
define "Index Behavioral Health Outpatient Psychotherapy Before Treatment or Psychotherapy":
( "Index Behavioral Health Outpatient Psychotherapy" Encounter
with ["Encounter, Performed": "BH Outpatient Psychotherapy"] OutpatientPsychotherapy
such that Encounter.relevantPeriod starts 42 days or less before start of OutpatientPsychotherapy.relevantPeriod
)
union ( "Index Behavioral Health Outpatient Psychotherapy" IndexOutpatientPsychotherapyEncounter
with "Treatments" Treatment
such that IndexOutpatientPsychotherapyEncounter.relevantPeriod starts 42 days or less before Treatment.authorDatetime
)
*/
define "Medications Active":
["Medication, Active": "BH Antidepressant Medication"]
union ["Medication, Active": "BH Mood Stabilizer Medication"]
define "Medication Active Or Diagnoses":
( "Medications Active" MedicationActive
union ( "Bipolar Disorder Or Unipolar Depression" Diagnoses
return "Medication, Active" { relevantPeriod: Diagnoses.prevalencePeriod }
)
)
define "Outpatient Encounter During Diagnosis or Medication Active":
["Encounter, Performed": "BH Outpatient encounter"] OutpatientEncounter
with "Medication Active Or Diagnoses" MedicationDiagnosis
such that OutpatientEncounter.relevantPeriod during MedicationDiagnosis.relevantPeriod
define "Outpatient Psychotherapy During Diagnoses":
["Encounter, Performed": "BH Outpatient Psychotherapy"] OutpatientPsychotherapy
with "Bipolar Disorder Or Unipolar Depression" Diagnoses
such that OutpatientPsychotherapy.relevantPeriod during Diagnoses.prevalencePeriod
define "Outpatient Encounter 180 days after Encounter Diagnosis Treatment":
( "Index Behavioral Health Outpatient Encounter" Encounter
with ( "Outpatient Encounter During Diagnosis or Medication Active"
union "Outpatient Psychotherapy During Diagnoses" ) PriorEncounter
such that Encounter.relevantPeriod starts 180 days or less after start of PriorEncounter.relevantPeriod
)
union ( "Index Behavioral Health Outpatient Encounter" Encounter
with "Diagnoses Start During Encounters" Diagnoses
such that Encounter.relevantPeriod starts 180 days or less after Diagnoses.prevalencePeriod
)
union ( "Index Behavioral Health Outpatient Encounter" Encounter
with "Treatments" Treatment
such that Encounter.relevantPeriod starts 180 days or less after Treatment.authorDatetime
)
define "Outpatient Psychotherapy 180 days after Encounter Diagnosis Treatment":
( "Index Behavioral Health Outpatient Psychotherapy Before Treatment or Psychotherapy" Encounter
with ( "Outpatient Encounter During Diagnosis or Medication Active"
union "Outpatient Psychotherapy During Diagnoses" ) PriorEncounter
such that Encounter.relevantPeriod starts 180 days or less after start of PriorEncounter.relevantPeriod
)
union ( "Index Behavioral Health Outpatient Psychotherapy Before Treatment or Psychotherapy" Encounter
with "Diagnoses Start During Encounters" Diagnoses
such that Encounter.relevantPeriod starts 180 days or less after Diagnoses.prevalencePeriod
)
union ( "Index Behavioral Health Outpatient Psychotherapy Before Treatment or Psychotherapy" Encounter
with "Treatments" Treatment
such that Encounter.relevantPeriod starts 180 days or less after Treatment.authorDatetime
)
define "Qualifying.Encounters":
( "Index Outpatient Encounter Before Treatment or Psychotherapy"
except "Outpatient Encounter 180 days after Encounter Diagnosis Treatment"
)
union ( "Index Behavioral Health Outpatient Psychotherapy Before Treatment or Psychotherapy"
except "Outpatient Psychotherapy 180 days after Encounter Diagnosis Treatment"
)
define "Medications Ordered":
["Medication, Order": "BH Antidepressant Medication"]
union ["Medication, Order": "BH Mood Stabilizer Medication"]
define "Procedures Ordered":
["Procedure, Order": "BH Electroconvulsive Therapy"]
union ["Procedure, Order": "BH Counseling for Depression"]
define "Procedures Performed":
["Procedure, Performed": "BH Electroconvulsive Therapy"]
union ["Procedure, Performed": "BH Counseling for Depression"]
define "Treatments":
( "Procedures Ordered" ProcedureOrdered
union ( "Procedures Performed" ProceduresPerformed
return "Procedure, Order" { authorDatetime: start of ProceduresPerformed.relevantPeriod }
)
union ( "Medications Ordered" MedicationsOrdered
return "Procedure, Order" { authorDatetime: MedicationsOrdered.authorDatetime }
)
)