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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +46 -0
  3. data/.travis.yml +15 -0
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +127 -0
  6. data/LICENSE +201 -0
  7. data/README.md +2 -0
  8. data/README.rdoc +2 -0
  9. data/Rakefile +32 -0
  10. data/app/assets/javascripts/cql_qdm_patientapi/.keep +0 -0
  11. data/app/assets/javascripts/cql_qdm_patientapi.js.coffee +3 -0
  12. data/app/assets/javascripts/cqlpatient.js.coffee +232 -0
  13. data/app/assets/javascripts/datatypes/adverseevent.js.coffee +70 -0
  14. data/app/assets/javascripts/datatypes/allergyintolerance.js.coffee +63 -0
  15. data/app/assets/javascripts/datatypes/assessment.js.coffee +159 -0
  16. data/app/assets/javascripts/datatypes/careexperience.js.coffee +47 -0
  17. data/app/assets/javascripts/datatypes/caregoal.js.coffee +60 -0
  18. data/app/assets/javascripts/datatypes/characteristic_birthdate.js.coffee +28 -0
  19. data/app/assets/javascripts/datatypes/communication.js.coffee +116 -0
  20. data/app/assets/javascripts/datatypes/datatype.js.coffee +44 -0
  21. data/app/assets/javascripts/datatypes/device.js.coffee +163 -0
  22. data/app/assets/javascripts/datatypes/diagnosis.js.coffee +67 -0
  23. data/app/assets/javascripts/datatypes/diagnosticstudy.js.coffee +215 -0
  24. data/app/assets/javascripts/datatypes/encounter.js.coffee +213 -0
  25. data/app/assets/javascripts/datatypes/familyhistory.js.coffee +37 -0
  26. data/app/assets/javascripts/datatypes/immunization.js.coffee +152 -0
  27. data/app/assets/javascripts/datatypes/intervention.js.coffee +164 -0
  28. data/app/assets/javascripts/datatypes/laboratorytest.js.coffee +243 -0
  29. data/app/assets/javascripts/datatypes/medication.js.coffee +486 -0
  30. data/app/assets/javascripts/datatypes/patient_characteristic.js.coffee +23 -0
  31. data/app/assets/javascripts/datatypes/patient_characteristic_expired.js.coffee +38 -0
  32. data/app/assets/javascripts/datatypes/patient_characteristic_payer.js.coffee +33 -0
  33. data/app/assets/javascripts/datatypes/patient_characteristic_sex.js.coffee +23 -0
  34. data/app/assets/javascripts/datatypes/physicalexam.js.coffee +223 -0
  35. data/app/assets/javascripts/datatypes/procedure.js.coffee +296 -0
  36. data/app/assets/javascripts/datatypes/substance.js.coffee +294 -0
  37. data/app/assets/javascripts/datatypes/symptom.js.coffee +49 -0
  38. data/app/assets/javascripts/types/component.js.coffee +71 -0
  39. data/app/assets/javascripts/types/facility.js.coffee +41 -0
  40. data/app/assets/javascripts/types/id.js.coffee +23 -0
  41. data/app/assets/javascripts/utils/helpers.js.coffee +101 -0
  42. data/bin/rails +12 -0
  43. data/coffeelint.json +135 -0
  44. data/cql_qdm_patientapi.gemspec +25 -0
  45. data/lib/cql_qdm_patientapi/engine.rb +6 -0
  46. data/lib/cql_qdm_patientapi/version.rb +3 -0
  47. data/lib/cql_qdm_patientapi.rb +4 -0
  48. data/vendor/assets/javascripts/cql4browsers.js +53992 -0
  49. metadata +133 -0
