hquery-patient-api 1.0.4 → 1.1.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.
@@ -5,7 +5,7 @@ this.hQuery ||= {}
5
5
 
6
6
 
7
7
  # =require core.coffee
8
-
8
+
9
9
  ###*
10
10
  An Encounter is an interaction, regardless of the setting, between a patient and a
11
11
  practitioner who is vested with primary responsibility for diagnosing, evaluating,
@@ -16,7 +16,7 @@ patient at a given contact, exercising independent judgment.
16
16
  @class An Encounter is an interaction, regardless of the setting, between a patient and a
17
17
  practitioner
18
18
  @augments hQuery.CodedEntry
19
- @exports Encounter as hQuery.Encounter
19
+ @exports Encounter as hQuery.Encounter
20
20
  ###
21
21
  class hQuery.Encounter extends hQuery.CodedEntry
22
22
  constructor: (@json) ->
@@ -24,19 +24,19 @@ class hQuery.Encounter extends hQuery.CodedEntry
24
24
  @_admitTime = hQuery.dateFromUtcSeconds @json['admitTime'] if @json['admitTime']
25
25
  @_dischargeTime = hQuery.dateFromUtcSeconds @json['dischargeTime'] if @json['dischargeTime']
26
26
  @_facility = new hQuery.Facility @json['facility'] if @json['facility']
27
-
27
+
28
28
  ###*
29
29
  @returns {String}
30
30
  ####
31
31
  dischargeDisposition: -> @json['dischargeDisposition']
32
-
32
+
33
33
  ###*
34
34
  A code indicating the priority of the admission (e.g., Emergency, Urgent, Elective, et cetera) from
35
35
  National Uniform Billing Committee (NUBC)
36
36
  @returns {CodedValue}
37
37
  ###
38
38
  admitType: -> hQuery.createCodedValue @json['admitType']
39
-
39
+
40
40
  ###*
41
41
  Date and time at which the patient was admitted for the encounter
42
42
  @returns {Date}
@@ -48,12 +48,12 @@ class hQuery.Encounter extends hQuery.CodedEntry
48
48
  @returns {Date}
49
49
  ###
50
50
  dischargeTime: -> @_dischargeTime
51
-
51
+
52
52
  ###*
53
53
  @returns {hQuery.Actor}
54
54
  ###
55
55
  performer: -> new hQuery.Actor @json['performer'] if @json['performer']
56
-
56
+
57
57
  ###*
58
58
  @returns {hQuery.Organization}
59
59
  ###
@@ -65,7 +65,7 @@ class hQuery.Encounter extends hQuery.CodedEntry
65
65
  @returns {hQuery.CodedEntry}
66
66
  ###
67
67
  reasonForVisit: -> new hQuery.CodedEntry @json['reason'] if @json['reason']
68
-
68
+
69
69
  ###*
70
70
  @returns {Integer}
71
71
  ###
@@ -73,13 +73,41 @@ class hQuery.Encounter extends hQuery.CodedEntry
73
73
  return 0 unless @startDate()? && @endDate()?
74
74
  Math.floor((@endDate() - @startDate()) / (1000 * 60 * 60 * 24))
75
75
 
76
+ ###*
77
+ @returns {CodedValue}
78
+ ###
79
+ method: -> new hQuery.createCodedValue @json['method']
76
80
 
81
+ ###*
82
+ @returns {CodedValue}
83
+ ###
84
+ reaction: -> new hQuery.createCodedValue @json['reaction']
77
85
  ###*
78
86
  @returns {CodedValue}
79
87
  ###
80
88
  transferTo: -> hQuery.createCodedValue @json['transferTo']
81
-
89
+
82
90
  ###*
83
91
  @returns {CodedValue}
84
92
  ###
85
93
  transferFrom: -> hQuery.createCodedValue @json['transferFrom']
