health-data-standards 3.5.3 → 3.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -3
  3. data/README.md +10 -2
  4. data/lib/health-data-standards.rb +5 -28
  5. data/lib/health-data-standards/export/cat_1.rb +3 -2
  6. data/lib/health-data-standards/export/cat_1_r2.rb +11 -0
  7. data/lib/health-data-standards/ext/node.rb +1 -2
  8. data/lib/health-data-standards/import/bulk_record_importer.rb +4 -4
  9. data/lib/health-data-standards/import/bundle/importer.rb +62 -0
  10. data/lib/health-data-standards/import/c32/insurance_provider_importer.rb +10 -8
  11. data/lib/health-data-standards/import/cat1/patient_importer.rb +3 -3
  12. data/lib/health-data-standards/import/cat1/procedure_importer.rb +42 -0
  13. data/lib/health-data-standards/import/cda/medication_importer.rb +11 -11
  14. data/lib/health-data-standards/import/cda/section_importer.rb +13 -7
  15. data/lib/health-data-standards/models/cqm/aggregate_objects.rb +5 -1
  16. data/lib/health-data-standards/models/cqm/bundle.rb +5 -3
  17. data/lib/health-data-standards/models/cqm/measure.rb +1 -1
  18. data/lib/health-data-standards/models/entry.rb +5 -1
  19. data/lib/health-data-standards/models/record.rb +10 -0
  20. data/lib/health-data-standards/models/reference.rb +23 -0
  21. data/lib/health-data-standards/models/svs/value_set.rb +4 -3
  22. data/lib/health-data-standards/railtie.rb +1 -1
  23. data/lib/health-data-standards/tasks.rb +1 -0
  24. data/lib/health-data-standards/tasks/bundle.rake +84 -2
  25. data/lib/health-data-standards/util/vs_api.rb +40 -7
  26. data/lib/health-data-standards/validate/base_validator.rb +23 -0
  27. data/lib/health-data-standards/validate/data_validator.rb +85 -0
  28. data/lib/health-data-standards/validate/measure_validator.rb +127 -0
  29. data/lib/health-data-standards/validate/performance_rate_validator.rb +94 -0
  30. data/lib/health-data-standards/validate/reported_result_extractor.rb +170 -0
  31. data/lib/health-data-standards/validate/schema_validator.rb +24 -0
  32. data/lib/health-data-standards/validate/schematron/c_processor.rb +28 -0
  33. data/lib/health-data-standards/validate/schematron/java_processor.rb +93 -0
  34. data/lib/health-data-standards/validate/schematron_validator.rb +34 -0
  35. data/lib/health-data-standards/validate/validation_error.rb +10 -0
  36. data/lib/health-data-standards/validate/validators.rb +80 -0
  37. data/lib/hqmf-generator/fulfills.xml.erb +7 -0
  38. data/lib/hqmf-generator/hqmf-generator.rb +8 -3
  39. data/lib/hqmf-model/data_criteria.rb +3 -0
  40. data/lib/hqmf-model/types.rb +29 -0
  41. data/lib/hqmf-parser/2.0/data_criteria.rb +7 -0
  42. data/lib/hqmf-parser/2.0/types.rb +24 -0
  43. data/resources/schema/infrastructure/cda/CDA_SDTC.xsd +44 -0
  44. data/resources/schema/infrastructure/cda/POCD_MT000040_SDTC.xsd +1500 -0
  45. data/resources/schema/infrastructure/cda/SDTC.xsd +210 -0
  46. data/resources/schema/processable/coreschemas/NarrativeBlock.xsd +557 -0
  47. data/resources/schema/processable/coreschemas/datatypes-base_SDTC.xsd +1850 -0
  48. data/resources/schema/processable/coreschemas/datatypes.xsd +1375 -0
  49. data/resources/schema/processable/coreschemas/infrastructureRoot.xsd +27 -0
  50. data/resources/schema/processable/coreschemas/voc.xsd +2124 -0
  51. data/resources/schematron/iso-schematron-xslt1/ExtractSchFromRNG.xsl +75 -0
  52. data/resources/schematron/iso-schematron-xslt1/ExtractSchFromXSD.xsl +77 -0
  53. data/resources/schematron/iso-schematron-xslt1/iso_abstract_expand.xsl +297 -0
  54. data/resources/schematron/iso-schematron-xslt1/iso_dsdl_include.xsl +1509 -0
  55. data/resources/schematron/iso-schematron-xslt1/iso_schematron_message.xsl +55 -0
  56. data/resources/schematron/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl +1844 -0
  57. data/resources/schematron/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl +605 -0
  58. data/resources/schematron/iso-schematron-xslt1/readme.txt +101 -0
  59. data/resources/schematron/iso-schematron-xslt1/schematron-skeleton-api.htm +723 -0
  60. data/resources/schematron/iso-schematron-xslt2/ExtractSchFromRNG-2.xsl +75 -0
  61. data/resources/schematron/iso-schematron-xslt2/ExtractSchFromXSD-2.xsl +77 -0
  62. data/resources/schematron/iso-schematron-xslt2/iso_abstract_expand.xsl +297 -0
  63. data/resources/schematron/iso-schematron-xslt2/iso_dsdl_include.xsl +1508 -0
  64. data/resources/schematron/iso-schematron-xslt2/iso_schematron_message_xslt2.xsl +55 -0
  65. data/resources/schematron/iso-schematron-xslt2/iso_schematron_skeleton_for_saxon.xsl +2299 -0
  66. data/resources/schematron/iso-schematron-xslt2/iso_svrl_for_xslt2.xsl +684 -0
  67. data/resources/schematron/iso-schematron-xslt2/readme.txt +100 -0
  68. data/resources/schematron/iso-schematron-xslt2/sch-messages-cs.xhtml +56 -0
  69. data/resources/schematron/iso-schematron-xslt2/sch-messages-de.xhtml +57 -0
  70. data/resources/schematron/iso-schematron-xslt2/sch-messages-en.xhtml +57 -0
  71. data/resources/schematron/iso-schematron-xslt2/sch-messages-fr.xhtml +54 -0
  72. data/resources/schematron/iso-schematron-xslt2/sch-messages-nl.xhtml +58 -0
  73. data/resources/schematron/iso-schematron-xslt2/schematron-skeleton-api.htm +723 -0
  74. data/resources/schematron/qrda/cat_1/CDAR2_QRDA_I_R1_D3_2015MAY_Schematron.sch +4676 -0
  75. data/resources/schematron/qrda/cat_1/voc.xml +1177 -0
  76. data/resources/schematron/qrda/cat_1_r2/QRDA Category I Release 2.sch +4069 -0
  77. data/resources/schematron/qrda/cat_1_r2/voc.xml +1065 -0
  78. data/resources/schematron/qrda/cat_3/QRDA Category III.sch +675 -0
  79. data/resources/schematron/qrda/cat_3/voc.xml +21 -0
  80. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.26.cat1.erb +18 -0
  81. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.32.cat1.erb +4 -0
  82. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.38.cat1.erb +5 -1
  83. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.4.cat1.erb +1 -0
  84. data/templates/cat1/_2.16.840.1.113883.10.20.24.3.64.cat1.erb +20 -0
  85. data/templates/cat1/_fulfills.cat1.erb +14 -0
  86. data/templates/cat1/_organization.cat1.erb +2 -1
  87. data/templates/cat1/_patient_data.cat1.erb +1 -1
  88. data/templates/cat1/show.cat1.erb +5 -4
  89. data/templates/cat3/_performance_rate.cat3.erb +5 -1
  90. data/templates/cat3/show.cat3.erb +1 -1
  91. metadata +128 -109
  92. data/lib/health-data-standards/export/ccr.rb +0 -417
  93. data/lib/health-data-standards/export/green_c32/entry.rb +0 -18
  94. data/lib/health-data-standards/export/green_c32/export_generator.rb +0 -23
  95. data/lib/health-data-standards/export/green_c32/record.rb +0 -18
  96. data/lib/health-data-standards/export/helper/gc32_view_helper.rb +0 -39
  97. data/lib/health-data-standards/import/ccr/patient_importer.rb +0 -238
  98. data/lib/health-data-standards/import/ccr/product_importer.rb +0 -60
  99. data/lib/health-data-standards/import/ccr/provider_importer.rb +0 -49
  100. data/lib/health-data-standards/import/ccr/result_importer.rb +0 -49
  101. data/lib/health-data-standards/import/ccr/section_importer.rb +0 -135
  102. data/lib/health-data-standards/import/ccr/simple_importer.rb +0 -30
  103. data/lib/health-data-standards/import/green_c32/advance_directive_importer.rb +0 -14
  104. data/lib/health-data-standards/import/green_c32/allergy_importer.rb +0 -20
  105. data/lib/health-data-standards/import/green_c32/care_goal_importer.rb +0 -26
  106. data/lib/health-data-standards/import/green_c32/condition_importer.rb +0 -38
  107. data/lib/health-data-standards/import/green_c32/encounter_importer.rb +0 -33
  108. data/lib/health-data-standards/import/green_c32/immunization_importer.rb +0 -23
  109. data/lib/health-data-standards/import/green_c32/medical_equipment_importer.rb +0 -24
  110. data/lib/health-data-standards/import/green_c32/medication_importer.rb +0 -68
  111. data/lib/health-data-standards/import/green_c32/patient_importer.rb +0 -14
  112. data/lib/health-data-standards/import/green_c32/procedure_importer.rb +0 -27
  113. data/lib/health-data-standards/import/green_c32/result_importer.rb +0 -43
  114. data/lib/health-data-standards/import/green_c32/section_importer.rb +0 -186
  115. data/lib/health-data-standards/import/green_c32/social_history_importer.rb +0 -13
  116. data/lib/health-data-standards/import/green_c32/support_importer.rb +0 -22
  117. data/lib/health-data-standards/import/green_c32/vital_sign_importer.rb +0 -21
  118. data/templates/gc32/_address.gc32.erb +0 -9
  119. data/templates/gc32/_advance_directive.gc32.erb +0 -5
  120. data/templates/gc32/_allergy.gc32.erb +0 -12
  121. data/templates/gc32/_care_goal.gc32.erb +0 -8
  122. data/templates/gc32/_condition.gc32.erb +0 -10
  123. data/templates/gc32/_encounter.gc32.erb +0 -28
  124. data/templates/gc32/_entry.gc32.erb +0 -3
  125. data/templates/gc32/_entry_attributes.gc32.erb +0 -10
  126. data/templates/gc32/_immunization.gc32.erb +0 -9
  127. data/templates/gc32/_insurance_provider.gc32.erb +0 -28
  128. data/templates/gc32/_medical_equipment.gc32.erb +0 -6
  129. data/templates/gc32/_medication.gc32.erb +0 -91
  130. data/templates/gc32/_name.gc32.erb +0 -11
  131. data/templates/gc32/_organization.gc32.erb +0 -10
  132. data/templates/gc32/_person_attributes.gc32.erb +0 -7
  133. data/templates/gc32/_procedure.gc32.erb +0 -9
  134. data/templates/gc32/_provider.gc32.erb +0 -9
  135. data/templates/gc32/_result.gc32.erb +0 -12
  136. data/templates/gc32/_social_history.gc32.erb +0 -6
  137. data/templates/gc32/_support.gc32.erb +0 -15
  138. data/templates/gc32/_telecom.gc32.erb +0 -1
  139. data/templates/gc32/_vital_sign.gc32.erb +0 -4
  140. data/templates/gc32/record.gc32.erb +0 -97
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f28260b9a20c4a5fa03677dbde72935d0779e1b7
4
- data.tar.gz: 758234c177f32a11c9606258a38bf83387fe2fb9
3
+ metadata.gz: 59b91fc289603c22a9152c776bebee15f193f70e
4
+ data.tar.gz: cde5d51f408a2eb237bd1ed632a2383936bc5631
5
5
  SHA512:
6
- metadata.gz: 03f1f77b7b63a7ca367c477dda130c115b8df7ecc2128aab02265c405f0db8b96696b3d09a15cb4f1ae59862142e8268d7900abc2e150d4c71ff9932a4f0dc61
7
- data.tar.gz: 79d88e0eecd99eddd931977ced5974969a2afee8ae74665721b0740013247183c86bbf75e376891d9427789f56d1a731e3c656631ae1bde4e16ea25095e65500
6
+ metadata.gz: 031ae5473fe9cdb09819c2ee91ca3570fc7e2aa06e720abc3e61cd34bc96b8f32a03279f715eb3ecbd292ff935cdded1fef4b6399dcbcd10e1f9627192c8705a
7
+ data.tar.gz: 9df5f732d24fc1f85232e13debff907f2afb82d41850301d865279b3a185bd984cc0806b1673005e4a0fd16705b3d96b2080921c4dadcd4bb3ecf3443c0268b1
data/Gemfile CHANGED
@@ -1,12 +1,11 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec :development_group => :test
4
4
 
5
5
  group :development do
6
6
  gem 'rake'
7
7
  gem 'pry', '~> 0.9.10'
8
- gem 'pry-nav', '~> 0.2.2'
9
-
8
+ gem 'pry-nav', '~> 0.2.2', platforms: [:ruby_21, :ruby_22]
10
9
  end
