hquery-patient-api 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,14 +1,21 @@
1
1
  source :rubygems
2
2
 
3
- gem 'execjs'
4
3
  gem 'sprockets'
5
4
  gem 'coffee-script'
6
5
  gem 'uglifier'
7
6
  gem 'rake'
8
7
  gem 'tilt'
9
- gem 'therubyrhino', :platforms => :jruby
10
8
 
11
9
  group :test do
12
10
  gem 'minitest'
13
11
  gem 'turn', :require => false
12
+
13
+ platforms :ruby do
14
+ gem "libv8"
15
+ gem "therubyracer", :require => 'v8'
16
+ end
17
+
18
+ platforms :jruby do
19
+ gem "therubyrhino"
20
+ end
14
21
  end
data/Rakefile CHANGED
@@ -15,6 +15,7 @@ Rake::TestTask.new("test_units") { |t|
15
15
 
16
16
 
17
17
  namespace :doc do
18
+ desc "Generate JS from CoffeeScript"
18
19
  task :generate_js do
19
20
  ctx = Sprockets::Environment.new(File.expand_path("../", __FILE__))
20
21
  Tilt::CoffeeScriptTemplate.default_bare=true
@@ -39,7 +39,7 @@ class hQuery.Allergy extends hQuery.CodedEntry
39
39
  Adverse event types SHALL be coded as specified in HITSP/C80 Section 2.2.3.4.2 Allergy/Adverse Event Type
40
40
  @returns {CodedValue}
41
41
  ###
42
- adverseEventType: -> new hQuery.CodedValue @json['type']['code'], @json['type']['codeSystem']
42
+ adverseEventType: -> hQuery.createCodedValue @json['type']
43
43
 
44
44
  ###*
45
45
  This indicates the reaction that may be caused by the product or agent.
@@ -55,7 +55,7 @@ class hQuery.Allergy extends hQuery.CodedEntry
55
55
  235719002 Food intolerance (disorder)
56
56
  @returns {CodedValue}
57
57
  ###
58
- reaction: -> new hQuery.CodedValue @json['reaction']['code'], @json['reaction']['codeSystem']
58
+ reaction: -> hQuery.createCodedValue @json['reaction']
59
59
 
60
60
  ###*
61
61
  This is a description of the level of the severity of the allergy or intolerance.
@@ -68,7 +68,7 @@ class hQuery.Allergy extends hQuery.CodedEntry
68
68
  399166001 Fatal
69
69
  @returns {CodedValue}
70
70
  ###
71
- severity: -> new hQuery.CodedValue @json['severity']['code'], @json['severity']['codeSystem']
71
+ severity: -> hQuery.createCodedValue @json['severity']
72
72
 
73
73
  ###*
74
74
  Additional comment or textual information
@@ -54,7 +54,7 @@ class hQuery.Condition extends hQuery.CodedEntry
54
54
  Ordinality
55
55
  @returns {CodedValue}
56
56
  ###
57
- ordinality: -> new hQuery.CodedValue @json['ordinality_code']['code'], @json['ordinality_code']['codeSystem']
57
+ ordinality: -> hQuery.createCodedValue @json['ordinality']
58
58
 
59
59
  ###*
60
60
  age at onset
@@ -67,13 +67,13 @@ class hQuery.Condition extends hQuery.CodedEntry
67
67
  cause of death
68
68
  @returns {hQuery.CauseOfDeath}
69
69
  ###
70
- causeOfDeath: -> new hQuery.CauseOfDeath @json['causeOfDeath']
70
+ causeOfDeath: -> new hQuery.CauseOfDeath @json['causeOfDeath'] if @json['causeOfDeath']
71
71
 
72
72
  ###*
73
73
  problem status
74
74
  @returns {hQuery.CodedValue}
75
75
  ###
76
- problemStatus: -> new hQuery.CodedValue @json['problemStatus']['code'], @json['problemStatus']['codeSystem']
76
+ problemStatus: -> hQuery.createCodedValue @json['problemStatus']
77
77
 
78
78
  ###*
79
79
  comment
@@ -85,4 +85,4 @@ class hQuery.Condition extends hQuery.CodedEntry
85
85
  This is a description of the level of the severity of the condition.
86
86
  @returns {CodedValue}
87
87
  ###
88
- severity: -> new hQuery.CodedValue @json['severity']['code'], @json['severity']['codeSystem']
88
+ severity: -> hQuery.createCodedValue @json['severity']
@@ -346,6 +346,12 @@ class hQuery.CodedEntry
346
346
  # id of the entry from the source document if available
347
347
  @source_id = @json['id']
348
348
  @_freeTextType = @json['description']
349
+
350
+ ###*
351
+ Adjust the start and end times of this event to the supplied timestamp
352
+ ###
353
+ setTimestamp: (timestamp) ->
354
+ @_date = @_startDate = @_endDate = timestamp
349
355
 
350
356
  ###*
351
357
  Date and time at which the coded entry took place
@@ -456,11 +462,14 @@ class hQuery.CodedEntry
456
462
  Indicates the reason an entry was negated.
457
463
  @returns {hQuery.CodedValue} Used to indicate reason an immunization was not administered.
458
464
  ###
459
- negationReason: ->
460
- if @json['negationReason'] && @json['negationReason']['code'] && @json['negationReason']['codeSystem']
461
- new hQuery.CodedValue @json['negationReason']['code'], @json['negationReason']['codeSystem']
462
- else
463
- null
465
+ negationReason: -> hQuery.createCodedValue @json['negationReason']
466
+
467
+ ###*
468
+ Explains the reason for an entry.
469
+ @returns {hQuery.CodedValue} Used to explain the rationale for a given entry.
470
+ ###
471
+ reason: -> hQuery.createCodedValue @json['reason']
472
+
464
473
 
465
474
  ###*
466
475
  @class Represents a list of hQuery.CodedEntry instances. Offers utility methods for matching
@@ -493,7 +502,8 @@ class hQuery.CodedEntryList extends Array
493
502
  for entry in this
494
503
  afterStart = (!start || entry.timeStamp()>=start)
495
504
  beforeEnd = (!end || entry.timeStamp()<=end)
496
- if (afterStart && beforeEnd && entry.includesCodeFrom(codeSet) && (includeNegated || !entry.negationInd()))
505
+ matchesCode = codeSet == null || entry.includesCodeFrom(codeSet)
506
+ if (afterStart && beforeEnd && matchesCode && (includeNegated || !entry.negationInd()))
497
507
  cloned.push(entry)
498
508
  cloned
499
509
 
@@ -553,4 +563,5 @@ hQuery.createCodedValues = (jsonCodes) ->
553
563
  codedValues.push new hQuery.CodedValue code, codeSystem
554
564
  codedValues
555
565
 
556
-
566
+ hQuery.createCodedValue = (json) ->
567
+ new hQuery.CodedValue json['code'], json['codeSystem'] if json?
@@ -9,48 +9,77 @@ this.hQuery ||= {}
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,
12
- or treating the patient's condition. It may include visits, appointments, as well
12
+ or treating the patients condition. It may include visits, appointments, as well
13
13
  as non face-to-face interactions. It is also a contact between a patient and a
14
14
  practitioner who has primary responsibility for assessing and treating the
15
15
  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
- practitioner
17
+ practitioner
18
18
  @augments hQuery.CodedEntry
19
19
  @exports Encounter as hQuery.Encounter
20
20
  ###
21
21
  class hQuery.Encounter extends hQuery.CodedEntry
22
22
  constructor: (@json) ->
23
23
  super(@json)
24
+ @_admitTime = hQuery.dateFromUtcSeconds @json['admitTime'] if @json['admitTime']
25
+ @_dischargeTime = hQuery.dateFromUtcSeconds @json['dischargeTime'] if @json['dischargeTime']
26
+ @_facility = new hQuery.Facility @json['facility'] if @json['facility']
24
27
 
25
28
  ###*
26
29
  @returns {String}
27
30
  ####
28
- dischargeDisp: -> @json['dischargeDisp']
31
+ dischargeDisposition: -> @json['dischargeDisposition']
29
32
 
30
33
  ###*
31
34
  A code indicating the priority of the admission (e.g., Emergency, Urgent, Elective, et cetera) from
32
35
  National Uniform Billing Committee (NUBC)
33
36
  @returns {CodedValue}
34
37
  ###
35
- admitType: -> new hQuery.CodedValue @json['admitType']['code'], @json['admitType']['codeSystem']
38
+ admitType: -> hQuery.createCodedValue @json['admitType']
39
+
40
+ ###*
41
+ Date and time at which the patient was admitted for the encounter
42
+ @returns {Date}
43
+ ###
44
+ admitTime: -> @_admitTime
45
+
46
+ ###*
47
+ Date and time at which the patient was discharged for the encounter
48
+ @returns {Date}
49
+ ###
50
+ dischargeTime: -> @_dischargeTime
36
51
 
37
52
  ###*
38
53
  @returns {hQuery.Actor}
39
54
  ###
40
- performer: -> new hQuery.Actor @json['performer']
55
+ performer: -> new hQuery.Actor @json['performer'] if @json['performer']
41
56
 
42
57
  ###*
43
58
  @returns {hQuery.Organization}
44
59
  ###
45
- facility: -> new hQuery.Facility @json['facility']
60
+ facility: -> @_facility
61
+ facilityArrival: -> @_facility?.startDate()
62
+ facilityDeparture: -> @_facility?.endDate()
46
63
 
47
64
  ###*
48
- @returns {hQuery.DateRange}
65
+ @returns {hQuery.CodedEntry}
49
66
  ###
50
- encounterDuration: -> new hQuery.DateRange @json
67
+ reasonForVisit: -> new hQuery.CodedEntry @json['reason'] if @json['reason']
51
68
 
52
69
  ###*
53
- @returns {hQuery.CodedEntry}
70
+ @returns {Integer}
54
71
  ###
55
- reasonForVisit: -> new hQuery.CodedEntry @json['reason']
72
+ lengthOfStay: ->
73
+ return 0 unless @startDate()? && @endDate()?
74
+ Math.floor((@endDate() - @startDate()) / (1000 * 60 * 60 * 24))
75
+
76
+
77
+ ###*
78
+ @returns {CodedValue}
79
+ ###
80
+ transferTo: -> hQuery.createCodedValue @json['transferTo']
56
81
 
82
+ ###*
83
+ @returns {CodedValue}
84
+ ###
85
+ transferFrom: -> hQuery.createCodedValue @json['transferFrom']
@@ -43,6 +43,5 @@ class hQuery.FunctionalStatus extends hQuery.CodedEntry
43
43
  @returns {hQuery.CodedValue}
44
44
  ###
45
45
  source: ->
46
- if @json["source"]?
47
- new hQuery.CodedValue @json["source"]["code"], @json["source"]["codeSystem"]
46
+ hQuery.createCodedValue @json["source"]
48
47
 
@@ -78,7 +78,7 @@ class hQuery.Immunization extends hQuery.CodedEntry
78
78
  ###*
79
79
  @returns{hQuery.Scalar}
80
80
  ###
81
- medicationSeriesNumber: -> new hQuery.Scalar @json['medicationSeriesNumber']
81
+ medicationSeriesNumber: -> new hQuery.Scalar @json['medicationSeriesNumber'] if @json['medicationSeriesNumber']
82
82
 
83
83
  ###*
84
84
  @returns{hQuery.MedicationInformation}
@@ -93,7 +93,7 @@ class hQuery.Immunization extends hQuery.CodedEntry
93
93
  ###*
94
94
  @returns{hQuery.Actor} Performer of immunization
95
95
  ###
96
- performer:-> new hQuery.Actor @json['performer']
96
+ performer:-> new hQuery.Actor @json['performer'] if @json['performer']
97
97
 
98
98
  ###*
99
99
  @returns {comment} human readable description of event
@@ -111,5 +111,5 @@ class hQuery.Immunization extends hQuery.CodedEntry
111
111
  It indicates the reason an immunization was not administered.
112
112
  @returns {hQuery.NoImmunization} Used to indicate reason an immunization was not administered.
113
113
  ###
114
- refusalReason: -> new hQuery.NoImmunization @json['negationReason']['code'], @json['negationReason']['codeSystem']
114
+ refusalReason: -> new hQuery.NoImmunization @json['negationReason']?['code'], @json['negationReason']?['codeSystem']
115
115
 
@@ -17,7 +17,7 @@ class hQuery.Language extends hQuery.CodedEntry
17
17
  ###*
18
18
  @returns {hQuery.CodedValue}
19
19
  ###
20
- modeCode: -> new hQuery.CodedValue @json['modeCode']['code'], @json['modeCode']['codeSystem']
20
+ modeCode: -> hQuery.createCodedValue @json['modeCode']
21
21
 
22
22
  ###*
23
23
  @returns {String}
@@ -25,4 +25,9 @@ class hQuery.MedicalEquipment extends hQuery.CodedEntry
25
25
  ###*
26
26
  @returns {CodedValue}
27
27
  ###
28
- anatomicalStructure: -> new hQuery.CodedValue @json['anatomicalStructure']['code'], @json['anatomicalStructure']['codeSystem']
28
+ anatomicalStructure: -> hQuery.createCodedValue @json['anatomicalStructure']
29
+
30
+ ###*
31
+ @returns {Date} The actual or intended removal time of the device.
32
+ ###
33
+ removalTime: -> hQuery.dateFromUtcSeconds @json['removalTime'] if @json['removalTime']
@@ -37,7 +37,7 @@ class hQuery.AdministrationTiming
37
37
  mean that the medication should be taken every 8 hours.
38
38
  @returns {hQuery.Scalar}
39
39
  ###
40
- period: -> new hQuery.Scalar @json['period']
40
+ period: -> new hQuery.Scalar @json['period'] if @json['period']
41
41
 
42
42
  ###*
43
43
  Indicates whether it is the interval (time between dosing), or frequency
@@ -54,8 +54,8 @@ class hQuery.AdministrationTiming
54
54
  ###
55
55
  class hQuery.DoseRestriction
56
56
  constructor: (@json) ->
57
- numerator: -> new hQuery.Scalar @json['numerator']
58
- denominator: -> new hQuery.Scalar @json['denominator']
57
+ numerator: -> new hQuery.Scalar @json['numerator'] if @json['numerator']
58
+ denominator: -> new hQuery.Scalar @json['denominator'] if @json['denominator']
59
59
 
60
60
 
61
61
  ###*
@@ -66,11 +66,11 @@ class hQuery.Fulfillment
66
66
  constructor: (@json) ->
67
67
 
68
68
  dispenseDate: -> hQuery.dateFromUtcSeconds @json['dispenseDate']
69
- dispensingPharmacyLocation: -> new hQuery.Address @json['dispensingPharmacyLocation']
70
- quantityDispensed: -> new hQuery.Scalar @json['quantityDispensed']
69
+ dispensingPharmacyLocation: -> new hQuery.Address @json['dispensingPharmacyLocation'] if @json['dispensingPharmacyLocation']
70
+ quantityDispensed: -> new hQuery.Scalar @json['quantityDispensed'] if @json['quantityDispensed']
71
71
  prescriptionNumber: -> @json['prescriptionNumber']
72
72
  fillNumber: -> @json['fillNumber']
73
- fillStatus: -> new hQuery.Status @json['fillStatus']
73
+ fillStatus: -> new hQuery.Status @json['fillStatus'] if @json['fillStatus']
74
74
 
75
75
  ###*
76
76
  @class OrderInformation - information abour an order for a medication
@@ -81,7 +81,7 @@ class hQuery.OrderInformation
81
81
 
82
82
  orderNumber: -> @json['orderNumber']
83
83
  fills: -> @json['fills']
84
- quantityOrdered: -> new hQuery.Scalar @json['quantityOrdered']
84
+ quantityOrdered: -> new hQuery.Scalar @json['quantityOrdered'] if @json['quantityOrdered']
85
85
  orderExpirationDateTime: -> hQuery.dateFromUtcSeconds @json['orderExpirationDateTime']
86
86
  orderDateTime: -> hQuery.dateFromUtcSeconds @json['orderDateTime']
87
87
 
@@ -173,7 +173,7 @@ class hQuery.Medication extends hQuery.CodedEntry
173
173
  ###
174
174
  indicateMedicationStop: -> hQuery.dateFromUtcSeconds @json['end_time']
175
175
 
176
- administrationTiming: -> new hQuery.AdministrationTiming @json['administrationTiming']
176
+ administrationTiming: -> new hQuery.AdministrationTiming @json['administrationTiming'] if @json['administrationTiming']
177
177
 
178
178
  ###*
179
179
  @returns {CodedValue} Contains routeCode or adminstrationUnitCode information.
@@ -185,22 +185,22 @@ class hQuery.Medication extends hQuery.CodedEntry
185
185
  product as presented to the patient.
186
186
  See http://www.fda.gov/Drugs/InformationOnDrugs/ucm142454.htm
187
187
  ###
188
- route: -> new hQuery.CodedValue @json['route']['code'], @json['route']['codeSystem']
188
+ route: -> hQuery.createCodedValue @json['route']
189
189
 
190
190
  ###*
191
191
  @returns {hQuery.Scalar} the dose
192
192
  ###
193
- dose: -> new hQuery.Scalar @json['dose']
193
+ dose: -> new hQuery.Scalar @json['dose'] if @json['dose']
194
194
 
195
195
  ###*
196
196
  @returns {CodedValue}
197
197
  ###
198
- site: -> new hQuery.CodedValue @json['site']['code'], @json['site']['codeSystem']
198
+ site: -> hQuery.createCodedValue @json['site'] if @json['site']
199
199
 
200
200
  ###*
201
201
  @returns {hQuery.DoseRestriction}
202
202
  ###
203
- doseRestriction: -> new hQuery.DoseRestriction @json['doseRestriction']
203
+ doseRestriction: -> new hQuery.DoseRestriction @json['doseRestriction'] if @json['doseRestriction']
204
204
 
205
205
  ###*
206
206
  @returns {String}
@@ -215,27 +215,27 @@ class hQuery.Medication extends hQuery.CodedEntry
215
215
  ###*
216
216
  @returns {CodedValue}
217
217
  ###
218
- indication: -> new hQuery.CodedValue @json['indication']['code'], @json['indication']['codeSystem']
218
+ indication: -> hQuery.createCodedValue @json['indication']
219
219
 
220
220
  ###*
221
221
  @returns {CodedValue}
222
222
  ###
223
- productForm: -> new hQuery.CodedValue @json['productForm']['code'], @json['productForm']['codeSystem']
223
+ productForm: -> hQuery.createCodedValue @json['productForm']
224
224
 
225
225
  ###*
226
226
  @returns {CodedValue}
227
227
  ###
228
- vehicle: -> new hQuery.CodedValue @json['vehicle']['code'], @json['vehicle']['codeSystem']
228
+ vehicle: -> hQuery.createCodedValue @json['vehicle']
229
229
 
230
230
  ###*
231
231
  @returns {CodedValue}
232
232
  ###
233
- reaction: -> new hQuery.CodedValue @json['reaction']['code'], @json['reaction']['codeSystem']
233
+ reaction: -> hQuery.createCodedValue @json['reaction']
234
234
 
235
235
  ###*
236
236
  @returns {CodedValue}
237
237
  ###
238
- deliveryMethod: -> new hQuery.CodedValue @json['deliveryMethod']['code'], @json['deliveryMethod']['codeSystem']
238
+ deliveryMethod: -> hQuery.createCodedValue @json['deliveryMethod']
239
239
 
240
240
  ###*
241
241
  @returns {hQuery.MedicationInformation}
@@ -245,14 +245,14 @@ class hQuery.Medication extends hQuery.CodedEntry
245
245
  ###*
246
246
  @returns {hQuery.TypeOfMedication} Indicates whether this is an over the counter or prescription medication
247
247
  ###
248
- typeOfMedication: -> new hQuery.TypeOfMedication @json['typeOfMedication']['code'], @json['typeOfMedication']['codeSystem']
248
+ typeOfMedication: -> new hQuery.TypeOfMedication @json['typeOfMedication']?['code'], @json['typeOfMedication']?['codeSystem']
249
249
 
250
250
  ###*
251
251
  Values conform to value set 2.16.840.1.113883.1.11.20.7 - Medication Status
252
252
  Values may be: On Hold, No Longer Active, Active, Prior History
253
253
  @returns {hQuery.StatusOfMedication} Used to indicate the status of the medication.
254
254
  ###
255
- statusOfMedication: -> new hQuery.StatusOfMedication @json['statusOfMedication']['code'], @json['statusOfMedication']['codeSystem']
255
+ statusOfMedication: -> new hQuery.StatusOfMedication @json['statusOfMedication']?['code'], @json['statusOfMedication']?['codeSystem']
256
256
 
257
257
  ###*
258
258
  @returns {String} free text instructions to the patient
@@ -63,7 +63,7 @@ class hQuery.Patient extends hQuery.Person
63
63
  gender: -> @json['gender']
64
64
 
65
65
  ###*
66
- @returns {Date} containing the patient's birthdate
66
+ @returns {Date} containing the patients birthdate
67
67
  ###
68
68
  birthtime: ->
69
69
  hQuery.dateFromUtcSeconds @json['birthdate']
@@ -92,7 +92,7 @@ class hQuery.Patient extends hQuery.Person
92
92
  ###
93
93
  maritalStatus: ->
94
94
  if @json['maritalStatus']
95
- return new hQuery.CodedValue @json['maritalStatus']['code'], @json['maritalStatus']['codeSystem']
95
+ return hQuery.createCodedValue @json['maritalStatus']
96
96
 
97
97
  ###*
98
98
  @returns {CodedValue} of the spiritual faith affiliation of the patient
@@ -100,7 +100,7 @@ class hQuery.Patient extends hQuery.Person
100
100
  ###
101
101
  religiousAffiliation: ->
102
102
  if @json['religiousAffiliation']
103
- return new hQuery.CodedValue @json['religiousAffiliation']['code'], @json['religiousAffiliation']['codeSystem']
103
+ return hQuery.createCodedValue @json['religiousAffiliation']
104
104
 
105
105
  ###*
106
106
  @returns {CodedValue} of the race of the patient
@@ -108,7 +108,7 @@ class hQuery.Patient extends hQuery.Person
108
108
  ###
109
109
  race: ->
110
110
  if @json['race']
111
- return new hQuery.CodedValue @json['race']['code'], @json['race']['codeSystem']
111
+ return hQuery.createCodedValue @json['race']
112
112
 
113
113
  ###*
114
114
  @returns {CodedValue} of the ethnicity of the patient
@@ -116,7 +116,7 @@ class hQuery.Patient extends hQuery.Person
116
116
  ###
117
117
  ethnicity: ->
118
118
  if @json['ethnicity']
119
- return new hQuery.CodedValue @json['ethnicity']['code'], @json['ethnicity']['codeSystem']
119
+ return hQuery.createCodedValue @json['ethnicity']
120
120
 
121
121
  ###*
122
122
  @returns {CodedValue} This is the code specifying the level of confidentiality of the document.
@@ -124,7 +124,7 @@ class hQuery.Patient extends hQuery.Person
124
124
  ###
125
125
  confidentiality: ->
126
126
  if @json['confidentiality']
127
- return new hQuery.CodedValue @json['confidentiality']['code'], @json['confidentiality']['codeSystem']
127
+ return hQuery.createCodedValue @json['confidentiality']
128
128
 
129
129
  ###*
130
130
  @returns {Address} of the location where the patient was born
@@ -19,10 +19,27 @@ class hQuery.Procedure extends hQuery.CodedEntry
19
19
  ###*
20
20
  @returns {hQuery.Actor} The provider that performed the procedure
21
21
  ###
22
- performer: -> new hQuery.Actor @json['performer']
22
+ performer: -> new hQuery.Actor @json['performer'] if @json['performer']
23
23
 
24
24
  ###*
25
25
  @returns {hQuery.CodedValue} A SNOMED code indicating the body site on which the
26
26
  procedure was performed
27
27
  ###
28
- site: -> new hQuery.CodedValue @json['site']['code'], @json['site']['codeSystem']
28
+ site: -> new hQuery.CodedValue @json['site']?['code'], @json['site']?['codeSystem']
29
+
30
+ ###*
31
+ @returns {hQuery.CodedValue} A SNOMED code indicating where the procedure was performed.
32
+ ###
33
+ source: ->
34
+ hQuery.createCodedValue @json['source']
35
+
36
+ ###*
37
+ @returns {Date} The actual or intended start of an incision.
38
+ ###
39
+ incisionTime: -> hQuery.dateFromUtcSeconds @json['incisionTime'] if @json['incisionTime']
40
+
41
+ ###*
42
+ Ordinality
43
+ @returns {CodedValue}
44
+ ###
45
+ ordinality: -> hQuery.createCodedValue @json['ordinality']
@@ -16,17 +16,17 @@ class hQuery.Provider
16
16
  ###*
17
17
  @returns {hQuery.Person}
18
18
  ###
19
- providerEntity: -> new hQuery.Person @json['providerEntity']
19
+ providerEntity: -> new hQuery.Person @json['providerEntity'] if @json['providerEntity']
20
20
 
21
21
  ###*
22
22
  @returns {hQuery.DateRange}
23
23
  ###
24
- careProvisionDateRange: -> new hQuery.DateRange @json['careProvisionDateRange']
24
+ careProvisionDateRange: -> new hQuery.DateRange @json['careProvisionDateRange'] if @json['careProvisionDateRange']
25
25
 
26
26
  ###*
27
27
  @returns {hQuery.CodedValue}
28
28
  ###
29
- role: -> new hQuery.CodedValue @json['role']['code'], @json['role']['codeSystem']
29
+ role: -> hQuery.createCodedValue @json['role']
30
30
 
31
31
  ###*
32
32
  @returns {String}
@@ -37,7 +37,7 @@ class hQuery.Provider
37
37
  ###*
38
38
  @returns {hQuery.CodedValue}
39
39
  ###
40
- providerType: -> new hQuery.CodedValue @json['providerType']['code'], @json['providerType']['codeSystem']
40
+ providerType: -> hQuery.createCodedValue @json['providerType']
41
41
 
42
42
 
43
43
  ###*
@@ -29,7 +29,7 @@ class hQuery.Result extends hQuery.CodedEntry
29
29
  ###*
30
30
  @returns {CodedValue}
31
31
  ###
32
- interpretation: -> new hQuery.CodedValue @json['interpretation'].code, @json['interpretation'].codeSystem
32
+ interpretation: -> hQuery.createCodedValue @json['interpretation']
33
33
 
34
34
  ###*
35
35
  @returns {String}
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.email = "talk@hquery.org"
8
8
  s.homepage = "http://github.com/hquery/patient_api"
9
9
  s.authors = ["Marc Hadley", "Andy Gregorowicz", "Rob Dingwell"]
10
- s.version = '0.3.0'
10
+ s.version = '1.0.0'
11
11
 
12
12
  s.files = `git ls-files`.split("\n")
13
13
  end
@@ -99,10 +99,14 @@
99
99
  }