94
+
95
+ ###*
96
+ @returns {CodedValue|CodedValue[]}
97
+ ###
98
+ diagnosis: ->
99
+ if @json['diagnosis']?['codes']
100
+ # Support for diagnosis with multiple codes
101
+ hQuery.createCodedValues @json['diagnosis']['codes']
102
+ else
103
+ hQuery.createCodedValue @json['diagnosis']
104
+
105
+ ###*
106
+ @returns {CodedValue|CodedValue[]}
107
+ ###
108
+ principalDiagnosis: ->
109
+ if @json['principalDiagnosis']?['codes']
110
+ # Support for principal diagnosis with multiple codes
111
+ hQuery.createCodedValues @json['principalDiagnosis']['codes']
112
+ else
113
+ hQuery.createCodedValue @json['principalDiagnosis']
@@ -0,0 +1,26 @@
1
+ ###*
2
+ @namespace scoping into the hquery namespace
3
+ ###
4
+ this.hQuery ||= {}
5
+
6
+
7
+ # =require core.coffee
8
+ ###*
9
+ This represents all family history.
10
+ @class
11
+ @augments hQuery.CodedEntry
12
+ @exports FamilyHistory as hQuery.FamilyHistory
13
+ ###
14
+ class hQuery.FamilyHistory extends hQuery.CodedEntry
15
+ constructor: (@json) ->
16
+ super(@json)
17
+
18
+ ###*
19
+ @returns {CodedValue}
20
+ ###
21
+ relationshipToPatient: -> hQuery.createCodedValue @json['relationshipToPatient']
22
+
23
+ ###*
24
+ @returns {CodedValue}
25
+ ###
26
+ onsetAge: -> new hQuery.Scalar @json['onsetAge']
@@ -5,7 +5,7 @@ this.hQuery ||= {}
5
5
 
6
6
  # =require core.coffee
7
7
  ###*
8
- This class can be used to represnt a functional status for a patient. Currently,
8
+ This class can be used to represent a functional status for a patient. Currently,
9
9
  it is not a very close representation of functional status as it is represented
10
10
  in the HL7 CCD, HITSP C32 or Consolidated CDA.
11
11
 
@@ -14,19 +14,19 @@ using either a condition or result. Having "mixed" types of entries in a section
14
14
  is currently not well supported in the existing Record class
15
15
 
16
16
  Additionally, there is a mismatch between the data needed to calculate Stage 2
17
- Meaningful Use Quailty Measures and the data contained in patient summary
17
+ Meaningful Use Quality Measures and the data contained in patient summary
18
18
  standards. The CQMs are checking to see if a functional status represented by
19
19
  a result was patient supplied. Right now, results do not have a source, and
20
20
  even if we were to use Provider as a source, it would need to be extended
21
21
  to support patients.
22
22
 
23
- To avoid this, the patient sumamry style functional status has been "flattened"
23
+ To avoid this, the patient summary style functional status has been "flattened"
24
24
  into this class. This model supports the information needed to calculate
25
25
  Stage 2 MU CQMs. If importers are created from C32 or CCDA, the information
26
26
  can be stored here, but it will be a lossy transformation.
27
27
  @class
28
28
  @augments hQuery.CodedEntry
29
- @exports FunctionalStatus as hQuery.FunctionalStatus
29
+ @exports FunctionalStatus as hQuery.FunctionalStatus
30
30
  ###
31
31
  class hQuery.FunctionalStatus extends hQuery.CodedEntry
32
32
  constructor: (@json) ->
@@ -44,4 +44,13 @@ class hQuery.FunctionalStatus extends hQuery.CodedEntry
44
44
  ###
45
45
  source: ->
46
46
  hQuery.createCodedValue @json["source"]
47
-
47
+
48
+ ###*
49
+ @returns {CodedValue}
50
+ ###
51
+ reaction: -> hQuery.createCodedValue @json['reaction']
52
+
53
+ ###*
54
+ @returns {CodedValue}
55
+ ###
56
+ method: -> hQuery.createCodedValue @json['method']
@@ -21,7 +21,7 @@ class hQuery.NoImmunization extends hQuery.CodedValue
21
21
  OUT_OF_STOCK = "OSTOCK"
22
22
  PAT_OBJ = "PATOBJ"
23
23
  PHIL_OBJ = "PHILISOP"
24
- REL_OBJ = "RELIG"
24
+ REL_OBJ = "RELIG"
25
25
  VAC_EFF = "VACEFF"
26
26
  VAC_SAFETY = "VACSAF"
27
27
 
@@ -44,22 +44,22 @@ class hQuery.NoImmunization extends hQuery.CodedValue
44
44
  @returns {Boolean}
45
45
  ###
46
46
  isPatObj: -> @c is PAT_OBJ
47
-
47
+
48
48
  ###*
49
49
  @returns {Boolean}