11
10
 
12
11
  group :test do
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- This is a project to generate and consume HITSP C32, ASTM CCR, QRDA Category I, QRDA Category III and PQRI.
1
+ This is a project to generate and consume HITSP C32, QRDA Category I, and QRDA Category III.
2
2
 
3
3
  In addition this project also contains libraries for parsing HQMF documents and for dealing with NLM valuesets.
4
4
 
5
5
  Environment
6
6
  ===========
7
7
 
8
- This project currently uses Ruby 1.9.3, Ruby 2.0.0, Ruby 2.1.1 and JRuby 1.7.11 and is built using [Bundler](http://gembundler.com/). To get all of the dependencies for the project, first install bundler:
8
+ This project currently uses Ruby 2.0.0, Ruby 2.1.1, Ruby 2.2.1, and JRuby 1.7.11 and is built using [Bundler](http://gembundler.com/). To get all of the dependencies for the project, first install bundler:
9
9
 
10
10
  gem install bundler
11
11
 
@@ -29,6 +29,14 @@ Change Log
29
29
 
30
30
  * Upgrading to mongoid 4
31
31
 
32
+ * 3.6.0
33
+
34
+ * Support for QRDA Cat I R3
35
+ * Additional validators for QRDA Cat I/III
36
+ * Removed GC32 & CCR code
37
+ * Support latest QDM changes
38
+ * Additional support for running in JRuby
39
+
32
40
  3.5.3 - January 20, 2015
33
41
 
34
42
  * Support for 2014 QRDA Errata Release
@@ -26,15 +26,9 @@ require_relative 'health-data-standards/export/view_helper'
26
26
  require_relative 'health-data-standards/export/rendering_context'
27
27
  require_relative 'health-data-standards/export/c32'
28
28
  require_relative 'health-data-standards/export/ccda'
29
- require_relative 'health-data-standards/export/ccr'
30
29
  require_relative 'health-data-standards/export/csv'
31
30
  require_relative 'health-data-standards/export/hdata/metadata'
32
31
 
33
- require_relative 'health-data-standards/export/helper/gc32_view_helper'
34
- require_relative 'health-data-standards/export/green_c32/record'
35
- require_relative 'health-data-standards/export/green_c32/entry'
36
- require_relative 'health-data-standards/export/green_c32/export_generator'
37
-
38
32
  require_relative 'health-data-standards/import/provider_import_utils'
39
33
  require_relative 'health-data-standards/import/hdata/metadata_importer'
40
34
 
@@ -43,6 +37,7 @@ require_relative 'health-data-standards/models/result_value'
43
37
  require_relative 'health-data-standards/models/coded_result_value'
44
38
  require_relative 'health-data-standards/models/physical_quantity_result_value'
45
39
  require_relative 'health-data-standards/models/cda_identifier'
40
+ require_relative 'health-data-standards/models/reference'
46
41
  require_relative 'health-data-standards/models/entry'
47
42
  require_relative 'health-data-standards/models/allergy'
48
43
  require_relative 'health-data-standards/models/encounter'
@@ -99,6 +94,7 @@ require_relative 'health-data-standards/export/helper/html_view_helper'
99
94
  require_relative 'health-data-standards/export/html'
100
95
  require_relative 'health-data-standards/export/helper/cat1_view_helper'
101
96
  require_relative 'health-data-standards/export/cat_1'
97
+ require_relative 'health-data-standards/export/cat_1_r2'
102
98
  require_relative 'health-data-standards/export/cat_3'
103
99
 
104
100
  require_relative 'health-data-standards/import/cda/narrative_reference_handler'
@@ -122,13 +118,6 @@ require_relative 'health-data-standards/import/c32/patient_importer'
122
118
  require_relative 'health-data-standards/import/c32/insurance_provider_importer'
123
119
  require_relative 'health-data-standards/import/c32/care_goal_importer'
124
120
 
125
- require_relative 'health-data-standards/import/ccr/patient_importer'
126
- require_relative 'health-data-standards/import/ccr/provider_importer'
127
- require_relative 'health-data-standards/import/ccr/section_importer'
128
- require_relative 'health-data-standards/import/ccr/result_importer'
129
- require_relative 'health-data-standards/import/ccr/simple_importer'
130
- require_relative 'health-data-standards/import/ccr/product_importer'
131
-
132
121
  require_relative 'health-data-standards/import/ccda/patient_importer'
133
122
  require_relative 'health-data-standards/import/ccda/allergy_importer'
134
123
  require_relative 'health-data-standards/import/ccda/condition_importer'
@@ -142,21 +131,6 @@ require_relative 'health-data-standards/import/ccda/care_goal_importer'
142
131
  require_relative 'health-data-standards/import/ccda/medical_equipment_importer'
143
132
  require_relative 'health-data-standards/import/ccda/insurance_provider_importer'
144
133
 
145
- require_relative 'health-data-standards/import/green_c32/section_importer'
146
- require_relative 'health-data-standards/import/green_c32/result_importer'
147
- require_relative 'health-data-standards/import/green_c32/condition_importer'
148
- require_relative 'health-data-standards/import/green_c32/vital_sign_importer'
149
- require_relative 'health-data-standards/import/green_c32/procedure_importer'
150
- require_relative 'health-data-standards/import/green_c32/encounter_importer'
151
- require_relative 'health-data-standards/import/green_c32/medication_importer'
152
- require_relative 'health-data-standards/import/green_c32/allergy_importer'
153
- require_relative 'health-data-standards/import/green_c32/social_history_importer'
154
- require_relative 'health-data-standards/import/green_c32/immunization_importer'
155
- require_relative 'health-data-standards/import/green_c32/support_importer'
156
- require_relative 'health-data-standards/import/green_c32/advance_directive_importer'
157
- require_relative 'health-data-standards/import/green_c32/medical_equipment_importer'
158
- require_relative 'health-data-standards/import/green_c32/care_goal_importer'
159
-
160
134
  require_relative 'health-data-standards/import/cat1/gestational_age_importer'
161
135
  require_relative 'health-data-standards/import/cat1/procedure_intolerance_importer'
162
136
  require_relative 'health-data-standards/import/cat1/procedure_performed_importer'
@@ -176,11 +150,14 @@ require_relative 'health-data-standards/import/cat1/lab_result_importer'
176
150
  require_relative 'health-data-standards/import/cat1/ecog_status_importer'
177
151
  require_relative 'health-data-standards/import/cat1/symptom_active_importer'
178
152
  require_relative 'health-data-standards/import/cat1/insurance_provider_importer'
153
+ require_relative 'health-data-standards/import/cat1/procedure_importer'
179
154
 
180
155
  require_relative 'health-data-standards/import/bundle/importer'
181
156
 
182
157
  require_relative 'health-data-standards/import/bulk_record_importer'
183
158
 
159
+ require_relative 'health-data-standards/validate/validators'
160
+
184
161
  module HealthDataStandards
185
162
  class << self
186
163
  attr_accessor :logger
@@ -9,9 +9,10 @@ module HealthDataStandards
9
9
  end
10
10
 
11
11
  @@vs_map = nil
12
- def export(patient, measures, start_date, end_date, header=nil)
12
+ def export(patient, measures, start_date, end_date, header=nil, r2_compatibility=false)
13
13
  @rendering_context.render(:template => 'show', :locals => {:patient => patient, :measures => measures,
14
- :start_date => start_date, :end_date => end_date, :header => header})
14
+ :start_date => start_date, :end_date => end_date, :header => header,
15
+ :r2_compatibility => r2_compatibility})
15
16
  end