100
100
  ]
101
101
  },
102
+ "transferTo": {
103
+ "code": "444933003",
104
+ "codeSystem": "SNOMED-CT"
105
+ },
102
106
  "time": 1268042997,
103
107
  "description": "Outpatient encounter",
104
108
  "_id": "OP12345",
105
- "dischargeDisp": "Home",
109
+ "dischargeDisposition": "Home",
106
110
  "admitType": {
107
111
  "code": "04",
108
112
  "codeSystem": "regular"
@@ -112,8 +116,8 @@
112
116
  "name": "General Hospital"
113
117
  }
114
118
  },
115
- "low": 1124956803,
116
- "hi": 1314259203,
119
+ "start_time": 1124956803,
120
+ "end_time": 1314259203,
117
121
  "reason": {
118
122
  "codes": {
119
123
  "CPT": [
@@ -153,8 +157,7 @@
153
157
  "description": "Colorectal Cancer",
154
158
  "ageAtOnset": 20,
155
159
  "priority": 1,
156
- "ordinality": "principal",
157
- "ordinality_code": {
160
+ "ordinality": {
158
161
  "code": "8319008",
159
162
  "codeSystem": "SNOMED-CT"
160
163
  },
@@ -217,7 +220,12 @@
217
220
  "last": "Tables"
218
221
  }
219
222
  },
220
- "description": "Colonscopy"
223
+ "description": "Colonscopy",
224
+ "source": {
225
+ "code": "158967008",
226
+ "codeSystem": "SNOMED-CT"
227
+ },
228
+ "incisionTime": 1073238725
221
229
  }
222
230
  ],