50
50
  ###
51
- isPhilisop: -> @c is PHIL_OBJ
52
-
51
+ isPhilisop: -> @c is PHIL_OBJ
52
+
53
53
  ###*
54
54
  @returns {Boolean}
55
55
  ###
56
56
  isRelig: -> @c is REL_OBJ
57
-
57
+
58
58
  ###*
59
59
  @returns {Boolean}
60
60
  ###
61
61
  isVacEff: -> @c is VAC_EFF
62
-
62
+
63
63
  ###*
64
64
  @returns {Boolean}
65
65
  ###
@@ -74,37 +74,37 @@ class hQuery.NoImmunization extends hQuery.CodedValue
74
74
  class hQuery.Immunization extends hQuery.CodedEntry
75
75
  constructor: (@json) ->
76
76
  super(@json)
77
-
77
+
78
78
  ###*
79
- @returns{hQuery.Scalar}
79
+ @returns{hQuery.Scalar}
80
80
  ###
81
81
  medicationSeriesNumber: -> new hQuery.Scalar @json['medicationSeriesNumber'] if @json['medicationSeriesNumber']
82
-
82
+
83
83
  ###*
84
84
  @returns{hQuery.MedicationInformation}
85
85
  ###
86
86
  medicationInformation: ->new hQuery.MedicationInformation @json
87
-
87
+
88
88
  ###*
89
89
  @returns{Date} Date immunization was administered
90
90
  ###
91
91
  administeredDate: -> dateFromUtcSeconds @json['administeredDate']
92
-
92
+
93
93
  ###*
94
94
  @returns{hQuery.Actor} Performer of immunization
95
95
  ###
96
96
  performer:-> new hQuery.Actor @json['performer'] if @json['performer']
97
-
97
+
98
98
  ###*
99
99
  @returns {comment} human readable description of event
100
100
  ###
101
101
  comment: -> @json['comment']
102
-
102
+
103
103
  ###*
104
104
  @returns {Boolean} whether the immunization has been refused by the patient.
105
105
  ###
106
106
  refusalInd: -> @json['negationInd']
107
-
107
+
108
108
  ###*
109
109
  NoImmunzation as defined by value set 2.16.840.1.113883.1.11.19717
110
110
  The terms come from Health Level Seven (HL7) Version 3.0 Vocabulary and are managed by HL7
@@ -112,4 +112,9 @@ class hQuery.Immunization extends hQuery.CodedEntry
112
112
  @returns {hQuery.NoImmunization} Used to indicate reason an immunization was not administered.
113
113
  ###
114
114
  refusalReason: -> new hQuery.NoImmunization @json['negationReason']?['code'], @json['negationReason']?['code_system']
115
-
115
+
116
+ ###*
117
+ @returns {CodedValue}
118
+ ###
119
+ reaction: -> new hQuery.createCodedValue @json['reaction']
120
+
@@ -6,24 +6,20 @@ this.hQuery ||= {}
6
6
 
7
7
  # =require core.coffee
8
8
  ###*
9
- @class
9
+ @class
10
10
  @augments hQuery.CodedEntry
11
11
  @exports Language as hQuery.Language
12
12
  ###
13
13
  class hQuery.Language extends hQuery.CodedEntry
14
14
  constructor: (@json) ->
15
15
  super(@json)
16
-
16
+
17
17
  ###*
18
18
  @returns {hQuery.CodedValue}
19
19
  ###
20
20
  modeCode: -> hQuery.createCodedValue @json['modeCode']
21
-
21
+
22
22
  ###*
23
23
  @returns {String}
24
24
  ###
25
25
  preferenceIndicator: -> @json['preferenceIndicator']
26
-
27
-
28
-
29
-
@@ -14,11 +14,11 @@ The template identifier for this section is 2.16.840.1.113883.3.88.11.83.128
14
14
  C83-[CT-128-1] This section shall conform to the HL7 CCD section, and shall contain a templateId element whose root attribute is 2.16.840.1.113883.10.20.1.7.
15
15
  C83-[CT-128-2] This section SHALL conform to the IHE Medical Devices Section, and shall contain a templateId element whose root attribute is 1.3.6.1.4.1.19376.1.5.3.1.1.5.3.5
16
16
 
17
- @exports MedicalEquipment as hQuery.MedicalEquipment
17
+ @exports MedicalEquipment as hQuery.MedicalEquipment
18
18
  @augments hQuery.CodedEntry