@@ -0,0 +1,213 @@
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 that an
9
+ order for the encounter indicated by the QDM category and its corresponding
10
+ value set has been recommended.
11
+ ###
12
+ class CQL_QDM.EncounterOrder extends CQL_QDM.QDMDatatype
13
+ ###
14
+ @param {Object} entry - the HDS data criteria object to convert
15
+ ###
16
+ constructor: (@entry) ->
17
+ super @entry
18
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
19
+ @_facilityLocation = @entry.facility
20
+ @_negationRationale = @entry.negationReason
21
+ @_reason = @entry.reason
22
+
23
+ ###
24
+ @returns {Date}
25
+ ###
26
+ authorDatetime: ->
27
+ @_authorDatetime
28
+
29
+ ###
30
+ @returns {FacilityLocation}
31
+ ###
32
+ facilityLocation: ->
33
+ if @_facilityLocation?.values?[0]?
34
+ new CQL_QDM.FacilityLocation(@_facilityLocation.values[0])
35
+ else
36
+ null
37
+
38
+ ###
39
+ @returns {Code}
40
+ ###
41
+ negationRationale: ->
42
+ if @_negationRationale?
43
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
44
+ else
45
+ null
46
+
47
+ ###
48
+ @returns {Code}
49
+ ###
50
+ reason: ->
51
+ if @_reason?
52
+ new cql.Code(@_reason.code, @_reason.code_system)
53
+ else
54
+ null
55
+
56
+
57
+ ###
58
+ Data elements that meet criteria using this datatype should document that the
59
+ encounter indicated by the QDM category and its corresponding value set has
60
+ been completed.
61
+ ###
62
+ class CQL_QDM.EncounterPerformed extends CQL_QDM.QDMDatatype
63
+ ###
64
+ @param {Object} entry - the HDS data criteria object to convert
65
+ ###
66
+ constructor: (@entry) ->
67
+ super @entry
68
+ @_admissionSource = @entry.admission_source
69
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
70
+ @_diagnoses = @entry.diagnosis
71
+ @_dischargeDisposition = @entry.dischargeDisposition
72
+ @_facilityLocations = @entry.facility
73
+ @_negationRationale = @entry.negationReason
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
+ @_principalDiagnosis = @entry.principalDiagnosis
81
+
82
+ ###
83
+ @returns {Code}
84
+ ###
85
+ admissionSource: ->
86
+ if @_admissionSource?
87
+ new cql.Code(@_admissionSource.code, @_admissionSource.code_system)
88
+ else
89
+ null
90
+
91
+ ###
92
+ Author date time is only present when this data type has been negated.
93
+ @returns {Date}
94
+ ###
95
+ authorDatetime: ->
96
+ @_authorDatetime
97
+
98
+ ###
99
+ @returns {Array}
100
+ ###
101
+ diagnoses: ->
102
+ CQL_QDM.Helpers.diagnoses(@_diagnoses, @_principalDiagnosis)
103
+
104
+ ###
105
+ @returns {Code}
106
+ ###
107
+ dischargeDisposition: ->
108
+ if @_dischargeDisposition?
109
+ new cql.Code(@_dischargeDisposition.code, @_dischargeDisposition.code_system)
110
+ else
111
+ null
112
+
113
+ ###
114
+ @returns {Array}
115
+ ###
116
+ facilityLocations: ->
117
+ # For Encounter Performed, there can be multiple Facility Locations
118
+ facilityLocations = []
119
+ if @_facilityLocations?
120
+ for facility in @_facilityLocations.values
121
+ if facility?
122
+ facilityLocations.push new CQL_QDM.FacilityLocation(facility)
123
+ facilityLocations
124
+
125
+ ###
126
+ @returns {Quantity}
127
+ ###
128
+ lengthOfStay: ->
129
+ low = @_relevantPeriodLow
130
+ high = @_relevantPeriodHigh
131
+ if low?
132
+ new cql.Quantity({unit: 'days', value: low.differenceBetween(high, 'day')?.high})
133
+ else
134
+ null
135
+
136
+ ###
137
+ @returns {Code}
138
+ ###
139
+ negationRationale: ->
140
+ if @_negationRationale?
141
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
142
+ else
143
+ null
144
+
145
+ ###
146
+ @returns {Interval<Date>}
147
+ ###
148
+ relevantPeriod: ->
149
+ low = @_relevantPeriodLow
150
+ high = @_relevantPeriodHigh
151
+ if low?
152
+ new cql.Interval(low, high)
153
+ else
154
+ null
155
+
156
+ ###
157
+ @returns {Code}
158
+ ###
159
+ principalDiagnosis: ->
160
+ if @_principalDiagnosis?
161
+ new cql.Code(@_principalDiagnosis.code, @_principalDiagnosis.code_system)
162
+ else
163
+ null
164
+
165
+
166
+ ###
167
+ Data elements that meet criteria using this datatype should document that the
168
+ encounter indicated by the QDM category and its corresponding value set has been
169
+ recommended.
170
+ ###
171
+ class CQL_QDM.EncounterRecommended extends CQL_QDM.QDMDatatype
172
+ ###
173
+ @param {Object} entry - the HDS data criteria object to convert
174
+ ###
175
+ constructor: (@entry) ->
176
+ super @entry
177
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
178
+ @_facilityLocation = @entry.facility
179
+ @_negationRationale = @entry.negationReason
180
+ @_reason = @entry.reason
181
+
182
+ ###
183
+ @returns {Date}
184
+ ###
185
+ authorDatetime: ->
186
+ @_authorDatetime
187
+
188
+ ###
189
+ @returns {FacilityLocation}
190
+ ###
191
+ facilityLocation: ->
192
+ if @_facilityLocation?.values?[0]?
193
+ new CQL_QDM.FacilityLocation(@_facilityLocation.values[0])
194
+ else
195
+ null
196
+
197
+ ###
198
+ @returns {Code}
199
+ ###
200
+ negationRationale: ->
201
+ if @_negationRationale?
202
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
203
+ else
204
+ null
205
+
206
+ ###
207
+ @returns {Code}
208
+ ###
209
+ reason: ->
210
+ if @_reason?
211
+ new cql.Code(@_reason.code, @_reason.code_system)
212
+ else
213
+ null
@@ -0,0 +1,37 @@
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
+ To meet criteria using this datatype, the diagnosis/problem indicated by the
10
+ FamilyHistory QDM category and its corresponding value set should reflect a
11
+ diagnosis/problem of a family member. When used in timing relationships, the
12
+ recorded datetime acts as both the implicit start datetime and implicit stop
13
+ datetime.
14
+ ###
15
+ class CQL_QDM.FamilyHistory extends CQL_QDM.QDMDatatype
16
+ ###
17
+ @param {Object} entry - the HDS data criteria object to convert
18
+ ###
19
+ constructor: (@entry) ->
20
+ super @entry
21
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
22
+ @_relationship = @entry.relationshipToPatient
23
+
24
+ ###
25
+ @returns {Date}
26
+ ###
27
+ authorDatetime: ->
28
+ @_authorDatetime
29
+
30
+ ###
31
+ @returns {Code}
32
+ ###
33
+ relationship: ->
34
+ if @_relationship?
35
+ new cql.Code(@_relationship.code, @_relationship.code_system)
36
+ else
37
+ null
@@ -0,0 +1,152 @@
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
+ vaccine indicated by the QDM category and its corresponding value set was
11
+ actually administered to the patient.
12
+ ###
13
+ class CQL_QDM.ImmunizationAdministered extends CQL_QDM.QDMDatatype
14
+ ###
15
+ @param {Object} entry - the HDS data criteria object to convert
16
+ ###
17
+ constructor: (@entry) ->
18
+ super @entry
19
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
20
+ @_dosage = @entry.dose
21
+ @_negationRationale = @entry.negationReason
22
+ @_reason = @entry.reason
23
+ @_route = @entry.route
24
+ @_supply = @entry.supply
25
+
26
+ ###
27
+ @returns {Date}
28
+ ###
29
+ authorDatetime: ->
30
+ @_authorDatetime
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
+ negationRationale: ->
45
+ if @_negationRationale?
46
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
47
+ else
48
+ null
49
+
50
+ ###
51
+ @returns {Code}
52
+ ###
53
+ reason: ->
54
+ if @_reason?
55
+ new cql.Code(@_reason.code, @_reason.code_system)
56
+ else
57
+ null
58
+
59
+ ###
60
+ @returns {Code}
61
+ ###
62
+ route: ->
63
+ if @_route?
64
+ new cql.Code(@_route.code, @_route.code_system)
65
+ else
66
+ null
67
+
68
+ ###
69
+ @returns {Quantity}
70
+ ###
71
+ supply: ->
72
+ if @_supply?
73
+ new cql.Quantity({unit: @_supply['unit'], value: @_supply['value']})
74
+ else
75
+ null
76
+
77
+
78
+ ###
79
+ Data elements that meet criteria using this datatype should document a request
80
+ for the immunization indicated by the QDM category and its corresponding value
81
+ set.
82
+ ###
83
+ class CQL_QDM.ImmunizationOrder extends CQL_QDM.QDMDatatype
84
+ ###
85
+ @param {Object} entry - the HDS data criteria object to convert
86
+ ###
87
+ constructor: (@entry) ->
88
+ super @entry
89
+ @_activeDatetime = CQL_QDM.Helpers.convertDateTime(@entry.active_datetime)
90
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
91
+ @_dosage = @entry.dose
92
+ @_negationRationale = @entry.negationReason
93
+ @_reason = @entry.reason
94
+ @_route = @entry.route
95
+ @_supply = @entry.supply
96
+
97
+ ###
98
+ @returns {Date}
99
+ ###
100
+ activeDatetime: ->
101
+ @_activeDatetime
102
+
103
+ ###
104
+ @returns {Date}
105
+ ###
106
+ authorDatetime: ->
107
+ @_authorDatetime
108
+
109
+ ###
110
+ @returns {Quantity}
111
+ ###
112
+ dosage: ->
113
+ if @_dosage?
114
+ new cql.Quantity({unit: @_dosage['unit'], value: @_dosage['value']})
115
+ else
116
+ null
117
+
118
+ ###
119
+ @returns {Code}
120
+ ###
121
+ negationRationale: ->
122
+ if @_negationRationale?
123
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
124
+ else
125
+ null
126
+
127
+ ###
128
+ @returns {Code}
129
+ ###
130
+ reason: ->
131
+ if @_reason?
132
+ new cql.Code(@_reason.code, @_reason.code_system)
133
+ else
134
+ null
135
+
136
+ ###
137
+ @returns {Code}
138
+ ###
139
+ route: ->
140
+ if @_route?
141
+ new cql.Code(@_route.code, @_route.code_system)
142
+ else
143
+ null
144
+
145
+ ###
146
+ @returns {Quantity}
147
+ ###
148
+ supply: ->
149
+ if @_supply?
150
+ new cql.Quantity({unit: @_supply['unit'], value: @_supply['value']})
151
+ else
152
+ null
@@ -0,0 +1,164 @@
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 a request
10
+ to perform the intervention indicated by the QDM category and its corresponding
11
+ value set.
12
+ ###
13
+ class CQL_QDM.InterventionOrder extends CQL_QDM.QDMDatatype
14
+ ###
15
+ @param {Object} entry - the HDS data criteria object to convert
16
+ ###
17
+ constructor: (@entry) ->
18
+ super @entry
19
+ @_negationRationale = @entry.negationReason
20
+ @_reason = @entry.reason
21
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
22
+
23
+ ###
24
+ @returns {Date}
25
+ ###
26
+ authorDatetime: ->
27
+ @_authorDatetime
28
+
29
+ ###
30
+ @returns {Code}
31
+ ###
32
+ negationRationale: ->
33
+ if @_negationRationale?
34
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
35
+ else
36
+ null
37
+
38
+ ###
39
+ @returns {Code}
40
+ ###
41
+ reason: ->
42
+ if @_reason?
43
+ new cql.Code(@_reason.code, @_reason.code_system)
44
+ else
45
+ null
46
+
47
+
48
+ ###
49
+ Data elements that meet criteria using this datatype should document the
50
+ completion of the intervention indicated by the QDM category and its
51
+ corresponding value set.
52
+ ###
53
+ class CQL_QDM.InterventionPerformed extends CQL_QDM.QDMDatatype
54
+ ###
55
+ @param {Object} entry - the HDS data criteria object to convert
56
+ ###
57
+ constructor: (@entry) ->
58
+ super @entry
59
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
60
+ @_negationRationale = @entry.negationReason
61
+ @_reason = @entry.reason
62
+ @_relevantPeriodLow = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
63
+ if @entry.end_time
64
+ @_relevantPeriodHigh = CQL_QDM.Helpers.convertDateTime(@entry.end_time)
65
+ else
66
+ # No end time; high is set to infinity
67
+ @_relevantPeriodHigh = CQL_QDM.Helpers.infinityDateTime()
68
+ if @entry.values? && @entry.values.length > 0
69
+ @_result = @entry.values?[0]
70
+ @_status = @entry.status
71
+
72
+ ###
73
+ Author date time is only present when this data type has been negated.
74
+ @returns {Date}
75
+ ###
76
+ authorDatetime: ->
77
+ @_authorDatetime
78
+
79
+ ###
80
+ @returns {Code}
81
+ ###
82
+ negationRationale: ->
83
+ if @_negationRationale?
84
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
85
+ else
86
+ null
87
+
88
+ ###
89
+ @returns {Code}
90
+ ###
91
+ reason: ->
92
+ if @_reason?
93
+ new cql.Code(@_reason.code, @_reason.code_system)
94
+ else
95
+ null
96
+
97
+ ###
98
+ @returns {Interval<Date>}
99
+ ###
100
+ relevantPeriod: ->
101
+ low = @_relevantPeriodLow
102
+ high = @_relevantPeriodHigh
103
+ if low?
104
+ new cql.Interval(low, high)
105
+ else
106
+ null
107
+
108
+ ###
109
+ The model_info_file also lists Integer, Decimal, and Ratio.
110
+ Decimal and Integer are covered under Quantity with a nil unit.
111
+ Ratio is not yet supported with CQL although it appears in the QDM model.
112
+ @returns {Code|Quantity}
113
+ ###
114
+ result: ->
115
+ CQL_QDM.Helpers.formatResult(@_result)
116
+
117
+ ###
118
+ @returns {Code}
119
+ ###
120
+ status: ->
121
+ if @_status?
122
+ new cql.Code(@_status.code, @_status.code_system)
123
+ else
124
+ null
125
+
126
+
127
+ ###
128
+ Data elements that meet criteria using this datatype should document a
129
+ recommendation for the intervention indicated by the QDM category and its
130
+ corresponding value set.
131
+ ###
132
+ class CQL_QDM.InterventionRecommended extends CQL_QDM.QDMDatatype
133
+ ###
134
+ @param {Object} entry - the HDS data criteria object to convert
135
+ ###
136
+ constructor: (@entry) ->
137
+ super @entry
138
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
139
+ @_negationRationale = @entry.negationReason
140
+ @_reason = @entry.reason
141
+
142
+ ###
143
+ @returns {Date}
144
+ ###
145
+ authorDatetime: ->
146
+ @_authorDatetime
147
+
148
+ ###
149
+ @returns {Code}
150
+ ###
151
+ negationRationale: ->
152
+ if @_negationRationale?
153
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
154
+ else
155
+ null
156
+
157
+ ###
158
+ @returns {Code}
159
+ ###
160
+ reason: ->
161
+ if @_reason?
162
+ new cql.Code(@_reason.code, @_reason.code_system)
163
+ else
164
+ null