223
231
  "results": [
@@ -345,6 +353,10 @@
345
353
  },
346
354
  "time": 1286382415,
347
355
  "description": "Multivitamin",
356
+ "reason": {
357
+ "code": "195911009",
358
+ "codeSystem": "SNOMED-CT"
359
+ },
348
360
  "brandName": "Centrum Silver",
349
361
  "route": {
350
362
  "code": "C38288",
@@ -1,4 +1,9 @@
1
1
  require File.expand_path("../../test_helper", __FILE__)
2
+ if RUBY_PLATFORM=='java'
3
+ require 'rhino'
4
+ else
5
+ require 'v8'
6
+ end
2
7
 
3
8
  class PatientApiTest < Test::Unit::TestCase
4
9
  def setup
@@ -7,8 +12,21 @@ class PatientApiTest < Test::Unit::TestCase
7
12
  initialize_patient = 'var patient = new hQuery.Patient(barry);'
8
13
  date = Time.new(2010,1,1)
9
14
  initialize_date = "var sampleDate = new Date(#{date.to_i*1000});"
10
- @context = ExecJS.compile(patient_api + "\nvar barry = " + fixture_json + ";\n" + initialize_patient + "\n" + initialize_date)
15
+ if RUBY_PLATFORM=='java'
16
+ @context = Rhino::Context.new
17
+ else
18
+ @context = V8::Context.new
19
+ end
20
+
21
+ @context.eval(patient_api + "\nvar barry = " + fixture_json + ";\n" + initialize_patient + "\n" + initialize_date)
11
22
  end
23
+
24
+ def test_utils
25
+ @context.eval('var encounter = patient.encounters()[0]')
26
+ assert_equal 2005, @context.eval('encounter.startDate().getFullYear()')
27
+ @context.eval('encounter.setTimestamp(new Date(2010,1,1))')
28
+ assert_equal 2010, @context.eval('encounter.startDate().getFullYear()')
29
+ end
12
30
 
13
31
  def test_demographics
14
32
  assert_equal 'Barry', @context.eval('patient.given()')
@@ -42,16 +60,18 @@ class PatientApiTest < Test::Unit::TestCase
42
60
  assert_equal 'CPT', @context.eval('patient.encounters()[0].type()[0].codeSystemName()')
43
61
  assert_equal 'OP12345', @context.eval('patient.encounters()[0].id')
44
62
  assert_equal 'Outpatient encounter', @context.eval('patient.encounters()[0].freeTextType()')
45
- assert_equal 'Home', @context.eval('patient.encounters()[0].dischargeDisp()')
63
+ assert_equal 'Home', @context.eval('patient.encounters()[0].dischargeDisposition()')
46
64
  assert_equal '04', @context.eval('patient.encounters()[0].admitType().code()')
47
65
  assert_equal 'General Hospital', @context.eval('patient.encounters()[0].performer().organization().organizationName()')
48
- assert_equal 2005, @context.eval('patient.encounters()[0].encounterDuration().low().getFullYear()')
49
- assert_equal 2011, @context.eval('patient.encounters()[0].encounterDuration().hi().getFullYear()')
66
+ assert_equal 2005, @context.eval('patient.encounters()[0].startDate().getFullYear()')
67
+ assert_equal 2011, @context.eval('patient.encounters()[0].endDate().getFullYear()')
50
68
  assert_equal 'PCP referred', @context.eval('patient.encounters()[0].reasonForVisit().freeTextType()')
51
69
  assert_equal 'CPT', @context.eval('patient.encounters()[0].reasonForVisit().type()[0].codeSystemName()')
52
70
  assert_equal 'HL7 Healthcare Service Location', @context.eval('patient.encounters()[0].facility().codeSystemName()')
53
71
  assert_equal '1155-1', @context.eval('patient.encounters()[0].facility().code()')
54
72
  assert_equal 'General Hospital', @context.eval('patient.encounters()[0].facility().name()')
73
+ assert_equal 2191, @context.eval('patient.encounters()[0].lengthOfStay()')
74
+ assert_equal "444933003", @context.eval('patient.encounters()[0].transferTo().code()')
55
75
  end
56
76
 
57
77
  def test_procedures
@@ -66,6 +86,8 @@ class PatientApiTest < Test::Unit::TestCase
66
86
  assert_equal '71854001', @context.eval('patient.procedures()[0].site().code()')
67
87
  assert_equal 'Bobby', @context.eval('patient.procedures()[0].performer().person().given()')
68
88
  assert_equal 'Tables', @context.eval('patient.procedures()[0].performer().person().last()')
89
+ assert_equal '158967008', @context.eval('patient.procedures()[0].source().code()')
90
+ assert_equal 1073238725000, @context.eval('patient.procedures()[0].incisionTime().getTime()')
69
91
  end
70
92
 
71
93
  def test_vital_signs
@@ -113,6 +135,7 @@ class PatientApiTest < Test::Unit::TestCase
113
135
  assert_equal 30, @context.eval('patient.medications()[0].orderInformation()[0].quantityOrdered().value()')
114
136
  assert_equal 20, @context.eval('patient.medications()[0].orderInformation()[0].fills()')
115
137
  assert_equal 3, @context.eval('patient.medications()[0].cumulativeMedicationDuration()["scalar"]')
138
+ assert_equal "195911009", @context.eval('patient.medications()[0].reason().code()')
116
139
  end
117
140
 
118
141
  def test_immunizations
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hquery-patient-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-11-01 00:00:00.000000000 Z
14
+ date: 2012-12-19 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: A javascript library abstraction for dealing with patients in hQuery
17
17
  map reduce functions