19
- ###
19
+ ###
20
20
  class hQuery.MedicalEquipment extends hQuery.CodedEntry
21
-
21
+
22
22
  constructor: (@json) ->
23
23
  super(@json)
24
24
 
@@ -27,6 +27,29 @@ class hQuery.MedicalEquipment extends hQuery.CodedEntry
27
27
  ###
28
28
  anatomicalStructure: -> hQuery.createCodedValue @json['anatomicalStructure']
29
29
 
30
+ ###*
31
+ @returns {CodedValue}
32
+ ###
33
+ anatomicalApproach: -> new hQuery.createCodedValue @json['anatomicalApproach']
34
+
35
+ ###*
36
+ @returns {CodedValue}
37
+ ###
38
+ anatomicalLocation: ->
39
+ #backwards compatibility with older patient records. anatomicalStructure was used for anatomicalLocation
40
+ at = @json['anatomicalLocation']
41
+ if at? then new hQuery.CodedValue(at) else @anatomicalStructure()
42
+
43
+ ###*
44
+ @returns {CodedValue}
45
+ ###
46
+ method: -> new hQuery.createCodedValue @json['method']
47
+
48
+ ###*
49
+ @returns {CodedValue}
50
+ ###
51
+ reaction: -> new hQuery.createCodedValue @json['reaction']
52
+
30
53
  ###*
31
54
  @returns {Date} The actual or intended removal time of the device.
32
55
  ###
@@ -38,11 +38,11 @@ class hQuery.AdministrationTiming
38
38
  @returns {hQuery.Scalar}
39
39
  ###
40
40
  period: -> new hQuery.Scalar @json['period'] if @json['period']
41
-
41
+
42
42
  ###*
43
- Indicates whether it is the interval (time between dosing), or frequency
44
- (number of doses in a time period) that is important. If instititutionSpecified is not
45
- present or is set to false, then the time between dosing is important (every 8 hours).
43
+ Indicates whether it is the interval (time between dosing), or frequency
44
+ (number of doses in a time period) that is important. If instititutionSpecified is not
45
+ present or is set to false, then the time between dosing is important (every 8 hours).
46
46
  If true, then the frequency of administration is important (e.g., 3 times per day).
47
47
  @returns {Boolean}
48
48
  ###
@@ -54,7 +54,7 @@ class hQuery.AdministrationTiming
54
54
  ###
55
55
  class hQuery.DoseRestriction
56
56
  constructor: (@json) ->
57
- numerator: -> new hQuery.Scalar @json['numerator'] if @json['numerator']
57
+ numerator: -> new hQuery.Scalar @json['numerator'] if @json['numerator']
58
58
  denominator: -> new hQuery.Scalar @json['denominator'] if @json['denominator']
59
59
 
60
60
 
@@ -78,7 +78,7 @@ class hQuery.Fulfillment
78
78
  ###
79
79
  class hQuery.OrderInformation
80
80
  constructor: (@json) ->
81
-
81
+
82
82
  orderNumber: -> @json['orderNumber']
83
83
  fills: -> @json['fills']
84
84
  quantityOrdered: -> new hQuery.Scalar @json['quantityOrdered'] if @json['quantityOrdered']
@@ -153,7 +153,7 @@ class hQuery.StatusOfMedication extends hQuery.CodedValue
153
153
  class hQuery.Medication extends hQuery.CodedEntry
154
154
  constructor: (@json) ->
155
155
  super(@json)
156
-
156
+
157
157
  ###*
158
158
  @returns {String}
159
159
  ####
@@ -173,11 +173,39 @@ class hQuery.Medication extends hQuery.CodedEntry
173
173
  ###
174
174
  indicateMedicationStop: -> hQuery.dateFromUtcSeconds @json['end_time']
175
175
 
176
+
177
+ ###*
178
+ @returns {Date}
179
+ ###
180
+ activeDateTime: -> hQuery.dateFromUtcSeconds @json['active_datetime'] if @json['active_datetime']
181
+
182
+ ###*
183
+ @returns {Date}
184
+ ###
185
+ signedDateTime: -> hQuery.dateFromUtcSeconds @json['signed_datetime'] if @json['signed_datetime']
186
+
187
+
176
188
  administrationTiming: -> new hQuery.AdministrationTiming @json['administrationTiming'] if @json['administrationTiming']
