cql_qdm_patientapi 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,116 @@
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 communication indicated by the
10
+ Communication QDM category and its corresponding value set must be
11
+ communicated from a patient to a provider.
12
+ ###
13
+ class CQL_QDM.CommunicationFromPatientToProvider 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
+ @_negationRationale = @entry.negationReason
21
+ @_relatedTo = @entry.references
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 {Array}
40
+ ###
41
+ relatedTo: ->
42
+ CQL_QDM.Helpers.relatedTo(@_relatedTo)
43
+
44
+
45
+ ###
46
+ To meet criteria using this datatype, the communication indicated by the
47
+ Communication QDM category and its corresponding value set must be
48
+ communicated from a provider to a patient.
49
+ ###
50
+ class CQL_QDM.CommunicationFromProviderToPatient extends CQL_QDM.QDMDatatype
51
+ ###
52
+ @param {Object} entry - the HDS data criteria object to convert
53
+ ###
54
+ constructor: (@entry) ->
55
+ super @entry
56
+ @_negationRationale = @entry.negationReason
57
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
58
+ @_relatedTo = @entry.references
59
+
60
+ ###
61
+ @returns {Code}
62
+ ###
63
+ negationRationale: ->
64
+ if @_negationRationale?
65
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
66
+ else
67
+ null
68
+
69
+ ###
70
+ @returns {Date}
71
+ ###
72
+ authorDatetime: ->
73
+ @_authorDatetime
74
+
75
+ ###
76
+ @returns {Array}
77
+ ###
78
+ relatedTo: ->
79
+ CQL_QDM.Helpers.relatedTo(@_relatedTo)
80
+
81
+
82
+ ###
83
+ To meet criteria using this datatype, the communication indicated by the
84
+ Communication QDM category and its corresponding value set must be
85
+ communicated from one provider to another.
86
+ ###
87
+ class CQL_QDM.CommunicationFromProviderToProvider extends CQL_QDM.QDMDatatype
88
+ ###
89
+ @param {Object} entry - the HDS data criteria object to convert
90
+ ###
91
+ constructor: (@entry) ->
92
+ super @entry
93
+ @_negationRationale = @entry.negationReason
94
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
95
+ @_relatedTo = @entry.references
96
+
97
+ ###
98
+ @returns {Code}
99
+ ###
100
+ negationRationale: ->
101
+ if @_negationRationale?
102
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
103
+ else
104
+ null
105
+
106
+ ###
107
+ @returns {Date}
108
+ ###
109
+ authorDatetime: ->
110
+ @_authorDatetime
111
+
112
+ ###
113
+ @returns {Array}
114
+ ###
115
+ relatedTo: ->
116
+ CQL_QDM.Helpers.relatedTo(@_relatedTo)
@@ -0,0 +1,44 @@
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
+ Base QDM datatype class; implements various functions that all implemented
10
+ QDM datatypes must support.
11
+ ###
12
+ class CQL_QDM.QDMDatatype
13
+ constructor: (@entry) ->
14
+ @_codes = @entry.codes
15
+
16
+ ###
17
+ Returns any instances of this attribute currently within this namespace.
18
+
19
+ @param {String} attribute - the QDM attribute to access
20
+ @returns {Date|Code|Quantity|String}
21
+ ###
22
+ get: (attribute) ->
23
+ @[attribute]?()
24
+
25
+ ###
26
+ @returns {Array}
27
+ ###
28
+ getCode: ->
29
+ allCodes = []
30
+ for system, codes of @_codes
31
+ for code in codes
32
+ allCodes.push code: code
33
+ allCodes
34
+
35
+ ###
36
+ Returns the QDM Id of this entry. If there is no entry for this instance, return null.
37
+
38
+ @returns {Id}
39
+ ###
40
+ id: ->
41
+ if @entry?._id?
42
+ return new CQL_QDM.Id(@entry._id)
43
+ else
44
+ null
@@ -0,0 +1,163 @@
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 the
9
+ device indicated by the QDM category and its corresponding value set is in use,
10
+ or impacts or alters the treatment, care plan, or encounter (e.g., an
11
+ antithrombotic device has been placed on the patient's legs to prevent
12
+ thromboembolism, or a cardiac pacemaker is in place).
13
+ ###
14
+ class CQL_QDM.DeviceApplied extends CQL_QDM.QDMDatatype
15
+ ###
16
+ @param {Object} entry - the HDS data criteria object to convert
17
+ ###
18
+ constructor: (@entry) ->
19
+ super @entry
20
+ @_anatomicalApproachSite = @entry.anatomical_approach
21
+ @_anatomicalLocationSite = @entry.anatomical_location
22
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
23
+ @_negationRationale = @entry.negationReason
24
+ @_reason = @entry.reason
25
+ @_relevantPeriodLow = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
26
+ if @entry.end_time
27
+ @_relevantPeriodHigh = CQL_QDM.Helpers.convertDateTime(@entry.end_time)
28
+ else
29
+ # No end time; high is set to infinity
30
+ @_relevantPeriodHigh = CQL_QDM.Helpers.infinityDateTime()
31
+
32
+ ###
33
+ @returns {Code}
34
+ ###
35
+ anatomicalApproachSite: ->
36
+ if @_anatomicalApproachSite?
37
+ new cql.Code(@_anatomicalApproachSite.code, @_anatomicalApproachSite.code_system)
38
+ else
39
+ end
40
+
41
+ ###
42
+ @returns {Code}
43
+ ###
44
+ anatomicalLocationSite: ->
45
+ if @_anatomicalLocationSite?
46
+ new cql.Code(@_anatomicalLocationSite.code, @_anatomicalLocationSite.code_system)
47
+ else
48
+ null
49
+
50
+ ###
51
+ Author date time is only present when this data type has been negated.
52
+ @returns {Date}
53
+ ###
54
+ authorDatetime: ->
55
+ @_authorDatetime
56
+
57
+ ###
58
+ @returns {Code}
59
+ ###
60
+ negationRationale: ->
61
+ if @_negationRationale?
62
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
63
+ else
64
+ null
65
+
66
+ ###
67
+ @returns {Code}
68
+ ###
69
+ reason: ->
70
+ if @_reason?
71
+ new cql.Code(@_reason.code, @_reason.code_system)
72
+ else
73
+ null
74
+
75
+ ###
76
+ @returns {Interval<Date>}
77
+ ###
78
+ relevantPeriod: ->
79
+ low = @_relevantPeriodLow
80
+ high = @_relevantPeriodHigh
81
+ if low?
82
+ new cql.Interval(low, high)
83
+ else
84
+ null
85
+
86
+
87
+ ###
88
+ Data elements that meet criteria using this datatype should document an order
89
+ for the device indicated by the QDM category and its corresponding value set.
90
+ ###
91
+ class CQL_QDM.DeviceOrder extends CQL_QDM.QDMDatatype
92
+ ###
93
+ @param {Object} entry - the HDS data criteria object to convert
94
+ ###
95
+ constructor: (@entry) ->
96
+ super @entry
97
+ @_negationRationale = @entry.negationReason
98
+ @_reason = @entry.reason
99
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
100
+
101
+ ###
102
+ @returns {Code}
103
+ ###
104
+ negationRationale: ->
105
+ if @_negationRationale?
106
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
107
+ else
108
+ null
109
+
110
+ ###
111
+ @returns {Code}
112
+ ###
113
+ reason: ->
114
+ if @_reason?
115
+ new cql.Code(@_reason.code, @_reason.code_system)
116
+ else
117
+ null
118
+
119
+ ###
120
+ @returns {Date}
121
+ ###
122
+ authorDatetime: ->
123
+ @_authorDatetime
124
+
125
+
126
+ ###
127
+ Data elements that meet criteria using this datatype should document a
128
+ recommendation to use the device indicated by the QDM category and its
129
+ corresponding value set.
130
+ ###
131
+ class CQL_QDM.DeviceRecommended extends CQL_QDM.QDMDatatype
132
+ ###
133
+ @param {Object} entry - the HDS data criteria object to convert
134
+ ###
135
+ constructor: (@entry) ->
136
+ super @entry
137
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
138
+ @_negationRationale = @entry.negationReason
139
+ @_reason = @entry.reason
140
+
141
+ ###
142
+ @returns {Date}
143
+ ###
144
+ authorDatetime: ->
145
+ @_authorDatetime
146
+
147
+ ###
148
+ @returns {Code}
149
+ ###
150
+ negationRationale: ->
151
+ if @_negationRationale?
152
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
153
+ else
154
+ null
155
+
156
+ ###
157
+ @returns {Code}
158
+ ###
159
+ reason: ->
160
+ if @_reason?
161
+ new cql.Code(@_reason.code, @_reason.code_system)
162
+ else
163
+ null
@@ -0,0 +1,67 @@
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 the
10
+ Condition/Diagnosis/Problem and its corresponding value set. The onset
11
+ datetime corresponds to the implicit start datetime of the datatype and the
12
+ abatement datetime corresponds to the implicit stop datetime of the datatype.
13
+ If the abatement datetime is null, then the diagnosis is considered to still
14
+ be active. When this datatype is used with timing relationships, the criterion
15
+ is looking for an active diagnosis for the time frame indicated by the timing
16
+ relationships.
17
+ ###
18
+ class CQL_QDM.Diagnosis extends CQL_QDM.QDMDatatype
19
+ ###
20
+ @param {Object} entry - the HDS data criteria object to convert
21
+ ###
22
+ constructor: (@entry) ->
23
+ super @entry
24
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
25
+ @_prevalencePeriodLow = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
26
+ if @entry.end_time
27
+ @_prevalencePeriodHigh = CQL_QDM.Helpers.convertDateTime(@entry.end_time)
28
+ else
29
+ # No end time; high is set to infinity
30
+ @_prevalencePeriodHigh = CQL_QDM.Helpers.infinityDateTime()
31
+ @_anatomicalLocationSite = @entry.anatomical_location
32
+ @_severity = @entry.severity
33
+
34
+ ###
35
+ @returns {Code}
36
+ ###
37
+ anatomicalLocationSite: ->
38
+ if @_anatomicalLocationSite?
39
+ new cql.Code(@_anatomicalLocationSite.code, @_anatomicalLocationSite.code_system)
40
+ else
41
+ null
42
+
43
+ ###
44
+ @returns {Interval<Date>}
45
+ ###
46
+ prevalencePeriod: ->
47
+ low = @_prevalencePeriodLow
48
+ high = @_prevalencePeriodHigh
49
+ if low?
50
+ new cql.Interval(low, high)
51
+ else
52
+ null
53
+
54
+ ###
55
+ @returns {Code}
56
+ ###
57
+ severity: ->
58
+ if @_severity?
59
+ new cql.Code(@_severity.code, @_severity.code_system)
60
+ else
61
+ null
62
+
63
+ ###
64
+ @returns {Date}
65
+ ###
66
+ authorDatetime: ->
67
+ @_authorDatetime
@@ -0,0 +1,215 @@
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
+ by a clinician or appropriately licensed care provider to an appropriate
10
+ provider or organization to perform the diagnostic study indicated by the QDM
11
+ category and its corresponding value set. The request may be in the form of a
12
+ consultation or a direct order to the organization that performs the diagnostic
13
+ study. Diagnostic studies are those that are not performed in the clinical
14
+ laboratory. Such studies include but are not limited to imaging studies,
15
+ cardiology studies (electrocardiogram, treadmill stress testing), pulmonary
16
+ function testing, vascular laboratory testing, and others.
17
+ ###
18
+ class CQL_QDM.DiagnosticStudyOrder extends CQL_QDM.QDMDatatype
19
+ ###
20
+ @param {Object} entry - the HDS data criteria object to convert
21
+ ###
22
+ constructor: (@entry) ->
23
+ super @entry
24
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
25
+ @_method = @entry.method
26
+ @_negationRationale = @entry.negationReason
27
+ @_reason = @entry.reason
28
+
29
+ ###
30
+ @returns {Date}
31
+ ###
32
+ authorDatetime: ->
33
+ @_authorDatetime
34
+
35
+ ###
36
+ @returns {Code}
37
+ ###
38
+ method: ->
39
+ if @_method?
40
+ new cql.Code(@_method.code, @_method.code_system)
41
+ else
42
+ null
43
+
44
+ ###
45
+ @returns {Code}
46
+ ###
47
+ negationRationale: ->
48
+ if @_negationRationale?
49
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
50
+ else
51
+ null
52
+
53
+ ###
54
+ @returns {Code}
55
+ ###
56
+ reason: ->
57
+ if @_reason?
58
+ new cql.Code(@_reason.code, @_reason.code_system)
59
+ else
60
+ null
61
+
62
+
63
+ ###
64
+ Data elements that meet criteria using this datatype should document the
65
+ completion of the diagnostic study indicated by the QDM category and its
66
+ corresponding value set.
67
+ ###
68
+ class CQL_QDM.DiagnosticStudyPerformed extends CQL_QDM.QDMDatatype
69
+ ###
70
+ @param {Object} entry - the HDS data criteria object to convert
71
+ ###
72
+ constructor: (@entry) ->
73
+ super @entry
74
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
75
+ @_facilityLocation = @entry.facility
76
+ @_method = @entry.method
77
+ @_negationRationale = @entry.negationReason
78
+ @_reason = @entry.reason
79
+ if @entry.values? && @entry.values.length > 0
80
+ @_result = @entry.values?[0]
81
+ @_resultDatetime = CQL_QDM.Helpers.convertDateTime(@entry.result_date_time)
82
+ @_relevantPeriodLow = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
83
+ if @entry.end_time
84
+ @_relevantPeriodHigh = CQL_QDM.Helpers.convertDateTime(@entry.end_time)
85
+ else
86
+ # No end time; high is set to infinity
87
+ @_relevantPeriodHigh = CQL_QDM.Helpers.infinityDateTime()
88
+ @_status = @entry.status
89
+ @_components = @entry.components
90
+
91
+
92
+ ###
93
+ Author date time is only present when this data type has been negated.
94
+ @returns {Date}
95
+ ###
96
+ authorDatetime: ->
97
+ @_authorDatetime
98
+
99
+ ###
100
+ @returns {FacilityLocation}
101
+ ###
102
+ facilityLocation: ->
103
+ if @_facilityLocation?.values?[0]?
104
+ new CQL_QDM.FacilityLocation(@_facilityLocation.values[0])
105
+ else
106
+ null
107
+
108
+ ###
109
+ @returns {Code}
110
+ ###
111
+ method: ->
112
+ if @_method?
113
+ new cql.Code(@_method.code, @_method.code_system)
114
+ else
115
+ null
116
+
117
+ ###
118
+ @returns {Code}
119
+ ###
120
+ negationRationale: ->
121
+ if @_negationRationale?
122
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
123
+ else
124
+ null
125
+
126
+ ###
127
+ @returns {Code}
128
+ ###
129
+ reason: ->
130
+ if @_reason?
131
+ new cql.Code(@_reason.code, @_reason.code_system)
132
+ else
133
+ null
134
+
135
+ ###
136
+ @returns {Interval<Date>}
137
+ ###
138
+ relevantPeriod: ->
139
+ low = @_relevantPeriodLow
140
+ high = @_relevantPeriodHigh
141
+ if low?
142
+ new cql.Interval(low, high)
143
+ else
144
+ null
145
+
146
+ ###
147
+ The model_info_file also lists Integer, Decimal, and Ratio.
148
+ Decimal and Integer are covered under Quantity with a nil unit.
149
+ Ratio is not yet supported with CQL although it appears in the QDM model.
150
+ @returns {Code|Quantity}
151
+ ###
152
+ result: ->
153
+ CQL_QDM.Helpers.formatResult(@_result)
154
+
155
+ ###
156
+ @returns {Date}
157
+ ###
158
+ resultDatetime: ->
159
+ @_resultDatetime
160
+
161
+ ###
162
+ @returns {Code}
163
+ ###
164
+ status: ->
165
+ if @_status?
166
+ new cql.Code(@_status.code, @_status.code_system)
167
+ else
168
+ null
169
+
170
+ ###
171
+ @returns {Array}
172
+ ###
173
+ components: ->
174
+ CQL_QDM.Helpers.components(@_components)
175
+
176
+
177
+ ###
178
+ Data elements that meet criteria using this datatype should document a
179
+ recommendation for a request by a clinician or appropriately licensed care
180
+ provider to an appropriate provider or organization to perform the diagnostic
181
+ study indicated by the QDM category and its corresponding value set.
182
+ ###
183
+ class CQL_QDM.DiagnosticStudyRecommended extends CQL_QDM.QDMDatatype
184
+ ###
185
+ @param {Object} entry - the HDS data criteria object to convert
186
+ ###
187
+ constructor: (@entry) ->
188
+ super @entry
189
+ @_authorDatetime = CQL_QDM.Helpers.convertDateTime(@entry.start_time)
190
+ @_method = @entry.method
191
+ @_negationRationale = @entry.negationReason
192
+
193
+ ###
194
+ @returns {Date}
195
+ ###
196
+ authorDatetime: ->
197
+ @_authorDatetime
198
+
199
+ ###
200
+ @returns {Code}
201
+ ###
202
+ method: ->
203
+ if @_method?
204
+ new cql.Code(@_method.code, @_method.code_system)
205
+ else
206
+ null
207
+
208
+ ###
209
+ @returns {Code}
210
+ ###
211
+ negationRationale: ->
212
+ if @_negationRationale?
213
+ new cql.Code(@_negationRationale.code, @_negationRationale.code_system)
214
+ else
215
+ null