16
17
  end
17
18
  end
@@ -0,0 +1,11 @@
1
+ # require_relative 'cat_1'
2
+
3
+ module HealthDataStandards
4
+ module Export
5
+ class Cat1R2 < Cat1
6
+ def export(patient, measures, start_date, end_date, header=nil, r2_compatibiliy=true)
7
+ super(patient, measures, start_date, end_date, header, r2_compatibiliy)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -10,7 +10,6 @@ if RUBY_PLATFORM.include?('java')
10
10
  NAMESPACES = {'cda' => 'urn:hl7-org:v3',
11
11
  'sdtc' => 'urn:hl7-org:sdtc',
12
12
  'gc32' => 'urn:hl7-org:greencda:c32',
13
- 'ccr' => 'urn:astm-org:CCR',
14
13
  'vs' => 'urn:ihe:iti:svs:2008',
15
14
  'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
16
15
  'hrf-md' => 'http://www.hl7.org/schemas/hdata/2009/11/metadata',
@@ -43,4 +42,4 @@ if RUBY_PLATFORM.include?('java')
43
42
  end
44
43
  end
45
44
  end
46
- end
45
+ end
@@ -7,7 +7,7 @@ module HealthDataStandards
7
7
  failed_dir ||= File.join(source_dir, '../', 'failed_imports')
8
8
  files = Dir.glob(File.join(source_dir, '*.*'))
9
9
  files.each do |file|
10
- BulkRecordImporter.import_file(file,File.new(file).read,failed_dir)
10
+ self.import_file(file,File.new(file).read,failed_dir)
11
11
  end
12
12
  end
13
13
 
@@ -27,7 +27,7 @@ module HealthDataStandards
27
27
  end
28
28
  next if entry.directory?
29
29
  data = zipfile.read(entry.name)
30
- BulkRecordImporter.import_file(entry.name,data,failed_dir)
30
+ self.import_file(entry.name,data,failed_dir)
31
31
  end
32
32
  end
33
33
 
@@ -60,9 +60,9 @@ module HealthDataStandards
60
60
  begin
61
61
  ext = File.extname(name)
62
62
  if ext == ".json"
63
- BulkRecordImporter.import_json(data)
63
+ self.import_json(data)
64
64
  else
65
- BulkRecordImporter.import(data)
65
+ self.import(data)
66
66
  end
67
67
  rescue
68
68
  FileUtils.mkdir_p(File.dirname(File.join(failed_dir,name)))
@@ -132,12 +132,74 @@ module HealthDataStandards
132
132
  entries.each_with_index do |entry, index|
133
133
  patient = Record.new(unpack_json(entry))
134
134
  patient['bundle_id'] = bundle.id
135
+
136
+ #index
137
+ source_data_with_references = Array.new
138
+ source_data_reference_id_hash = Hash.new
139
+ source_data_id_hash = Hash.new
140
+ index = 0
141
+ #loops through source data criteria, if there are references adds ids to hash
142
+ patient['source_data_criteria'].each do |data_criteria|
143
+ source_data_id_hash[data_criteria['criteria_id']] = index
144
+ if data_criteria['references'] != nil
145
+ source_data_with_references.push(index)
146
+ reference_ids = Array.new
147
+ data_criteria['references'].each do |reference|
148
+ reference_ids.push(reference['reference_id'])
149
+ end
150
+ source_data_reference_id_hash[data_criteria['criteria_id']] = reference_ids
151
+ end
152
+ index = index + 1
153
+ end
154
+ #if there are references, id references are reestablished
155
+ if source_data_with_references.size > 0
156
+ reconnect_references(patient, source_data_with_references, source_data_reference_id_hash, source_data_id_hash)
157
+ end
135
158
  patient.save
136
159
  report_progress('patients', (index*100/entries.length)) if index%10 == 0
137
160
  end
138
161
  puts "\rLoading: Patients Complete "
139
162
  end
140
163
 
164
+ #bit of a hack here, equality is made by date and codes
165
+ def self.compare_and_update_entries(patient, reference_id, start_date, end_date, codes)
166
+ patient.entries.each do |entry|
167
+ # if dates and codes match then replace id with original
168
+ if compare_dates(entry, start_date, end_date)
169
+ if entry.codes == codes
170
+ entry._id = BSON::ObjectId.from_string(reference_id)
171
+ end
172
+ end
173
+ end
174
+ end
175
+
176
+ def self.compare_dates(entry, start_date, end_date)
177
+ if entry.start_time * 1000 == start_date
178
+ if entry.end_time == nil
179
+ if end_date == nil
180
+ return true
181
+ else
182
+ return false
183
+ end
184
+ else entry.end_time * 1000 == end_date
185
+ return true
186
+ end
187
+ end
188
+ return false
189
+ end
190
+
191
+ def self.reconnect_references(patient, source_data_with_references, source_data_reference_id_hash, source_data_id_hash)
192
+
193
+ source_data_with_references.each do |source_data_with_reference|
194
+ #only do this with the references
195
+ sdc = patient['source_data_criteria'][source_data_with_reference]
196
+ source_data_reference_id_hash[sdc['criteria_id']].each do |ref_criteria_id|
197
+ ref_sdc = patient['source_data_criteria'][source_data_id_hash[ref_criteria_id]]
198
+ compare_and_update_entries(patient, ref_sdc['coded_entry_id'],ref_sdc['start_date'],ref_sdc['end_date'],ref_sdc['codes'])
199
+ end
200
+ end
201
+ end
202
+
141
203
  def self.unpack_and_store_valuesets(zip, bundle)
142
204
  entries = zip.glob(SOURCE_ROOTS[:valuesets])
143
205
  entries.each_with_index do |entry, index|
@@ -2,13 +2,13 @@ module HealthDataStandards
2
2
  module Import
3
3
  module C32
4
4
  class InsuranceProviderImporter < CDA::SectionImporter
5
-
5
+
6
6
  def initialize(entry_finder=CDA::EntryFinder.new("//cda:act[cda:templateId/@root='2.16.840.1.113883.10.20.1.26']"))
7
7
  super(entry_finder)
8
8
  @check_for_usable = false # needs to be this way becase InsuranceProvider does not respond
9
9
  # to usable?
10
10
  end
11
-
11
+
12
12
  def create_entry(payer_element, nrh = CDA::NarrativeReferenceHandler.new)
13
13
  ip = InsuranceProvider.new
14
14
  type = extract_code(payer_element, "./cda:code")
@@ -21,25 +21,27 @@ module HealthDataStandards
21
21
  name = payer_element.at_xpath("./cda:entryRelationship[@typeCode='REFR']/cda:act[@classCode='ACT' and @moodCode='DEF']/cda:text")
22
22
  ip.name = name.try(:text)
23
23
  patient_element = member_info_element.at_xpath("./cda:participantRole[@classCode='PAT']")
24
- ip.member_id = patient_element.at_xpath("./cda:id")
25
- ip.relationship = extract_code(patient_element, "./cda:code")
24
+ if patient_element
25
+ ip.member_id = patient_element.at_xpath("./cda:id")
26
+ ip.relationship = extract_code(patient_element, "./cda:code")
27
+ end
26
28
  ip.financial_responsibility_type = extract_code(payer_element, "./cda:performer/cda:assignedEntity/cda:code")
27
29
  ip
28
30
  end
29
-
31
+
30
32
  def extract_guarantors(guarantor_elements)
31
33
  guarantor_elements.map do |guarantor_element|
32
34
  guarantor = Guarantor.new
33
- extract_dates(guarantor_element, guarantor, element_name="time")
35
+ extract_dates(guarantor_element, guarantor, "time")
34
36
  guarantor_entity = guarantor_element.at_xpath("./cda:assignedEntity")
35
37
  guarantor.person = import_person(guarantor_entity.at_xpath("./cda:assignedPerson"))
36
38
  guarantor.organization = import_organization(guarantor_entity.at_xpath("./cda:representedOrganization"))
37
39
  guarantor
38
40
  end
39
41
  end
40
-
42
+
41
43
  end
42
44
  end
43
45
  end
44
-
46
+
45
47
  end
@@ -35,7 +35,7 @@ module HealthDataStandards
35
35
  generate_importer(CDA::ProcedureImporter, "./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.31']", '2.16.840.1.113883.3.560.1.45', 'ordered'), #intervention ordered
36
36
  generate_importer(CDA::ProcedureImporter, "./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.32']", '2.16.840.1.113883.3.560.1.46', 'performed'), #intervention performed
37
37
  generate_importer(CDA::ProcedureImporter, "./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.34']", '2.16.840.1.113883.3.560.1.47'), #intervention result
38
- generate_importer(CDA::ProcedureImporter, "./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.4']", '2.16.840.1.113883.3.560.1.129'), #comm from provider to provider
38
+ generate_importer(Cat1::ProcedureImporter, nil, '2.16.840.1.113883.3.560.1.129'), #comm from provider to provider
39
39
  generate_importer(CDA::ProcedureImporter, "./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.2']", '2.16.840.1.113883.3.560.1.30'), #comm from patient to provider
40
40
  generate_importer(ProcedureOrderImporter, nil, '2.16.840.1.113883.3.560.1.62', 'ordered'),
41
41
  generate_importer(ProcedurePerformedImporter, "./cda:entry/cda:procedure[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.64']", '2.16.840.1.113883.3.560.1.6'),
@@ -56,7 +56,8 @@ module HealthDataStandards
56
56
  generate_importer(CDA::ResultImporter, "./cda:entry/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.38']", '2.16.840.1.113883.3.560.1.5', 'performed'), #lab performed
57
57
  generate_importer(CDA::ResultImporter, "./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.34']", '2.16.840.1.113883.3.560.1.47'), #intervention result
58
58
  generate_importer(CDA::ResultImporter, "./cda:entry/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.57']", '2.16.840.1.113883.3.560.1.18'), #physical exam finding
59
- generate_importer(CDA::ResultImporter, "./cda:entry/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.28']", '2.16.840.1.113883.3.560.1.88'), #functional status result
59
+ generate_importer(CDA::ResultImporter, "./cda:entry/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.28']", '2.16.840.1.113883.3.560.1.88'), #functional status result
60
+ generate_importer(CDA::ResultImporter, "./cda:entry/cda:observation[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.26']", '2.16.840.1.113883.3.560.1.85'), #functional status, performed
60
61
  generate_importer(LabResultImporter, nil, '2.16.840.1.113883.3.560.1.12')] #lab result