177
189
 
190
+ ###*
191
+ This is used for Medicaton, Order. It is the total number of times a dose of a particular
192
+ medication can be administered. This, coupled with the administrationTiming will
193
+ give the cumulative medication duration.
194
+ E.g.
195
+ allowedAdministrations = 90 doses
196
+ administrationTiming = 1 dose / 12 hours
197
+ cumulativeMedicationDuration = allowedAdministrations / administrationTiming * (time conversion)
198
+ cumulativeMedicationDuration = (90 doses) * (12 hours)/(1 dose) * (1 day)/(24 hours) = 45 days
199
+ Medication, Order can't use fulfillmentHistory because the fulfillment of the
200
+ medication has not yet happened.
201
+ This corresponds to 'repeatNumber' in the QRDA representation
202
+ @returns {Integer}
203
+ ###
204
+ allowedAdministrations: -> @json['allowedAdministrations']
205
+
178
206
  ###*
179
207
  @returns {CodedValue} Contains routeCode or adminstrationUnitCode information.
180
- Route code shall have a a value drawn from FDA route of adminstration,
208
+ Route code shall have a a value drawn from FDA route of administration,
181
209
  and indicates how the medication is received by the patient.
182
210
  See http://www.fda.gov/Drugs/DevelopmentApprovalProcess/UCM070829
183
211
  The administration unit code shall have a value drawn from the FDA
@@ -188,15 +216,27 @@ class hQuery.Medication extends hQuery.CodedEntry
188
216
  route: -> hQuery.createCodedValue @json['route']
189
217
 
190
218
  ###*
191
- @returns {hQuery.Scalar} the dose
219
+ @returns {Hash} with two keys: units and scalar
192
220
  ###
193
- dose: -> new hQuery.Scalar @json['dose'] if @json['dose']
221
+ dose: ->
222
+ # In Bonnie, dose can be specified in two different contexts: CMD specification and as a field value; the
223
+ # CMD version used 'unit' and 'value', while the field value version uses 'units' and 'scalar'; we want to
224
+ # consolidate the versions, so here we convert everything to the field value style
225
+ if @json.dose
226
+ units: @json.dose.units || @json.dose.unit
227
+ scalar: @json.dose.scalar || @json.dose.value
194
228
 
195
229
  ###*
196
230
  @returns {CodedValue}
197
231
  ###
198
232
  site: -> hQuery.createCodedValue @json['site'] if @json['site']
199
233
 
234
+ ###*
235
+ @returns {CodedValue}
236
+ ###
237
+ anatomicalApproach: ->
238
+ #backwards compatibility for older patient records
239
+ if @json['anatomicalApproach'] then hQuery.createCodedValue @json['anatomicalApproach'] else @site()
200
240
  ###*
201
241
  @returns {hQuery.DoseRestriction}
202
242
  ###
@@ -237,6 +277,11 @@ class hQuery.Medication extends hQuery.CodedEntry
237
277
  ###
238
278
  deliveryMethod: -> hQuery.createCodedValue @json['deliveryMethod']
239
279
 
280
+ ###*
281
+ @returns {CodedValue}
282
+ ###
283
+ method: -> hQuery.createCodedValue @json['method']
284
+
240
285
  ###*
241
286
  @returns {hQuery.MedicationInformation}
242
287
  ###
@@ -258,20 +303,21 @@ class hQuery.Medication extends hQuery.CodedEntry
258
303
  @returns {String} free text instructions to the patient
259
304
  ###
260
305
  patientInstructions: -> @json['patientInstructions']
261
-
306
+
262
307
  ###*
263
308
  The duration over which this medication has been active. For example, 5 days.
264
309
  @returns {Hash} with two keys: unit and scalar
265
310
  ###
266
311
  cumulativeMedicationDuration: -> @json['cumulativeMedicationDuration']
267
312
 
313
+ refills: -> @json['refills']
268
314
  ###*
269
315
  @returns {Array} an array of {@link FulFillment} objects
270
316
  ###
271
317
  fulfillmentHistory: ->
272
318
  for order in @json['fulfillmentHistory']
273
319
  new hQuery.Fulfillment order
274
-
320
+
275
321
  ###*
276
322
  @returns {Array} an array of {@link OrderInformation} objects
277
323
  ###