health-data-standards 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +9 -1
- data/Rakefile +14 -4
- data/lib/health-data-standards.rb +23 -0
- data/lib/health-data-standards/export/ccr.rb +55 -56
- data/lib/health-data-standards/export/hdata/metadata.rb +16 -0
- data/lib/health-data-standards/export/html.rb +21 -0
- data/lib/health-data-standards/export/template_helper.rb +3 -0
- data/lib/health-data-standards/export/view_helper.rb +29 -5
- data/lib/health-data-standards/import/c32/condition_importer.rb +31 -33
- data/lib/health-data-standards/import/c32/encounter_importer.rb +4 -6
- data/lib/health-data-standards/import/c32/medication_importer.rb +1 -5
- data/lib/health-data-standards/import/c32/organization_importer.rb +23 -0
- data/lib/health-data-standards/import/c32/patient_importer.rb +1 -4
- data/lib/health-data-standards/import/c32/provider_importer.rb +43 -30
- data/lib/health-data-standards/import/c32/section_importer.rb +20 -41
- data/lib/health-data-standards/import/ccr/patient_importer.rb +27 -10
- data/lib/health-data-standards/import/ccr/provider_importer.rb +29 -41
- data/lib/health-data-standards/import/ccr/section_importer.rb +38 -27
- data/lib/health-data-standards/import/green_c32/allergy_importer.rb +20 -0
- data/lib/health-data-standards/import/green_c32/condition_importer.rb +2 -3
- data/lib/health-data-standards/import/green_c32/encounter_importer.rb +42 -0
- data/lib/health-data-standards/import/green_c32/immunization_importer.rb +23 -0
- data/lib/health-data-standards/import/green_c32/medication_importer.rb +69 -0
- data/lib/health-data-standards/import/green_c32/procedure_importer.rb +35 -0
- data/lib/health-data-standards/import/green_c32/result_importer.rb +21 -8
- data/lib/health-data-standards/import/green_c32/section_importer.rb +55 -9
- data/lib/health-data-standards/import/green_c32/social_history_importer.rb +18 -0
- data/lib/health-data-standards/import/green_c32/vital_sign_importer.rb +21 -0
- data/lib/health-data-standards/import/hdata/metadata_importer.rb +82 -0
- data/lib/health-data-standards/import/provider_import_utils.rb +23 -0
- data/lib/health-data-standards/models/address.rb +11 -0
- data/lib/health-data-standards/models/allergy.rb +1 -0
- data/lib/health-data-standards/models/condition.rb +1 -1
- data/lib/health-data-standards/models/encounter.rb +11 -6
- data/lib/health-data-standards/models/entry.rb +16 -5
- data/lib/health-data-standards/models/fulfillment_history.rb +3 -5
- data/lib/health-data-standards/models/immunization.rb +7 -1
- data/lib/health-data-standards/models/medication.rb +4 -3
- data/lib/health-data-standards/models/metadata/author.rb +16 -0
- data/lib/health-data-standards/models/metadata/base.rb +20 -0
- data/lib/health-data-standards/models/metadata/change_info.rb +9 -0
- data/lib/health-data-standards/models/metadata/link_info.rb +9 -0
- data/lib/health-data-standards/models/metadata/pedigree.rb +15 -0
- data/lib/health-data-standards/models/organization.rb +8 -0
- data/lib/health-data-standards/models/procedure.rb +5 -2
- data/lib/health-data-standards/models/provider.rb +6 -1
- data/lib/health-data-standards/models/record.rb +13 -3
- data/lib/health-data-standards/models/social_history.rb +3 -0
- data/lib/health-data-standards/models/telecom.rb +9 -0
- data/lib/health-data-standards/models/vital_sign.rb +2 -0
- data/lib/health-data-standards/util/code_system_helper.rb +3 -1
- data/templates/_address.gc32.erb +9 -0
- data/templates/_allergies.c32.erb +2 -2
- data/templates/_allergy.gc32.erb +13 -0
- data/templates/_care_goals.c32.erb +1 -1
- data/templates/_condition.gc32.erb +6 -6
- data/templates/_conditions.c32.erb +2 -2
- data/templates/_encounter.gc32.erb +32 -0
- data/templates/_encounters.c32.erb +1 -1
- data/templates/_immunization.gc32.erb +9 -0
- data/templates/_immunizations.c32.erb +1 -1
- data/templates/_medical_equipment.c32.erb +1 -1
- data/templates/_medication.gc32.erb +60 -0
- data/templates/_medications.c32.erb +1 -1
- data/templates/_narrative_block.c32.erb +1 -1
- data/templates/_organization.gc32.erb +10 -0
- data/templates/_pedigree.hdata.erb +24 -0
- data/templates/_procedure.gc32.erb +8 -0
- data/templates/_procedures.c32.erb +1 -1
- data/templates/_provider.gc32.erb +19 -0
- data/templates/_results.c32.erb +1 -1
- data/templates/_social_history.c32.erb +1 -1
- data/templates/_social_history.gc32.erb +6 -0
- data/templates/_telecom.gc32.erb +1 -0
- data/templates/_vital_sign.gc32.erb +12 -0
- data/templates/_vital_signs.c32.erb +1 -1
- data/templates/metadata.hdata.erb +35 -0
- data/templates/show.html.erb +287 -0
- metadata +50 -15
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'rake/testtask'
|
2
|
+
require 'cane/rake_task'
|
3
|
+
require "simplecov"
|
2
4
|
|
3
5
|
Rake::TestTask.new(:test_unit) do |t|
|
4
6
|
t.libs << "test"
|
@@ -6,7 +8,15 @@ Rake::TestTask.new(:test_unit) do |t|
|
|
6
8
|
t.verbose = true
|
7
9
|
end
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
Cane::RakeTask.new(:quality) do |cane|
|
12
|
+
cane.abc_max = 45
|
13
|
+
cane.add_threshold 'coverage/covered_percent', :>=, 97
|
14
|
+
cane.style_measure = 120
|
15
|
+
cane.no_style = true
|
16
|
+
cane.no_doc = true
|
17
|
+
end
|
18
|
+
|
19
|
+
task :test => [:test_unit, :quality] do
|
20
|
+
|
21
|
+
system("open coverage/index.html")
|
22
|
+
end
|
@@ -19,10 +19,14 @@ require_relative 'health-data-standards/export/rendering_context'
|
|
19
19
|
require_relative 'health-data-standards/export/c32'
|
20
20
|
require_relative 'health-data-standards/export/ccr'
|
21
21
|
require_relative 'health-data-standards/export/csv'
|
22
|
+
require_relative 'health-data-standards/export/html'
|
23
|
+
require_relative 'health-data-standards/export/hdata/metadata'
|
22
24
|
|
23
25
|
require_relative 'health-data-standards/export/green_c32/entry'
|
24
26
|
require_relative 'health-data-standards/export/green_c32/export_generator'
|
25
27
|
|
28
|
+
require_relative 'health-data-standards/import/provider_import_utils'
|
29
|
+
require_relative 'health-data-standards/import/hdata/metadata_importer'
|
26
30
|
|
27
31
|
require_relative 'health-data-standards/models/entry'
|
28
32
|
require_relative 'health-data-standards/models/allergy'
|
@@ -37,10 +41,21 @@ require_relative 'health-data-standards/models/lab_result'
|
|
37
41
|
require_relative 'health-data-standards/models/record'
|
38
42
|
require_relative 'health-data-standards/models/provider'
|
39
43
|
require_relative 'health-data-standards/models/provider_performance'
|
44
|
+
require_relative 'health-data-standards/models/social_history'
|
45
|
+
require_relative 'health-data-standards/models/vital_sign'
|
46
|
+
require_relative 'health-data-standards/models/organization'
|
47
|
+
require_relative 'health-data-standards/models/address'
|
48
|
+
require_relative 'health-data-standards/models/telecom'
|
49
|
+
require_relative 'health-data-standards/models/metadata/base'
|
50
|
+
require_relative 'health-data-standards/models/metadata/author'
|
51
|
+
require_relative 'health-data-standards/models/metadata/change_info'
|
52
|
+
require_relative 'health-data-standards/models/metadata/link_info'
|
53
|
+
require_relative 'health-data-standards/models/metadata/pedigree'
|
40
54
|
|
41
55
|
require_relative 'health-data-standards/import/c32/section_importer'
|
42
56
|
require_relative 'health-data-standards/import/c32/allergy_importer'
|
43
57
|
require_relative 'health-data-standards/import/c32/encounter_importer'
|
58
|
+
require_relative 'health-data-standards/import/c32/condition_importer'
|
44
59
|
require_relative 'health-data-standards/import/c32/immunization_importer'
|
45
60
|
require_relative 'health-data-standards/import/c32/medication_importer'
|
46
61
|
require_relative 'health-data-standards/import/c32/procedure_importer'
|
@@ -48,6 +63,7 @@ require_relative 'health-data-standards/import/c32/result_importer'
|
|
48
63
|
require_relative 'health-data-standards/import/c32/vital_sign_importer'
|
49
64
|
require_relative 'health-data-standards/import/c32/patient_importer'
|
50
65
|
require_relative 'health-data-standards/import/c32/provider_importer'
|
66
|
+
require_relative 'health-data-standards/import/c32/organization_importer'
|
51
67
|
|
52
68
|
require_relative 'health-data-standards/import/ccr/patient_importer'
|
53
69
|
require_relative 'health-data-standards/import/ccr/provider_importer'
|
@@ -59,3 +75,10 @@ require_relative 'health-data-standards/import/ccr/product_importer'
|
|
59
75
|
require_relative 'health-data-standards/import/green_c32/section_importer'
|
60
76
|
require_relative 'health-data-standards/import/green_c32/result_importer'
|
61
77
|
require_relative 'health-data-standards/import/green_c32/condition_importer'
|
78
|
+
require_relative 'health-data-standards/import/green_c32/vital_sign_importer'
|
79
|
+
require_relative 'health-data-standards/import/green_c32/procedure_importer'
|
80
|
+
require_relative 'health-data-standards/import/green_c32/encounter_importer'
|
81
|
+
require_relative 'health-data-standards/import/green_c32/medication_importer'
|
82
|
+
require_relative 'health-data-standards/import/green_c32/allergy_importer'
|
83
|
+
require_relative 'health-data-standards/import/green_c32/social_history_importer'
|
84
|
+
require_relative 'health-data-standards/import/green_c32/immunization_importer'
|
@@ -28,16 +28,17 @@ module HealthDataStandards
|
|
28
28
|
end
|
29
29
|
to_ccr_purpose(xml)
|
30
30
|
xml.Body do
|
31
|
+
|
31
32
|
to_ccr_problems(xml, patient)
|
33
|
+
to_ccr_socialhistory(xml, patient)
|
32
34
|
to_ccr_allergies(xml, patient)
|
35
|
+
|
33
36
|
to_ccr_medications(xml, patient)
|
34
37
|
to_ccr_immunizations(xml, patient)
|
35
38
|
to_ccr_vitals(xml, patient)
|
36
39
|
to_ccr_results(xml, patient)
|
37
40
|
to_ccr_procedures(xml, patient)
|
38
|
-
to_ccr_encounters(xml, patient)
|
39
|
-
to_ccr_socialhistory(xml, patient)
|
40
|
-
|
41
|
+
to_ccr_encounters(xml, patient)
|
41
42
|
end
|
42
43
|
to_ccr_actors(xml, patient)
|
43
44
|
end
|
@@ -83,13 +84,7 @@ module HealthDataStandards
|
|
83
84
|
patient.conditions.each_with_index do |condition, index|
|
84
85
|
xml.Problem do
|
85
86
|
xml.CCRDataObjectID("PR000#{index + 1}")
|
86
|
-
xml.
|
87
|
-
xml.Type do
|
88
|
-
xml.Text("Start date")
|
89
|
-
end
|
90
|
-
#time
|
91
|
-
xml.ExactDateTime(convert_to_ccr_time_string(condition.time))
|
92
|
-
end
|
87
|
+
to_ccr_date(xml, condition.as_point_in_time, "Start date")
|
93
88
|
xml.Type do
|
94
89
|
#TODO: Need to fix this and not be a hard-coded value
|
95
90
|
xml.Text("Diagnosis")
|
@@ -114,13 +109,7 @@ module HealthDataStandards
|
|
114
109
|
patient.encounters.each_with_index do |encounter, index|
|
115
110
|
xml.Encounter do
|
116
111
|
xml.CCRDataObjectID("EN000#{index + 1}")
|
117
|
-
xml.
|
118
|
-
xml.Type do
|
119
|
-
xml.Text("Encounter Date")
|
120
|
-
end
|
121
|
-
#time
|
122
|
-
xml.ExactDateTime(convert_to_ccr_time_string(encounter.time))
|
123
|
-
end
|
112
|
+
to_ccr_date(xml, encounter.as_point_in_time, "Encounter Date")
|
124
113
|
xml.Description do
|
125
114
|
xml.Text(encounter.description)
|
126
115
|
code_section(xml, encounter.codes)
|
@@ -163,14 +152,7 @@ module HealthDataStandards
|
|
163
152
|
def to_result(xml, res, ccr_id )
|
164
153
|
xml.Result do
|
165
154
|
xml.CCRDataObjectID(ccr_id)
|
166
|
-
xml.
|
167
|
-
xml.Type do
|
168
|
-
xml.Text("Start date")
|
169
|
-
end
|
170
|
-
#time
|
171
|
-
xml.ExactDateTime(convert_to_ccr_time_string(res.time))
|
172
|
-
end
|
173
|
-
|
155
|
+
to_ccr_date(xml, res.as_point_in_time, "Start date")
|
174
156
|
xml.Source
|
175
157
|
xml.Test do
|
176
158
|
xml.CCRDataObjectID("#{ccr_id}TestResult")
|
@@ -200,13 +182,7 @@ module HealthDataStandards
|
|
200
182
|
patient.medications.each_with_index do |medication, index|
|
201
183
|
xml.Medication do
|
202
184
|
xml.CCRDataObjectID("MD000#{index + 1}")
|
203
|
-
xml.
|
204
|
-
xml.Type do
|
205
|
-
xml.Text("Prescription Date")
|
206
|
-
end
|
207
|
-
#time
|
208
|
-
xml.ExactDateTime(convert_to_ccr_time_string(medication.time))
|
209
|
-
end
|
185
|
+
to_ccr_date(xml, medication.as_point_in_time, "Prescription Date")
|
210
186
|
xml.Type do
|
211
187
|
xml.Text("Medication")
|
212
188
|
end
|
@@ -235,13 +211,7 @@ module HealthDataStandards
|
|
235
211
|
patient.immunizations.each_with_index do |immunization, index|
|
236
212
|
xml.Immunization do
|
237
213
|
xml.CCRDataObjectID("IM000#{index + 1}")
|
238
|
-
xml.
|
239
|
-
xml.Type do
|
240
|
-
xml.Text("Prescription Date")
|
241
|
-
end
|
242
|
-
#time
|
243
|
-
xml.ExactDateTime(convert_to_ccr_time_string(immunization.time))
|
244
|
-
end
|
214
|
+
to_ccr_date(xml, immunization.as_point_in_time, "Prescription Date")
|
245
215
|
xml.Type do
|
246
216
|
xml.Text("Immunization")
|
247
217
|
end
|
@@ -272,13 +242,7 @@ module HealthDataStandards
|
|
272
242
|
patient.procedures.each_with_index do |procedure, index|
|
273
243
|
xml.Procedure do
|
274
244
|
xml.CCRDataObjectID("PR000#{index + 1}")
|
275
|
-
xml.
|
276
|
-
xml.Type do
|
277
|
-
xml.Text("Service date")
|
278
|
-
end
|
279
|
-
#time
|
280
|
-
xml.ExactDateTime(convert_to_ccr_time_string(procedure.time))
|
281
|
-
end
|
245
|
+
to_ccr_date(xml, procedure.as_point_in_time, "Service date")
|
282
246
|
xml.Description do
|
283
247
|
xml.Text(procedure.description)
|
284
248
|
code_section(xml, procedure.codes)
|
@@ -299,13 +263,7 @@ module HealthDataStandards
|
|
299
263
|
patient.allergies.each_with_index do |allergy, index|
|
300
264
|
xml.Alert do
|
301
265
|
xml.CCRDataObjectID("AL000#{index + 1}")
|
302
|
-
xml.
|
303
|
-
xml.Type do
|
304
|
-
xml.Text("Initial Occurrence")
|
305
|
-
end
|
306
|
-
#time
|
307
|
-
xml.ExactDateTime(convert_to_ccr_time_string(allergy.time))
|
308
|
-
end
|
266
|
+
to_ccr_date(xml, allergy.as_point_in_time, "Initial Occurrence")
|
309
267
|
xml.Type do
|
310
268
|
xml.Text("Allergy")
|
311
269
|
end
|
@@ -339,9 +297,38 @@ module HealthDataStandards
|
|
339
297
|
code_section(xml, history.codes)
|
340
298
|
end
|
341
299
|
|
342
|
-
|
300
|
+
xml.Source
|
343
301
|
end
|
344
302
|
end
|
303
|
+
|
304
|
+
if patient.race
|
305
|
+
xml.SocialHistoryElement do
|
306
|
+
xml.CCRDataObjectID("SH000RACE")
|
307
|
+
xml.Type do
|
308
|
+
xml.Text("Race")
|
309
|
+
end
|
310
|
+
xml.Description do
|
311
|
+
|
312
|
+
code_section(xml, {"2.16.840.1.113883.6.238"=>[patient.race["code"]]})
|
313
|
+
end
|
314
|
+
xml.Source
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
if patient.ethnicity
|
319
|
+
xml.SocialHistoryElement do
|
320
|
+
xml.CCRDataObjectID("SH000ETHICITY")
|
321
|
+
xml.Type do
|
322
|
+
xml.Text("Ethnicity")
|
323
|
+
end
|
324
|
+
xml.Description do
|
325
|
+
|
326
|
+
code_section(xml, {"2.16.840.1.113883.6.238" => [patient.ethnicity["code"]]})
|
327
|
+
end
|
328
|
+
xml.Source
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
345
332
|
end
|
346
333
|
end
|
347
334
|
end
|
@@ -404,8 +391,20 @@ module HealthDataStandards
|
|
404
391
|
end
|
405
392
|
|
406
393
|
def convert_to_ccr_time_string(time)
|
407
|
-
|
408
|
-
|
394
|
+
converted_time = Time.at(time)
|
395
|
+
converted_time.strftime("%Y-%m-%dT%H:%M:%SZ")
|
396
|
+
end
|
397
|
+
|
398
|
+
def to_ccr_date(xml, time, type)
|
399
|
+
if time
|
400
|
+
xml.DateTime do
|
401
|
+
xml.Type do
|
402
|
+
xml.Text(type)
|
403
|
+
end
|
404
|
+
#time
|
405
|
+
xml.ExactDateTime(convert_to_ccr_time_string(time))
|
406
|
+
end
|
407
|
+
end
|
409
408
|
end
|
410
409
|
|
411
410
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module HealthDataStandards
|
2
|
+
module Export
|
3
|
+
module Hdata
|
4
|
+
module Metadata
|
5
|
+
include TemplateHelper
|
6
|
+
|
7
|
+
def export(entry, metadata)
|
8
|
+
self.template_format = "hdata"
|
9
|
+
render(:template => 'metadata', :locals => {entry: entry, metadata: metadata})
|
10
|
+
end
|
11
|
+
|
12
|
+
extend self
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module HealthDataStandards
|
2
|
+
module Export
|
3
|
+
module HTML
|
4
|
+
include TemplateHelper
|
5
|
+
|
6
|
+
def export(patient)
|
7
|
+
self.template_format = "html"
|
8
|
+
render(:template => 'show', :locals => {:patient => patient})
|
9
|
+
end
|
10
|
+
|
11
|
+
extend self
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -14,6 +14,8 @@ module HealthDataStandards
|
|
14
14
|
def partial(partial_name)
|
15
15
|
template("_#{partial_name}")
|
16
16
|
end
|
17
|
+
|
18
|
+
|
17
19
|
|
18
20
|
def render(params)
|
19
21
|
erb = nil
|
@@ -22,6 +24,7 @@ module HealthDataStandards
|
|
22
24
|
elsif params[:partial]
|
23
25
|
erb = partial(params[:partial])
|
24
26
|
end
|
27
|
+
|
25
28
|
locals = params[:locals]
|
26
29
|
locals ||= {}
|
27
30
|
rendering_context = RenderingContext.new(locals)
|
@@ -3,24 +3,30 @@ module HealthDataStandards
|
|
3
3
|
module ViewHelper
|
4
4
|
def code_display(entry, options={})
|
5
5
|
options['tag_name'] ||= 'code'
|
6
|
+
options['attribute'] ||= :codes
|
6
7
|
code_string = nil
|
7
|
-
preferred_code = entry.preferred_code(options['preferred_code_sets'])
|
8
|
+
preferred_code = entry.preferred_code(options['preferred_code_sets'], options['attribute'])
|
8
9
|
if preferred_code
|
9
10
|
code_system_oid = HealthDataStandards::Util::CodeSystemHelper.oid_for_code_system(preferred_code['code_set'])
|
10
11
|
code_string = "<#{options['tag_name']} code=\"#{preferred_code['code']}\" codeSystem=\"#{code_system_oid}\" #{options['extra_content']}>"
|
11
12
|
else
|
12
13
|
code_string = "<#{options['tag_name']} nullFlavor=\"UNK\" #{options['extra_content']}>"
|
13
14
|
end
|
14
|
-
|
15
|
-
entry.
|
16
|
-
|
15
|
+
|
16
|
+
code_string += "<originalText>#{ERB::Util.html_escape entry.description}</originalText>" if entry.respond_to?(:description)
|
17
|
+
|
18
|
+
if entry.respond_to?(:translation_codes)
|
19
|
+
entry.translation_codes(options['preferred_code_sets']).each do |translation|
|
20
|
+
code_string += "<translation code=\"#{translation['code']}\" codeSystem=\"#{HealthDataStandards::Util::CodeSystemHelper.oid_for_code_system(translation['code_set'])}\"/>\n"
|
21
|
+
end
|
17
22
|
end
|
23
|
+
|
18
24
|
code_string += "</#{options['tag_name']}>"
|
19
25
|
code_string
|
20
26
|
end
|
21
27
|
|
22
28
|
def status_code_for(entry)
|
23
|
-
case entry.status.to_s
|
29
|
+
case entry.status.to_s.downcase
|
24
30
|
when 'active'
|
25
31
|
'55561003'
|
26
32
|
when 'inactive'
|
@@ -29,6 +35,24 @@ module HealthDataStandards
|
|
29
35
|
'413322009'
|
30
36
|
end
|
31
37
|
end
|
38
|
+
|
39
|
+
def value_or_null_flavor(time)
|
40
|
+
if time
|
41
|
+
return "value='#{Time.at(time).utc.to_formatted_s(:number)}'"
|
42
|
+
else
|
43
|
+
return "nullFlavor='UNK'"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def quantity_display(value, tag_name="value")
|
49
|
+
return unless value
|
50
|
+
"<#{tag_name} value=\"#{value['value']}\" units=\"#{value['unit']}\" />"
|
51
|
+
end
|
52
|
+
|
53
|
+
def time_if_not_nil(*args)
|
54
|
+
args.compact.map {|t| Time.at(t)}.first
|
55
|
+
end
|
32
56
|
end
|
33
57
|
end
|
34
58
|
end
|
@@ -4,9 +4,10 @@ module HealthDataStandards
|
|
4
4
|
class ConditionImporter < SectionImporter
|
5
5
|
|
6
6
|
def initialize
|
7
|
-
@entry_xpath = "//cda:
|
8
|
-
@code_xpath = "./cda:
|
9
|
-
@
|
7
|
+
@entry_xpath = "//cda:section[cda:templateId/@root='2.16.840.1.113883.3.88.11.83.103']/cda:entry/cda:act/cda:entryRelationship/cda:observation"
|
8
|
+
@code_xpath = "./cda:value"
|
9
|
+
@status_xpath = "./cda:entryRelationship/cda:observation[cda:templateId/@root='2.16.840.1.113883.10.20.1.50']/cda:value"
|
10
|
+
@description_xpath = "./cda:text/cda:reference[@value]"
|
10
11
|
end
|
11
12
|
|
12
13
|
def create_entries(doc, id_map = {})
|
@@ -19,47 +20,44 @@ module HealthDataStandards
|
|
19
20
|
|
20
21
|
extract_codes(entry_element, condition)
|
21
22
|
extract_dates(entry_element, condition)
|
23
|
+
extract_status(entry_element, condition)
|
22
24
|
extract_description(entry_element, condition, id_map)
|
23
|
-
|
24
|
-
condition.diagnosis_priority = extract_code(entry_element, "???")
|
25
|
-
|
26
|
-
condition.problem_date = extract_code(entry_element,
|
27
|
-
"./cda:entryRelationship[@typeCode='SUBJ']/cda:observation[@classCode='OBS']/cda.effectiveTime")
|
28
|
-
|
29
|
-
condition.problem_type = extract_code(entry_element,
|
30
|
-
"./cda:entryRelationship[@typeCode='SUBJ']/cda:observation[@classCode='OBS']")
|
31
|
-
|
32
|
-
condition.problem_name = extract_code(entry_element, "./cda:text")
|
33
|
-
|
34
|
-
condition.problem_code = extract_code(entry_element,
|
35
|
-
"./cda:entryRelationship[@typeCode='SUBJ']/cda:observation[@classCode='OBS']/cda:code[@code='11450-4']/cda:value[@codeSystem='2.16.840.1.113883.96']")
|
36
|
-
|
37
|
-
condition.age_at_onset = extract_code(entry_element, "???")
|
38
|
-
|
39
25
|
extract_cause_of_death(entry_element, condition)
|
40
|
-
|
41
|
-
|
42
|
-
|
26
|
+
extract_type(entry_element, condition)
|
27
|
+
|
28
|
+
entry_element.xpath("./cda:act[cda:templateId/@root='2.16.840.1.113883.10.20.1.27']/cda:performer").each do |provider_element|
|
29
|
+
condition.treating_provider < import_actor(provider_element)
|
30
|
+
end
|
43
31
|
|
44
32
|
condition_list << condition
|
45
33
|
end
|
46
34
|
|
47
35
|
condition_list
|
48
36
|
end
|
49
|
-
|
37
|
+
|
50
38
|
private
|
51
|
-
|
52
|
-
def extract_cause_of_death(
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
39
|
+
|
40
|
+
def extract_cause_of_death(entry_element, condition)
|
41
|
+
cod = entry_element.at_xpath("./cda:entryRelationship[@typeCode='CAUS']/cda:observation/cda:code[@code='419620001']")
|
42
|
+
condition.cause_of_death = cod.present?
|
43
|
+
end
|
44
|
+
|
45
|
+
def extract_type(entry_element, condition)
|
46
|
+
code_element = entry_element.at_xpath('./cda:code')
|
47
|
+
if code_element
|
48
|
+
condition.type = case code_element['code']
|
49
|
+
when '404684003' then 'Finding'
|
50
|
+
when '418799008' then 'Symptom'
|
51
|
+
when '55607006' then 'Problem'
|
52
|
+
when '409586006' then 'Complaint'
|
53
|
+
when '64572001' then 'Condition'
|
54
|
+
when '282291009' then 'Diagnosis'
|
55
|
+
when '248536006' then 'Functional limitation'
|
56
|
+
else nil
|
57
|
+
end
|
60
58
|
end
|
61
59
|
end
|
62
|
-
|
60
|
+
|
63
61
|
end
|
64
62
|
end
|
65
63
|
end
|