61
62
 
62
63
  @section_importers[:encounters] = [generate_importer(EncounterPerformedImporter, "./cda:encounter[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.23']", '2.16.840.1.113883.3.560.1.79', 'performed'), #encounter performed
@@ -85,7 +86,6 @@ module HealthDataStandards
85
86
  nrh.build_id_map(doc)
86
87
  @section_importers.each do |section, entry_packages|
87
88
  entry_packages.each do |entry_package|
88
- # binding.pry if section == :results
89
89
  record.send(section) << entry_package.package_entries(context, nrh)
90
90
  end
91
91
  end
@@ -0,0 +1,42 @@
1
+ module HealthDataStandards
2
+ module Import
3
+ module Cat1
4
+ class ProcedureImporter < CDA::ProcedureImporter
5
+
6
+ def initialize(entry_finder=CDA::EntryFinder.new("./cda:entry/cda:act[cda:templateId/@root = '2.16.840.1.113883.10.20.24.3.4']"))
7
+ super(entry_finder)
8
+ @reference_xpath = "./sdtc:inFulfillmentOf1"
9
+ end
10
+
11
+ def create_entry(entry_element, nrh = CDA::NarrativeReferenceHandler.new)
12
+ procedure = super
13
+ extract_references(entry_element, procedure)
14
+ procedure
15
+ end
16
+
17
+ private
18
+
19
+ def extract_references(parent_element, entry)
20
+ parent_element.xpath(@reference_xpath).each do |ref_xml|
21
+ ref = Reference.new
22
+ ref.type = case ref_xml.at_xpath("./@typeCode").value
23
+ when "FLFS"
24
+ "fulfills"
25
+ end
26
+ ref.referenced_type = case ref_xml.at_xpath("./sdtc:actReference/@classCode").value
27
+ when "ACT"
28
+ "Procedure"
29
+ end
30
+ id_element = ref_xml.at_xpath("./sdtc:actReference/sdtc:id")
31
+ identifier = CDAIdentifier.new
32
+ identifier.root = id_element['root']
33
+ identifier.extension = id_element['extension']
34
+ ref.referenced_id = identifier
35
+ entry.references << ref
36
+ end
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,7 +1,7 @@
1
1
  module HealthDataStandards
2
2
  module Import
3
3
  module CDA
4
-
4
+
5
5
  # TODO: Coded Product Name, Free Text Product Name, Coded Brand Name and Free Text Brand name need to be pulled out separatelty
6
6
  # This would mean overriding extract_codes
7
7
  # TODO: Patient Instructions needs to be implemented. Will likely be a reference to the narrative section
@@ -24,26 +24,26 @@ module HealthDataStandards
24
24
 
25
25
  def create_entry(entry_element, nrh = NarrativeReferenceHandler.new)
26
26
  medication = super
27
-
27
+
28
28
  extract_administration_timing(entry_element, medication)
29
-
29
+
30
30
  medication.route = extract_code(entry_element, "./cda:routeCode")
31
31
  medication.dose = extract_scalar(entry_element, "./cda:doseQuantity")
32
32
  medication.site = extract_code(entry_element, "./cda:approachSiteCode", 'SNOMED-CT')
33
-
33
+
34
34
  extract_dose_restriction(entry_element, medication)
35
-
35
+
36
36
  medication.product_form = extract_code(entry_element, "./cda:administrationUnitCode", 'NCI Thesaurus')
37
37
  medication.delivery_method = extract_code(entry_element, "./cda:code", 'SNOMED-CT')
38
38
  medication.type_of_medication = extract_code(entry_element, @type_of_med_xpath, 'SNOMED-CT') if @type_of_med_xpath
39
39
  medication.indication = extract_code(entry_element, @indication_xpath, 'SNOMED-CT')
40
40
  medication.vehicle = extract_code(entry_element, @vehicle_xpath, 'SNOMED-CT')
41
-
41
+
42
42
  extract_order_information(entry_element, medication)
43
-
43
+
44
44
  extract_fulfillment_history(entry_element, medication)
45
45
  extract_negation(entry_element, medication)
46
-
46
+
47
47
  medication
48
48
  end
49
49
 
@@ -68,20 +68,20 @@ module HealthDataStandards
68
68
  end
69
69
  end
70
70
  end
71
-
71
+
72
72
  def extract_order_information(parent_element, medication)
73
73
  order_elements = parent_element.xpath("./cda:entryRelationship[@typeCode='REFR']/cda:supply[@moodCode='INT']")
74
74
  if order_elements
75
75
  order_elements.each do |order_element|
76
76
  order_information = OrderInformation.new
77
77
  actor_element = order_element.at_xpath('./cda:author')
78
- if actor_element
78
+ if actor_element && Mongoid.configured? # Also make sure we can look up providers
79
79
  order_information.provider = ProviderImporter.instance.extract_provider(actor_element, "assignedAuthor")
80
80
  end
81
81
  order_information.order_number = order_element.at_xpath('./cda:id').try(:[], 'root')
82
82
  order_information.fills = order_element.at_xpath('./cda:repeatNumber').try(:[], 'value').try(:to_i)
83
83
  order_information.quantity_ordered = extract_scalar(order_element, "./cda:quantity")
84
-
84
+
85
85
  medication.orderInformation << order_information
86
86
  end
87
87
  end