cql_qdm_patientapi 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +46 -0
- data/.travis.yml +15 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +127 -0
- data/LICENSE +201 -0
- data/README.md +2 -0
- data/README.rdoc +2 -0
- data/Rakefile +32 -0
- data/app/assets/javascripts/cql_qdm_patientapi/.keep +0 -0
- data/app/assets/javascripts/cql_qdm_patientapi.js.coffee +3 -0
- data/app/assets/javascripts/cqlpatient.js.coffee +232 -0
- data/app/assets/javascripts/datatypes/adverseevent.js.coffee +70 -0
- data/app/assets/javascripts/datatypes/allergyintolerance.js.coffee +63 -0
- data/app/assets/javascripts/datatypes/assessment.js.coffee +159 -0
- data/app/assets/javascripts/datatypes/careexperience.js.coffee +47 -0
- data/app/assets/javascripts/datatypes/caregoal.js.coffee +60 -0
- data/app/assets/javascripts/datatypes/characteristic_birthdate.js.coffee +28 -0
- data/app/assets/javascripts/datatypes/communication.js.coffee +116 -0
- data/app/assets/javascripts/datatypes/datatype.js.coffee +44 -0
- data/app/assets/javascripts/datatypes/device.js.coffee +163 -0
- data/app/assets/javascripts/datatypes/diagnosis.js.coffee +67 -0
- data/app/assets/javascripts/datatypes/diagnosticstudy.js.coffee +215 -0
- data/app/assets/javascripts/datatypes/encounter.js.coffee +213 -0
- data/app/assets/javascripts/datatypes/familyhistory.js.coffee +37 -0
- data/app/assets/javascripts/datatypes/immunization.js.coffee +152 -0
- data/app/assets/javascripts/datatypes/intervention.js.coffee +164 -0
- data/app/assets/javascripts/datatypes/laboratorytest.js.coffee +243 -0
- data/app/assets/javascripts/datatypes/medication.js.coffee +486 -0
- data/app/assets/javascripts/datatypes/patient_characteristic.js.coffee +23 -0
- data/app/assets/javascripts/datatypes/patient_characteristic_expired.js.coffee +38 -0
- data/app/assets/javascripts/datatypes/patient_characteristic_payer.js.coffee +33 -0
- data/app/assets/javascripts/datatypes/patient_characteristic_sex.js.coffee +23 -0
- data/app/assets/javascripts/datatypes/physicalexam.js.coffee +223 -0
- data/app/assets/javascripts/datatypes/procedure.js.coffee +296 -0
- data/app/assets/javascripts/datatypes/substance.js.coffee +294 -0
- data/app/assets/javascripts/datatypes/symptom.js.coffee +49 -0
- data/app/assets/javascripts/types/component.js.coffee +71 -0
- data/app/assets/javascripts/types/facility.js.coffee +41 -0
- data/app/assets/javascripts/types/id.js.coffee +23 -0
- data/app/assets/javascripts/utils/helpers.js.coffee +101 -0
- data/bin/rails +12 -0
- data/coffeelint.json +135 -0
- data/cql_qdm_patientapi.gemspec +25 -0
- data/lib/cql_qdm_patientapi/engine.rb +6 -0
- data/lib/cql_qdm_patientapi/version.rb +3 -0
- data/lib/cql_qdm_patientapi.rb +4 -0
- data/vendor/assets/javascripts/cql4browsers.js +53992 -0
- metadata +133 -0
@@ -0,0 +1,243 @@
|
|
1
|
+
###
|
2
|
+
@namespace scoping into the CQL_QDM namespace (all classes and
|
3
|
+
their methods will be accessable through the CQL_QDM namespace)
|
4
|
+
###
|
5
|
+
@CQL_QDM ||= {}
|
6
|
+
|
7
|
+
###
|
8
|
+
Data elements that meet criteria using this datatype should document a request
|
9
|
+
for the laboratory test indicated by the QDM category and its corresponding
|
10
|
+
value set.
|
11
|
+
###
|
12
|
+
class CQL_QDM.LaboratoryTestOrder extends CQL_QDM.QDMDatatype
|
13
|
+
###
|
14
|
+
@param {Object} entry - the HDS data criteria object to convert
|
15
|
+
###
|
16
|
+
constructor: (@entry) ->
|
17
|
+
super @entry
|
18
|
+
@_method = @entry.method
|
19
|
+
@_negationRationale = @entry.negationReason
|
20
|
+
@_reason = @entry.reason
|
21
|
+
@_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
22
|
+
|
23
|
+
###
|
24
|
+
@returns {Code}
|
25
|
+
###
|
26
|
+
method: ->
|
27
|
+
if @_method?
|
28
|
+
new cql.Code(@_method.code, @_method.code_system)
|
29
|
+
else
|
30
|
+
null
|
31
|
+
|
32
|
+
###
|
33
|
+
@returns {Code}
|
34
|
+
###
|
35
|
+
negationRationale: ->
|
36
|
+
if @_negationRationale?
|
37
|
+
new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
|
38
|
+
else
|
39
|
+
null
|
40
|
+
|
41
|
+
###
|
42
|
+
@returns {Code}
|
43
|
+
###
|
44
|
+
reason: ->
|
45
|
+
if @_reason?
|
46
|
+
new cql.Code(@_reason.code, @_reason.code_system)
|
47
|
+
else
|
48
|
+
null
|
49
|
+
|
50
|
+
###
|
51
|
+
@returns {Date}
|
52
|
+
###
|
53
|
+
authorDatetime: ->
|
54
|
+
@_authorDatetime
|
55
|
+
|
56
|
+
|
57
|
+
###
|
58
|
+
Data elements that meet criteria using this datatype should document the
|
59
|
+
laboratory test indicated by the QDM category and its corresponding value set
|
60
|
+
was performed.
|
61
|
+
###
|
62
|
+
class CQL_QDM.LaboratoryTestPerformed extends CQL_QDM.QDMDatatype
|
63
|
+
###
|
64
|
+
@param {Object} entry - the HDS data criteria object to convert
|
65
|
+
###
|
66
|
+
constructor: (@entry) ->
|
67
|
+
super @entry
|
68
|
+
@_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
69
|
+
@_method = @entry.method
|
70
|
+
@_negationRationale = @entry.negationReason
|
71
|
+
@_reason = @entry.reason
|
72
|
+
@_referenceRangeLow = @entry.referenceRangeLow
|
73
|
+
@_referenceRangeHigh = @entry.referenceRangeHigh
|
74
|
+
@_relevantPeriodLow = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
75
|
+
if @entry.end_time
|
76
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.convertDateTime(@entry.end_time)
|
77
|
+
else
|
78
|
+
# No end time; high is set to infinity
|
79
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.infinityDateTime()
|
80
|
+
if @entry.values? && @entry.values.length > 0
|
81
|
+
@_result = @entry.values?[0]
|
82
|
+
@_resultDatetime = CQL_QDM.Helpers.convertDateTime(@entry.result_date_time)
|
83
|
+
@_status = @entry.status
|
84
|
+
@_components = @entry.components
|
85
|
+
|
86
|
+
###
|
87
|
+
Author date time is only present when this data type has been negated.
|
88
|
+
@returns {Date}
|
89
|
+
###
|
90
|
+
authorDatetime: ->
|
91
|
+
@_authorDatetime
|
92
|
+
|
93
|
+
###
|
94
|
+
@returns {Code}
|
95
|
+
###
|
96
|
+
method: ->
|
97
|
+
if @_method?
|
98
|
+
new cql.Code(@_method.code, @_method.code_system)
|
99
|
+
else
|
100
|
+
null
|
101
|
+
|
102
|
+
###
|
103
|
+
@returns {Code}
|
104
|
+
###
|
105
|
+
negationRationale: ->
|
106
|
+
if @_negationRationale?
|
107
|
+
new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
|
108
|
+
else
|
109
|
+
null
|
110
|
+
|
111
|
+
###
|
112
|
+
@returns {Code}
|
113
|
+
###
|
114
|
+
reason: ->
|
115
|
+
if @_reason?
|
116
|
+
new cql.Code(@_reason.code, @_reason.code_system)
|
117
|
+
else
|
118
|
+
null
|
119
|
+
|
120
|
+
###
|
121
|
+
@returns {Interval}
|
122
|
+
###
|
123
|
+
referenceRange: ->
|
124
|
+
# According to documentation, this is assumed to be a 'Quantity'
|
125
|
+
high = null
|
126
|
+
low = null
|
127
|
+
if @_referenceRangeHigh?['unit']?
|
128
|
+
high_obj =
|
129
|
+
unit:
|
130
|
+
@_referenceRangeHigh['unit']
|
131
|
+
value:
|
132
|
+
@_referenceRangeHigh['value']
|
133
|
+
high = new cql.Quantity(high_obj)
|
134
|
+
if @_referenceRangeLow?['unit']?
|
135
|
+
low_obj =
|
136
|
+
unit:
|
137
|
+
@_referenceRangeLow['unit']
|
138
|
+
value:
|
139
|
+
@_referenceRangeLow['value']
|
140
|
+
low = new cql.Quantity(low_obj)
|
141
|
+
if low?
|
142
|
+
new cql.Interval(low, high)
|
143
|
+
else
|
144
|
+
null
|
145
|
+
|
146
|
+
###
|
147
|
+
@returns {Interval<Date>}
|
148
|
+
###
|
149
|
+
relevantPeriod: ->
|
150
|
+
low = @_relevantPeriodLow
|
151
|
+
high = @_relevantPeriodHigh
|
152
|
+
if low?
|
153
|
+
new cql.Interval(low, high)
|
154
|
+
else
|
155
|
+
null
|
156
|
+
|
157
|
+
###
|
158
|
+
The model_info_file also lists Integer, Decimal, and Ratio.
|
159
|
+
Decimal and Integer are covered under Quantity with a nil unit.
|
160
|
+
Ratio is not yet supported with CQL although it appears in the QDM model.
|
161
|
+
@returns {Code|Quantity}
|
162
|
+
###
|
163
|
+
result: ->
|
164
|
+
CQL_QDM.Helpers.formatResult(@_result)
|
165
|
+
|
166
|
+
###
|
167
|
+
@returns {Date}
|
168
|
+
###
|
169
|
+
resultDatetime: ->
|
170
|
+
@_resultDatetime
|
171
|
+
|
172
|
+
###
|
173
|
+
@returns {Code}
|
174
|
+
###
|
175
|
+
status: ->
|
176
|
+
if @_status?
|
177
|
+
new cql.Code(@_status.code, @_status.code_system)
|
178
|
+
else
|
179
|
+
null
|
180
|
+
|
181
|
+
###
|
182
|
+
@returns {Array}
|
183
|
+
###
|
184
|
+
components: ->
|
185
|
+
# Note, this components differs from the one defined in the helpers
|
186
|
+
# in that it has a reference range.
|
187
|
+
components = []
|
188
|
+
if @_components
|
189
|
+
for value in @_components.values
|
190
|
+
if value?
|
191
|
+
# Lab test performed uses ResultComponent, which has a range
|
192
|
+
components.push new CQL_QDM.ResultComponent(value)
|
193
|
+
components
|
194
|
+
|
195
|
+
|
196
|
+
###
|
197
|
+
Data elements that meet criteria using this datatype should document a
|
198
|
+
recommendation for the laboratory test indicated by the QDM category and its
|
199
|
+
corresponding value set.
|
200
|
+
###
|
201
|
+
class CQL_QDM.LaboratoryTestRecommended extends CQL_QDM.QDMDatatype
|
202
|
+
###
|
203
|
+
@param {Object} entry - the HDS data criteria object to convert
|
204
|
+
###
|
205
|
+
constructor: (@entry) ->
|
206
|
+
super @entry
|
207
|
+
@_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
208
|
+
@_method = @entry.method
|
209
|
+
@_negationRationale = @entry.negationReason
|
210
|
+
@_reason = @entry.reason
|
211
|
+
|
212
|
+
###
|
213
|
+
@returns {Date}
|
214
|
+
###
|
215
|
+
authorDatetime: ->
|
216
|
+
@_authorDatetime
|
217
|
+
|
218
|
+
###
|
219
|
+
@returns {Code}
|
220
|
+
###
|
221
|
+
method: ->
|
222
|
+
if @_method?
|
223
|
+
new cql.Code(@_method.code, @_method.code_system)
|
224
|
+
else
|
225
|
+
null
|
226
|
+
|
227
|
+
###
|
228
|
+
@returns {Code}
|
229
|
+
###
|
230
|
+
negationRationale: ->
|
231
|
+
if @_negationRationale?
|
232
|
+
new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
|
233
|
+
else
|
234
|
+
null
|
235
|
+
|
236
|
+
###
|
237
|
+
@returns {Code}
|
238
|
+
###
|
239
|
+
reason: ->
|
240
|
+
if @_reason?
|
241
|
+
new cql.Code(@_reason.code, @_reason.code_system)
|
242
|
+
else
|
243
|
+
null
|
@@ -0,0 +1,486 @@
|
|
1
|
+
###
|
2
|
+
@namespace scoping into the CQL_QDM namespace (all classes and
|
3
|
+
their methods will be accessable through the CQL_QDM namespace)
|
4
|
+
###
|
5
|
+
@CQL_QDM ||= {}
|
6
|
+
|
7
|
+
|
8
|
+
###
|
9
|
+
Data elements that meet criteria using this datatype should document that the
|
10
|
+
medication indicated by the QDM category and its corresponding value set is
|
11
|
+
being taken by the patient. Keep in mind that when this datatype is used with
|
12
|
+
timing relationships, the criterion is looking for a medication being taken for
|
13
|
+
the time frame indicated by the timing relationships.
|
14
|
+
###
|
15
|
+
class CQL_QDM.MedicationActive extends CQL_QDM.QDMDatatype
|
16
|
+
###
|
17
|
+
@param {Object} entry - the HDS data criteria object to convert
|
18
|
+
###
|
19
|
+
constructor: (@entry) ->
|
20
|
+
super @entry
|
21
|
+
@_dosage = @entry.dose
|
22
|
+
@_frequency = @entry.frequency
|
23
|
+
@_route = @entry.route
|
24
|
+
@_relevantPeriodLow = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
25
|
+
if @entry.end_time
|
26
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.convertDateTime(@entry.end_time)
|
27
|
+
else
|
28
|
+
# No end time; high is set to infinity
|
29
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.infinityDateTime()
|
30
|
+
@_supply = @entry.supply
|
31
|
+
|
32
|
+
###
|
33
|
+
@returns {Quantity}
|
34
|
+
###
|
35
|
+
dosage: ->
|
36
|
+
if @_dosage?
|
37
|
+
new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['value']})
|
38
|
+
else
|
39
|
+
null
|
40
|
+
|
41
|
+
###
|
42
|
+
@returns {Code}
|
43
|
+
###
|
44
|
+
frequency: ->
|
45
|
+
# TODO: Frequency currently not in HDS model. Can probably add by calculating based off of dose & regimen
|
46
|
+
throw new Error('Bonnie does not currently support MedicationActive.frequency')
|
47
|
+
if @_frequency?
|
48
|
+
new cql.Code(@_frequency.code, @_frequency.code_system)
|
49
|
+
else
|
50
|
+
null
|
51
|
+
|
52
|
+
###
|
53
|
+
@returns {Code}
|
54
|
+
###
|
55
|
+
route: ->
|
56
|
+
if @_route?
|
57
|
+
new cql.Code(@_route.code, @_route.code_system)
|
58
|
+
else
|
59
|
+
null
|
60
|
+
|
61
|
+
###
|
62
|
+
@returns {Interval<Date>}
|
63
|
+
###
|
64
|
+
relevantPeriod: ->
|
65
|
+
low = @_relevantPeriodLow
|
66
|
+
high = @_relevantPeriodHigh
|
67
|
+
if low?
|
68
|
+
new cql.Interval(low, high)
|
69
|
+
else
|
70
|
+
null
|
71
|
+
|
72
|
+
###
|
73
|
+
@returns {Quantity}
|
74
|
+
###
|
75
|
+
supply: ->
|
76
|
+
if @_supply?
|
77
|
+
new cql.Quantity({unit: @_supply['unit'], value: @_supply['value']})
|
78
|
+
else
|
79
|
+
null
|
80
|
+
|
81
|
+
|
82
|
+
###
|
83
|
+
Data elements that meet criteria using this datatype should document that the
|
84
|
+
medication indicated by the QDM category and its corresponding value set was
|
85
|
+
actually administered to the patient.
|
86
|
+
###
|
87
|
+
class CQL_QDM.MedicationAdministered extends CQL_QDM.QDMDatatype
|
88
|
+
###
|
89
|
+
@param {Object} entry - the HDS data criteria object to convert
|
90
|
+
###
|
91
|
+
constructor: (@entry) ->
|
92
|
+
super @entry
|
93
|
+
@_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
94
|
+
@_dosage = @entry.dose
|
95
|
+
@_frequency = @entry.frequency
|
96
|
+
@_negationRationale = @entry.negationReason
|
97
|
+
@_reason = @entry.reason
|
98
|
+
@_relevantPeriodLow = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
99
|
+
if @entry.end_time
|
100
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.convertDateTime(@entry.end_time)
|
101
|
+
else
|
102
|
+
# No end time; high is set to infinity
|
103
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.infinityDateTime()
|
104
|
+
@_route = @entry.route
|
105
|
+
@_supply = @entry.supply
|
106
|
+
|
107
|
+
###
|
108
|
+
Author date time is only present when this data type has been negated.
|
109
|
+
@returns {Date}
|
110
|
+
###
|
111
|
+
authorDatetime: ->
|
112
|
+
@_authorDatetime
|
113
|
+
|
114
|
+
###
|
115
|
+
@returns {Quantity}
|
116
|
+
###
|
117
|
+
dosage: ->
|
118
|
+
if @_dosage?
|
119
|
+
new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['value']})
|
120
|
+
else
|
121
|
+
null
|
122
|
+
|
123
|
+
###
|
124
|
+
@returns {code}
|
125
|
+
###
|
126
|
+
frequency: ->
|
127
|
+
# TODO: Frequency currently not in HDS model. Can probably add by calculating based off of dose & regimen
|
128
|
+
throw new Error('Bonnie does not currently support MedicationAdministered.frequency')
|
129
|
+
if @_frequency?
|
130
|
+
new cql.Code(@_frequency.code, @_frequency.code_system)
|
131
|
+
else
|
132
|
+
null
|
133
|
+
|
134
|
+
###
|
135
|
+
@returns {Code}
|
136
|
+
###
|
137
|
+
negationRationale: ->
|
138
|
+
if @_negationRationale?
|
139
|
+
new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
|
140
|
+
else
|
141
|
+
null
|
142
|
+
|
143
|
+
###
|
144
|
+
@returns {Code}
|
145
|
+
###
|
146
|
+
reason: ->
|
147
|
+
if @_reason?
|
148
|
+
new cql.Code(@_reason.code, @_reason.code_system)
|
149
|
+
else
|
150
|
+
null
|
151
|
+
|
152
|
+
###
|
153
|
+
@returns {Interval<Date>}
|
154
|
+
###
|
155
|
+
relevantPeriod: ->
|
156
|
+
low = @_relevantPeriodLow
|
157
|
+
high = @_relevantPeriodHigh
|
158
|
+
if low?
|
159
|
+
new cql.Interval(low, high)
|
160
|
+
else
|
161
|
+
null
|
162
|
+
|
163
|
+
###
|
164
|
+
@returns {Code}
|
165
|
+
###
|
166
|
+
route: ->
|
167
|
+
if @_route?
|
168
|
+
new cql.Code(@_route.code, @_route.code_system)
|
169
|
+
else
|
170
|
+
null
|
171
|
+
|
172
|
+
###
|
173
|
+
@returns {Quantity}
|
174
|
+
###
|
175
|
+
supply: ->
|
176
|
+
if @_supply?
|
177
|
+
new cql.Quantity({unit: @_supply['unit'], value: @_supply['value']})
|
178
|
+
else
|
179
|
+
null
|
180
|
+
|
181
|
+
|
182
|
+
###
|
183
|
+
Data elements that meet criteria using this datatype should document that the
|
184
|
+
medications indicated by the QDM category and its corresponding value set
|
185
|
+
should be taken by or given to the patient after being discharged from
|
186
|
+
an inpatient encounter.
|
187
|
+
###
|
188
|
+
class CQL_QDM.MedicationDischarge extends CQL_QDM.QDMDatatype
|
189
|
+
###
|
190
|
+
@param {Object} entry - the HDS data criteria object to convert
|
191
|
+
###
|
192
|
+
constructor: (@entry) ->
|
193
|
+
super @entry
|
194
|
+
@_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
195
|
+
@_dosage = @entry.dose
|
196
|
+
@_frequency = @entry.frequency
|
197
|
+
@_negationRationale = @entry.negationReason
|
198
|
+
@_refills = @entry.refills
|
199
|
+
@_route = @entry.route
|
200
|
+
@_supply = @entry.supply
|
201
|
+
|
202
|
+
###
|
203
|
+
@returns {Date}
|
204
|
+
###
|
205
|
+
authorDatetime: ->
|
206
|
+
@_authorDatetime
|
207
|
+
|
208
|
+
###
|
209
|
+
@returns {Quantity}
|
210
|
+
###
|
211
|
+
dosage: ->
|
212
|
+
if @_dosage?
|
213
|
+
new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['value']})
|
214
|
+
else
|
215
|
+
null
|
216
|
+
|
217
|
+
###
|
218
|
+
@returns {Code}
|
219
|
+
###
|
220
|
+
frequency: ->
|
221
|
+
# TODO: Frequency currently not in HDS model. Can probably add by calculating based off of dose & regimen
|
222
|
+
throw new Error('Bonnie does not currently support MedicationDischarge.frequency')
|
223
|
+
if @_frequency?
|
224
|
+
new cql.Code(@_frequency.code, @_frequency.code_system)
|
225
|
+
else
|
226
|
+
null
|
227
|
+
|
228
|
+
###
|
229
|
+
@returns {Code}
|
230
|
+
###
|
231
|
+
negationRationale: ->
|
232
|
+
if @_negationRationale?
|
233
|
+
new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
|
234
|
+
else
|
235
|
+
null
|
236
|
+
|
237
|
+
###
|
238
|
+
@returns {Integer}
|
239
|
+
###
|
240
|
+
refills: ->
|
241
|
+
# TODO: Refills should represent 'The number of refills allowed by the prescription.'
|
242
|
+
throw new Error('Bonnie does not currently support MedicationDischarge.refills')
|
243
|
+
|
244
|
+
###
|
245
|
+
@returns {Code}
|
246
|
+
###
|
247
|
+
route: ->
|
248
|
+
if @_route?
|
249
|
+
new cql.Code(@_route.code, @_route.code_system)
|
250
|
+
else
|
251
|
+
null
|
252
|
+
|
253
|
+
###
|
254
|
+
@returns {Quantity}
|
255
|
+
###
|
256
|
+
supply: ->
|
257
|
+
if @_supply?
|
258
|
+
new cql.Quantity({unit: @_supply['unit'], value: @_supply['value']})
|
259
|
+
else
|
260
|
+
null
|
261
|
+
|
262
|
+
|
263
|
+
###
|
264
|
+
Data elements that meet criteria using this datatype should document that a
|
265
|
+
prescription for the medication indicated by the QDM category and its
|
266
|
+
corresponding value set has been dispensed and provided to the patient or
|
267
|
+
patient proxy. In the ambulatory setting, medications are primarily taken
|
268
|
+
directly by patients and not directly observed. Hence, dispensed is the closest
|
269
|
+
health provider documentation of medication compliance. In settings where
|
270
|
+
patients attest to taking medications in electronic format (perhaps a Personal
|
271
|
+
Health Record), patient attestation of “medication taken” may be available.
|
272
|
+
###
|
273
|
+
class CQL_QDM.MedicationDispensed extends CQL_QDM.QDMDatatype
|
274
|
+
###
|
275
|
+
@param {Object} entry - the HDS data criteria object to convert
|
276
|
+
###
|
277
|
+
constructor: (@entry) ->
|
278
|
+
super @entry
|
279
|
+
@_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
280
|
+
@_dosage = @entry.dose
|
281
|
+
@_frequency = @entry.frequency
|
282
|
+
@_negationRationale = @entry.negationReason
|
283
|
+
@_refills = @entry.refills
|
284
|
+
@_route = @entry.route
|
285
|
+
@_supply = @entry.supply
|
286
|
+
@_relevantPeriodLow = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
287
|
+
if @entry.end_time
|
288
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.convertDateTime(@entry.end_time)
|
289
|
+
else
|
290
|
+
# No end time; high is set to infinity
|
291
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.infinityDateTime()
|
292
|
+
|
293
|
+
###
|
294
|
+
@returns {Date}
|
295
|
+
###
|
296
|
+
authorDatetime: ->
|
297
|
+
@_authorDatetime
|
298
|
+
|
299
|
+
###
|
300
|
+
@returns {Quantity}
|
301
|
+
###
|
302
|
+
dosage: ->
|
303
|
+
if @_dosage?
|
304
|
+
new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['value']})
|
305
|
+
else
|
306
|
+
null
|
307
|
+
|
308
|
+
###
|
309
|
+
@returns {Code}
|
310
|
+
###
|
311
|
+
frequency: ->
|
312
|
+
# TODO: Frequency currently not in HDS model. Can probably add by calculating based off of dose & regimen
|
313
|
+
throw new Error('Bonnie does not currently support MedicationDispensed.frequency')
|
314
|
+
if @_frequency?
|
315
|
+
new cql.Code(@_frequency.code, @_frequency.code_system)
|
316
|
+
else
|
317
|
+
null
|
318
|
+
|
319
|
+
###
|
320
|
+
@returns {Code}
|
321
|
+
###
|
322
|
+
negationRationale: ->
|
323
|
+
if @_negationRationale?
|
324
|
+
new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
|
325
|
+
else
|
326
|
+
null
|
327
|
+
|
328
|
+
###
|
329
|
+
@returns {Interval<Date>}
|
330
|
+
###
|
331
|
+
relevantPeriod: ->
|
332
|
+
low = @_relevantPeriodLow
|
333
|
+
high = @_relevantPeriodHigh
|
334
|
+
if low?
|
335
|
+
new cql.Interval(low, high)
|
336
|
+
else
|
337
|
+
null
|
338
|
+
|
339
|
+
###
|
340
|
+
@returns {Integer}
|
341
|
+
###
|
342
|
+
refills: ->
|
343
|
+
# TODO: Refills should represent 'The number of refills allowed by the prescription.'
|
344
|
+
throw new Error('Bonnie does not currently support MedicationDispensed.refills')
|
345
|
+
|
346
|
+
###
|
347
|
+
@returns {Code}
|
348
|
+
###
|
349
|
+
route: ->
|
350
|
+
if @_route?
|
351
|
+
new cql.Code(@_route.code, @_route.code_system)
|
352
|
+
else
|
353
|
+
null
|
354
|
+
|
355
|
+
###
|
356
|
+
@returns {Quantity}
|
357
|
+
###
|
358
|
+
supply: ->
|
359
|
+
if @_supply?
|
360
|
+
new cql.Quantity({unit: @_supply['unit'], value: @_supply['value']})
|
361
|
+
else
|
362
|
+
null
|
363
|
+
|
364
|
+
|
365
|
+
###
|
366
|
+
Data elements that meet criteria using this datatype should document a request
|
367
|
+
to a pharmacy to provide the medication indicated by the QDM category and its
|
368
|
+
corresponding value set.
|
369
|
+
###
|
370
|
+
class CQL_QDM.MedicationOrder extends CQL_QDM.QDMDatatype
|
371
|
+
###
|
372
|
+
@param {Object} entry - the HDS data criteria object to convert
|
373
|
+
###
|
374
|
+
constructor: (@entry) ->
|
375
|
+
super @entry
|
376
|
+
@_activeDatetime = CQL_QDM.Helpers.convertDateTime(@entry.active_datetime)
|
377
|
+
@_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
378
|
+
@_dosage = @entry.dose
|
379
|
+
@_frequency = @entry.frequency
|
380
|
+
@_method = @entry.method
|
381
|
+
@_negationRationale = @entry.negationReason
|
382
|
+
@_reason = @entry.reason
|
383
|
+
@_refills = @entry.refills
|
384
|
+
@_route = @entry.route
|
385
|
+
@_supply = @entry.supply
|
386
|
+
@_relevantPeriodLow = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
|
387
|
+
if @entry.end_time
|
388
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.convertDateTime(@entry.end_time)
|
389
|
+
else
|
390
|
+
# No end time; high is set to infinity
|
391
|
+
@_relevantPeriodHigh = CQL_QDM.Helpers.infinityDateTime()
|
392
|
+
|
393
|
+
###
|
394
|
+
@returns {Date}
|
395
|
+
###
|
396
|
+
activeDatetime: ->
|
397
|
+
@_activeDatetime
|
398
|
+
|
399
|
+
###
|
400
|
+
@returns {Date}
|
401
|
+
###
|
402
|
+
authorDatetime: ->
|
403
|
+
@_authorDatetime
|
404
|
+
|
405
|
+
###
|
406
|
+
@returns {Quantity}
|
407
|
+
###
|
408
|
+
dosage: ->
|
409
|
+
if @_dosage?
|
410
|
+
new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['value']})
|
411
|
+
else
|
412
|
+
null
|
413
|
+
|
414
|
+
###
|
415
|
+
@returns {Code}
|
416
|
+
###
|
417
|
+
frequency: ->
|
418
|
+
# TODO: Frequency currently not in HDS model. Can probably add by calculating based off of dose & regimen
|
419
|
+
throw new Error('Bonnie does not currently support MedicationOrder.frequency')
|
420
|
+
if @_frequency?
|
421
|
+
new cql.Code(@_frequency.code, @_frequency.code_system)
|
422
|
+
else
|
423
|
+
null
|
424
|
+
|
425
|
+
###
|
426
|
+
@returns {Code}
|
427
|
+
###
|
428
|
+
method: ->
|
429
|
+
if @_method?
|
430
|
+
new cql.Code(@_method.code, @_method.code_system)
|
431
|
+
else
|
432
|
+
null
|
433
|
+
|
434
|
+
###
|
435
|
+
@returns {Code}
|
436
|
+
###
|
437
|
+
negationRationale: ->
|
438
|
+
if @_negationRationale?
|
439
|
+
new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
|
440
|
+
else
|
441
|
+
null
|
442
|
+
|
443
|
+
###
|
444
|
+
@returns {Code}
|
445
|
+
###
|
446
|
+
reason: ->
|
447
|
+
if @_reason?
|
448
|
+
new cql.Code(@_reason.code, @_reason.code_system)
|
449
|
+
else
|
450
|
+
null
|
451
|
+
|
452
|
+
###
|
453
|
+
@returns {Integer}
|
454
|
+
###
|
455
|
+
refills: ->
|
456
|
+
# TODO: Refills should represent 'The number of refills allowed by the prescription.'
|
457
|
+
throw new Error('Bonnie does not currently support MedicationOrder.refills')
|
458
|
+
|
459
|
+
###
|
460
|
+
@returns {Interval<Date>}
|
461
|
+
###
|
462
|
+
relevantPeriod: ->
|
463
|
+
low = @_relevantPeriodLow
|
464
|
+
high = @_relevantPeriodHigh
|
465
|
+
if low?
|
466
|
+
new cql.Interval(low, high)
|
467
|
+
else
|
468
|
+
null
|
469
|
+
|
470
|
+
###
|
471
|
+
@returns {Code}
|
472
|
+
###
|
473
|
+
route: ->
|
474
|
+
if @_route?
|
475
|
+
new cql.Code(@_route.code, @_route.code_system)
|
476
|
+
else
|
477
|
+
null
|
478
|
+
|
479
|
+
###
|
480
|
+
@returns {Quantity}
|
481
|
+
###
|
482
|
+
supply: ->
|
483
|
+
if @_supply?
|
484
|
+
new cql.Quantity({unit: @_supply['unit'], value: @_supply['value']})
|
485
|
+
else
|
486
|
+
null
|