health-data-standards 3.4.6 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/Gemfile +2 -2
  2. data/README.md +4 -0
  3. data/lib/health-data-standards.rb +1 -0
  4. data/lib/health-data-standards/export/cat_1.rb +4 -4
  5. data/lib/health-data-standards/export/helper/scooped_view_helper.rb +16 -16
  6. data/lib/health-data-standards/export/qrda/hqmf-qrda-oids.json +6 -0
  7. data/lib/health-data-standards/export/view_helper.rb +8 -1
  8. data/lib/health-data-standards/import/bulk_record_importer.rb +45 -13
  9. data/lib/health-data-standards/import/bundle/importer.rb +2 -4
  10. data/lib/health-data-standards/import/cda/provider_importer.rb +2 -2
  11. data/lib/health-data-standards/import/green_c32/section_importer.rb +2 -2
  12. data/lib/health-data-standards/import/provider_import_utils.rb +2 -2
  13. data/lib/health-data-standards/models/cda_identifier.rb +1 -0
  14. data/lib/health-data-standards/models/cqm/bundle.rb +4 -1
  15. data/lib/health-data-standards/models/cqm/measure.rb +40 -25
  16. data/lib/health-data-standards/models/cqm/patient_cache.rb +61 -60
  17. data/lib/health-data-standards/models/encounter.rb +4 -12
  18. data/lib/health-data-standards/models/entry.rb +4 -8
  19. data/lib/health-data-standards/models/facility.rb +1 -0
  20. data/lib/health-data-standards/models/fulfillment_history.rb +6 -18
  21. data/lib/health-data-standards/models/guarantor.rb +1 -0
  22. data/lib/health-data-standards/models/lab_result.rb +2 -6
  23. data/lib/health-data-standards/models/medical_equipment.rb +2 -7
  24. data/lib/health-data-standards/models/medication.rb +11 -31
  25. data/lib/health-data-standards/models/metadata/link_info.rb +1 -0
  26. data/lib/health-data-standards/models/order_information.rb +5 -13
  27. data/lib/health-data-standards/models/organization.rb +1 -0
  28. data/lib/health-data-standards/models/procedure.rb +1 -4
  29. data/lib/health-data-standards/models/provider.rb +2 -1
  30. data/lib/health-data-standards/models/provider_performance.rb +1 -0
  31. data/lib/health-data-standards/models/qrda/legal_authenticator.rb +1 -0
  32. data/lib/health-data-standards/models/qrda/organization.rb +2 -0
  33. data/lib/health-data-standards/models/record.rb +7 -7
  34. data/lib/health-data-standards/models/result_value.rb +1 -0
  35. data/lib/health-data-standards/models/svs/concept.rb +1 -0
  36. data/lib/health-data-standards/models/svs/value_set.rb +1 -0
  37. data/lib/health-data-standards/models/telecom.rb +1 -0
  38. data/lib/health-data-standards/models/transfer.rb +1 -0
  39. data/lib/health-data-standards/tasks/bundle.rake +3 -3
  40. data/lib/health-data-standards/util/vs_api.rb +2 -2
  41. data/lib/hqmf-generator/attribute.xml.erb +9 -11
  42. data/lib/hqmf-generator/characteristic_criteria.xml.erb +5 -5
  43. data/lib/hqmf-generator/code.xml.erb +6 -2
  44. data/lib/hqmf-generator/condition_criteria.xml.erb +4 -5
  45. data/lib/hqmf-generator/derivation.xml.erb +6 -6
  46. data/lib/hqmf-generator/description.xml.erb +1 -1
  47. data/lib/hqmf-generator/document.xml.erb +46 -11
  48. data/lib/hqmf-generator/encounter_criteria.xml.erb +4 -5
  49. data/lib/hqmf-generator/field.xml.erb +13 -1
  50. data/lib/hqmf-generator/grouper_criteria.xml.erb +17 -0
  51. data/lib/hqmf-generator/hqmf-generator.rb +75 -8
  52. data/lib/hqmf-generator/local_variable.xml.erb +1 -0
  53. data/lib/hqmf-generator/measure_observation_definition.xml.erb +25 -0
  54. data/lib/hqmf-generator/observation_criteria.xml.erb +4 -5
  55. data/lib/hqmf-generator/population_criteria.xml.erb +2 -3
  56. data/lib/hqmf-generator/precondition.xml.erb +2 -2
  57. data/lib/hqmf-generator/precondition_cv.xml.erb +8 -0
  58. data/lib/hqmf-generator/procedure_criteria.xml.erb +4 -5
  59. data/lib/hqmf-generator/reference.xml.erb +2 -2
  60. data/lib/hqmf-generator/source.xml.erb +2 -2
  61. data/lib/hqmf-generator/specific_occurrence.xml.erb +4 -5
  62. data/lib/hqmf-generator/subset.xml.erb +16 -3
  63. data/lib/hqmf-generator/substance_criteria.xml.erb +4 -5
  64. data/lib/hqmf-generator/supply_criteria.xml.erb +4 -5
  65. data/lib/hqmf-generator/temporal_relationship.xml.erb +1 -1
  66. data/lib/hqmf-generator/value.xml.erb +35 -9
  67. data/lib/hqmf-generator/variable_criteria.xml.erb +2 -3
  68. data/lib/hqmf-model/attribute.rb +36 -8
  69. data/lib/hqmf-model/data_criteria.json +38 -204
  70. data/lib/hqmf-model/data_criteria.rb +40 -16
  71. data/lib/hqmf-model/document.rb +61 -2
  72. data/lib/hqmf-model/population_criteria.rb +11 -7
  73. data/lib/hqmf-model/precondition.rb +1 -1
  74. data/lib/hqmf-model/types.rb +91 -8
  75. data/lib/hqmf-parser/1.0/attribute.rb +55 -2
  76. data/lib/hqmf-parser/1.0/document.rb +10 -23
  77. data/lib/hqmf-parser/1.0/population_criteria.rb +2 -2
  78. data/lib/hqmf-parser/1.0/range.rb +0 -1
  79. data/lib/hqmf-parser/2.0/data_criteria.rb +90 -21
  80. data/lib/hqmf-parser/2.0/document.rb +122 -7
  81. data/lib/hqmf-parser/2.0/population_criteria.rb +18 -6
  82. data/lib/hqmf-parser/2.0/precondition.rb +4 -1
  83. data/lib/hqmf-parser/2.0/types.rb +36 -15
  84. data/lib/hqmf-parser/converter/pass1/document_converter.rb +4 -56
  85. data/lib/hqmf-parser/converter/pass1/population_criteria_converter.rb +24 -8
  86. data/lib/hqmf-parser/converter/pass1/precondition_extractor.rb +15 -2
  87. data/lib/hqmf-parser/converter/pass2/comparison_converter.rb +1 -1
  88. data/lib/hqmf-parser/parser.rb +64 -41
  89. data/templates/cat1/_2.16.840.1.113883.10.20.22.4.85.cat1.erb +0 -1
  90. data/templates/cat1/_address.cat1.erb +9 -0
  91. data/templates/cat1/_author.cat1.erb +28 -0
  92. data/templates/cat1/_id.cat1.erb +1 -0
  93. data/templates/cat1/_organization.cat1.erb +8 -0
  94. data/templates/cat1/_patient_data.cat1.erb +0 -3
  95. data/templates/cat1/_telecom.cat1.erb +1 -0
  96. data/templates/cat1/show.cat1.erb +96 -58
  97. metadata +115 -66
  98. checksums.yaml +0 -7
@@ -1,61 +1,62 @@
1
- module HealthDataStandards
2
- module CQM
3
- class PatientCache
4
- include Mongoid::Document
5
- include Mongoid::Timestamps
6
- store_in collection: 'patient_cache'
7
- index "value.last" => 1
8
- index "bundle_id" => 1
9
- embeds_one :value, class_name: "HealthDataStandards::CQM::PatientCacheValue", inverse_of: :patient_cache
10
-
11
- def record
12
- Record.where(:medical_record_number => value['medical_record_id'], :test_id => value["test_id"]).first
13
- end
14
-
15
- def self.smoking_gun_rational(hqmf_id,sub_ids=nil, filter ={})
16
-
17
- match = {"value.IPP" => {"$gt" => 0},
18
- "value.measure_id" => hqmf_id
19
- }.merge filter
20
-
21
- if sub_ids
22
- match["value.sub_id"] = {"$in" => sub_ids}
23
- end
24
-
25
- group = {"$group" => {"_id" => "$value.medical_record_id", "rational" => {"$push"=> "$value.rationale"}}}
26
- aggregate = self.mongo_session.command(:aggregate => 'patient_cache', :pipeline => [{"$match" =>match},group])
27
-
28
- merged = {}
29
- aggregate["result"].each do |agg|
30
- mrn = agg["_id"]
31
- rational = {}
32
- merged[mrn] = rational
33
- agg["rational"].each do |r|
34
- rational.merge! r
35
- end
36
- end
37
-
38
- merged
39
- end
40
- end
41
-
42
- class PatientCacheValue
43
-
44
- include Mongoid::Document
45
-
46
- embedded_in :patient_cache, inverse_of: :value
47
-
48
- field :DENOM, type: Integer
49
- field :NUMER, type: Integer
50
- field :DENEX, type: Integer
51
- field :DENEXCEP, type: Integer
52
- field :MSRPOPL, type: Integer
53
- field :OBSERV
54
- field :antinumerator, type: Integer
55
- field :IPP, type: Integer
56
- field :measure_id, type: String
57
- field :sub_id, type: String\
58
- end
59
-
60
- end
1
+ module HealthDataStandards
2
+ module CQM
3
+ class PatientCache
4
+ include Mongoid::Document
5
+ include Mongoid::Timestamps
6
+ store_in collection: 'patient_cache'
7
+ index "value.last" => 1
8
+ index "bundle_id" => 1
9
+ index "value.medical_record_id" => 1
10
+ embeds_one :value, class_name: "HealthDataStandards::CQM::PatientCacheValue", inverse_of: :patient_cache
11
+
12
+ def record
13
+ Record.where(:medical_record_number => value['medical_record_id'], :test_id => value["test_id"]).first
14
+ end
15
+
16
+ def self.smoking_gun_rational(hqmf_id, sub_ids=nil, filter ={})
17
+
18
+ match = {"value.IPP" => {"$gt" => 0},
19
+ "value.measure_id" => hqmf_id
20
+ }.merge filter
21
+
22
+ if sub_ids
23
+ match["value.sub_id"] = {"$in" => sub_ids}
24
+ end
25
+
26
+ group = {"$group" => {"_id" => "$value.medical_record_id", "rational" => {"$push"=> "$value.rationale"}}}
27
+ aggregate = self.mongo_session.command(:aggregate => 'patient_cache', :pipeline => [{"$match" =>match},group])
28
+
29
+ merged = {}
30
+ aggregate["result"].each do |agg|
31
+ mrn = agg["_id"]
32
+ rational = {}
33
+ merged[mrn] = rational
34
+ agg["rational"].each do |r|
35
+ rational.merge! r
36
+ end
37
+ end
38
+
39
+ merged
40
+ end
41
+ end
42
+
43
+ class PatientCacheValue
44
+
45
+ include Mongoid::Document
46
+
47
+ embedded_in :patient_cache, inverse_of: :value
48
+
49
+ field :DENOM, type: Integer
50
+ field :NUMER, type: Integer
51
+ field :DENEX, type: Integer
52
+ field :DENEXCEP, type: Integer
53
+ field :MSRPOPL, type: Integer
54
+ field :OBSERV
55
+ field :antinumerator, type: Integer
56
+ field :IPP, type: Integer
57
+ field :measure_id, type: String
58
+ field :sub_id, type: String
59
+ end
60
+
61
+ end
61
62
  end
@@ -1,8 +1,8 @@
1
1
  class Encounter < Entry
2
- field :admitType, type: Hash
3
- field :dischargeDisposition, type: Hash
4
- field :admitTime, type: Integer
5
- field :dischargeTime, type: Integer
2
+ field :admitType, as: :admit_type, type: Hash
3
+ field :dischargeDisposition, as: :discharge_disposition, type: Hash
4
+ field :admitTime, as: :admit_time, type: Integer
5
+ field :dischargeTime, as: :discharge_time, type: Integer
6
6
 
7
7
  embeds_one :transferTo, class_name: "Transfer"
8
8
  embeds_one :transferFrom, class_name: "Transfer"
@@ -12,14 +12,6 @@ class Encounter < Entry
12
12
 
13
13
  belongs_to :performer, class_name: "Provider"
14
14
 
15
- alias :admit_time :admitTime
16
- alias :admit_time= :admitTime=
17
- alias :admit_type :admitType
18
- alias :admit_type= :admitType=
19
- alias :discharge_disposition :dischargeDisposition
20
- alias :discharge_disposition= :dischargeDisposition=
21
- alias :discharge_time :dischargeTime
22
- alias :discharge_time= :dischargeTime=
23
15
  alias :transfer_to :transferTo
24
16
  alias :transfer_to= :transferTo=
25
17
  alias :transfer_from :transferFrom
@@ -1,6 +1,7 @@
1
1
  class Entry
2
-
2
+ include ActiveModel::MassAssignmentSecurity
3
3
  include Mongoid::Document
4
+ include Mongoid::Attributes::Dynamic
4
5
  include ThingWithCodes
5
6
 
6
7
  # embedded_in :entry_list, polymorphic: true
@@ -16,16 +17,11 @@ class Entry
16
17
  field :end_time, type: Integer
17
18
  field :status_code, type: Hash
18
19
  field :mood_code, type: String, default: "EVN"
19
- field :negationInd, type: Boolean
20
- field :negationReason, type: Hash
20
+ field :negationInd, as: :negation_ind, type: Boolean
21
+ field :negationReason, as: :negation_reason, type: Hash
21
22
  field :oid, type: String
22
23
  field :reason, type: Hash
23
24
 
24
- alias :negation_ind :negationInd
25
- alias :negation_ind= :negationInd=
26
- alias :negation_reason :negationReason
27
- alias :negation_reason= :negationReason=
28
-
29
25
  attr_protected :version
30
26
  attr_protected :_id
31
27
  attr_protected :created_at
@@ -1,5 +1,6 @@
1
1
  class Facility
2
2
  include Mongoid::Document
3
+ include Mongoid::Attributes::Dynamic
3
4
 
4
5
  field :name, type: String
5
6
  field :code, type: Hash
@@ -1,27 +1,15 @@
1
1
  class FulfillmentHistory
2
2
  include Mongoid::Document
3
+ include Mongoid::Attributes::Dynamic
3
4
 
4
- field :prescriptionNumber, type: String
5
- field :dispenseDate, type: Integer
6
- field :quantityDispensed, type: Hash
7
- field :fillNumber, type: Integer
8
- field :fillStatus, type: String
5
+ field :prescriptionNumber, as: :prescription_number, type: String
6
+ field :dispenseDate, as: :dispense_date, type: Integer
7
+ field :quantityDispensed, as: :quantity_dispensed, type: Hash
8
+ field :fillNumber, as: :fill_number, type: Integer
9
+ field :fillStatus, as: :fill_status, type: String
9
10
 
10
11
  belongs_to :provider, class_name: "Provider"
11
12
 
12
- alias :prescription_number :prescriptionNumber
13
- alias :prescription_number= :prescriptionNumber=
14
- alias :dispense_date :dispenseDate
15
- alias :dispense_date= :dispenseDate=
16
- alias :quantity_dispensed :quantityDispensed
17
- alias :quantity_dispensed= :quantityDispensed=
18
- alias :fill_number :fillNumber
19
- alias :fill_number= :fillNumber=
20
- alias :fill_status :fillStatus
21
- alias :fill_status= :fillStatus=
22
- alias :prescription_number :prescriptionNumber
23
- alias :prescription_number= :prescriptionNumber=
24
-
25
13
  def shift_dates(date_diff)
26
14
  self.dispenseDate = (self.dispenseDate.nil?) ? nil : self.dispenseDate + date_diff
27
15
  end
@@ -1,5 +1,6 @@
1
1
  class Guarantor
2
2
  include Mongoid::Document
3
+ include Mongoid::Attributes::Dynamic
3
4
 
4
5
  embeds_one :organization
5
6
  embeds_one :person
@@ -1,8 +1,4 @@
1
1
  class LabResult < Entry
2
- field :referenceRange, type: String
3
- field :interpretation, type: Hash
4
-
5
- alias :reference_range :referenceRange
6
- alias :reference_range= :referenceRange=
7
-
2
+ field :referenceRange, as: :reference_range, type: String
3
+ field :interpretation, type: Hash
8
4
  end
@@ -1,13 +1,8 @@
1
1
  class MedicalEquipment < Entry
2
2
 
3
3
  field :manufacturer, type: String
4
- field :anatomicalStructure, type: Hash
5
- field :removalTime, type: Integer
6
-
7
- alias :anatomical_structure :anatomicalStructure
8
- alias :anatomical_structure= :anatomicalStructure=
9
- alias :removal_time :removalTime
10
- alias :removal_time= :removalTime=
4
+ field :anatomicalStructure, as: :anatomical_structure, type: Hash
5
+ field :removalTime, as: :removal_time, type: Integer
11
6
 
12
7
  def shift_dates(date_diff)
13
8
  super
@@ -1,52 +1,32 @@
1
1
  class Medication < Entry
2
- field :administrationTiming, type: Hash
2
+ field :administrationTiming, as: :administration_timing, type: Hash
3
3
  field :freeTextSig, type: String
4
4
  field :dose, type: Hash
5
- field :typeOfMedication, type: Hash
6
- field :statusOfMedication, type: Hash
5
+ field :typeOfMedication, as: :type_of_medication, type: Hash
6
+ field :statusOfMedication, as: :status_of_medication, type: Hash
7
7
  embeds_many :fulfillmentHistory, class_name: 'FulfillmentHistory'
8
8
  embeds_many :orderInformation, class_name: 'OrderInformation'
9
9
 
10
10
  field :route, type: Hash
11
11
  field :site, type: Hash
12
- field :doseRestriction, type: Hash
13
- field :fulfillmentInstructions, type: String
12
+ field :doseRestriction, as: :dose_restriction, type: Hash
13
+ field :fulfillmentInstructions, as: :fulfillment_instructions, type: String
14
14
  field :indication, type: Hash
15
- field :productForm, type: Hash
15
+ field :productForm, as: :product_form, type: Hash
16
16
  field :vehicle, type: Hash
17
17
  field :reaction, type: Hash
18
- field :deliveryMethod, type: Hash
19
- field :patientInstructions, type: String
20
- field :doseIndicator, type: String
18
+ field :deliveryMethod, as: :delivery_method, type: Hash
19
+ field :patientInstructions, as: :patient_instructions, type: String
20
+ field :doseIndicator, as: :dose_indicator, type: String
21
21
 
22
22
  # There are currently no importers that support this field
23
23
  # It is expected to be a scalar and value, such as 7 days
24
- field :cumulativeMedicationDuration, type: Hash
25
-
26
- alias :administration_timing :administrationTiming
27
- alias :administration_timing= :administrationTiming=
28
- alias :type_of_medication :typeOfMedication
29
- alias :type_of_medication= :typeOfMedication=
30
- alias :status_of_medication :statusOfMedication
31
- alias :status_of_medication= :statusOfMedication=
24
+ field :cumulativeMedicationDuration, as: :cumulative_medication_duration, type: Hash
25
+
32
26
  alias :fulfillment_history :fulfillmentHistory
33
27
  alias :fulfillment_history= :fulfillmentHistory=
34
28
  alias :order_information :orderInformation
35
29
  alias :order_information= :orderInformation=
36
- alias :dose_restriction :doseRestriction
37
- alias :dose_restriction= :doseRestriction=
38
- alias :fulfillment_instructions :fulfillmentInstructions
39
- alias :fulfillment_instructions= :fulfillmentInstructions=
40
- alias :product_form :productForm
41
- alias :product_form= :productForm=
42
- alias :delivery_method :deliveryMethod
43
- alias :delivery_method= :deliveryMethod=
44
- alias :patient_instructions :patientInstructions
45
- alias :patient_instructions= :patientInstructions=
46
- alias :dose_indicator :doseIndicator
47
- alias :dose_indicator= :doseIndicator=
48
- alias :cumulative_medication_duration :cumulativeMedicationDuration
49
- alias :cumulative_medication_duration= :cumulativeMedicationDuration=
50
30
 
51
31
  def shift_dates(date_diff)
52
32
  super
@@ -4,6 +4,7 @@ module Metadata
4
4
 
5
5
  field :href, type: String
6
6
  field :extension, type: String
7
+ field :uri, type: String
7
8
 
8
9
  end
9
10
  end
@@ -1,22 +1,14 @@
1
1
  class OrderInformation
2
2
  include Mongoid::Document
3
+ include Mongoid::Attributes::Dynamic
3
4
 
4
- field :orderNumber, type: String
5
+ field :orderNumber, as: :order_number, type: String
5
6
  field :fills, type: Integer
6
- field :quantityOrdered, type: Hash
7
- field :orderExpirationDateTime, type: Integer
8
- field :orderDateTime, type: Integer
7
+ field :quantityOrdered, as: :quantity_ordered, type: Hash
8
+ field :orderExpirationDateTime, as: :order_expiration_date_time, type: Integer
9
+ field :orderDateTime, as: :order_date_time, type: Integer
9
10
 
10
11
  belongs_to :provider
11
-
12
- alias :order_number :orderNumber
13
- alias :order_number= :orderNumber=
14
- alias :quantity_ordered :quantityOrdered
15
- alias :quantity_ordered= :quantityOrdered=
16
- alias :order_expiration_date_time :orderExpirationDateTime
17
- alias :order_expiration_date_time= :orderExpirationDateTime=
18
- alias :order_date_time :orderDateTime
19
- alias :order_date_time= :orderDateTime=
20
12
 
21
13
 
22
14
  def shift_dates(date_diff)
@@ -1,5 +1,6 @@
1
1
  class Organization
2
2
  include Mongoid::Document
3
+ include Mongoid::Attributes::Dynamic
3
4
 
4
5
  field :name, type: String
5
6
 
@@ -1,14 +1,11 @@
1
1
  class Procedure < Entry
2
2
  field :site, type: Hash
3
- field :incisionTime, type: Integer
3
+ field :incisionTime, type: Integer, as: :incision_time
4
4
  field :ordinality, type: Hash
5
5
  field :source, type: Hash
6
6
 
7
7
  belongs_to :performer, class_name: "Provider"
8
8
 
9
- alias :incision_time :incisionTime
10
- alias :incision_time= :incisionTime=
11
-
12
9
  def shift_dates(date_diff)
13
10
  super
14
11
  self.incisionTime = self.incisionTime.nil? ? nil : self.incisionTime + date_diff
@@ -1,6 +1,7 @@
1
1
  class Provider
2
2
  include Personable
3
3
  include Mongoid::Tree
4
+ include Mongoid::Attributes::Dynamic
4
5
 
5
6
  NPI_OID = '2.16.840.1.113883.4.6'
6
7
  TAX_ID_OID = '2.16.840.1.113883.4.2'
@@ -84,7 +85,7 @@ class Provider
84
85
  # exists. If this method call return nil an attempt will be made to discover
85
86
  # the Provider by name matching and if that fails a Provider will be created
86
87
  # in the db based on the information in the parsed hash.
87
- def self.resolve_provider(provider_hash)
88
+ def self.resolve_provider(provider_hash, patient=nil)
88
89
  Provider.where(:npi => nil).first
89
90
  end
90
91
  end
@@ -1,5 +1,6 @@
1
1
  class ProviderPerformance
2
2
  include Mongoid::Document
3
+ include Mongoid::Attributes::Dynamic
3
4
 
4
5
  field :start_date, type: Integer
5
6
  field :end_date, type: Integer
@@ -4,6 +4,7 @@ module Qrda
4
4
  include Mongoid::Document
5
5
 
6
6
  field :time, type: DateTime, default: Time.now
7
+ field :telecoms, type: Array
7
8
 
8
9
  embeds_many :ids
9
10
  embeds_many :addresses
@@ -4,6 +4,8 @@ module Qrda
4
4
  include Mongoid::Document
5
5
  field :name, type: String
6
6
  embeds_many :ids
7
+ embeds_many :addresses
8
+ embeds_many :telecoms
7
9
  end
8
10
 
9
11
  end
@@ -1,6 +1,7 @@
1
1
  class Record
2
2
  include Mongoid::Document
3
3
  include Mongoid::Timestamps
4
+ include Mongoid::Attributes::Dynamic
4
5
  extend Memoist
5
6
 
6
7
  field :title, type: String
@@ -14,14 +15,14 @@ class Record
14
15
  field :race, type: Hash
15
16
  field :ethnicity, type: Hash
16
17
  field :languages, type: Array, default: []
17
- field :test_id, type: Moped::BSON::ObjectId
18
+ field :test_id, type: BSON::ObjectId
18
19
  field :marital_status, type: Hash
19
20
  field :medical_record_number, type: String
20
21
  field :medical_record_assigner, type: String
21
22
  field :expired, type: Boolean
22
- field :clinicalTrialParticipant, type: Boolean # Currently not implemented in the C32 importer
23
- # because it cannot be easily represented in a
24
- # HITSP C32
23
+ field :clinicalTrialParticipant, as: :clinical_trial_participant, type: Boolean # Currently not implemented in the C32 importer
24
+ # because it cannot be easily represented in a
25
+ # HITSP C32
25
26
 
26
27
  index "last" => 1
27
28
  embeds_many :allergies
@@ -97,7 +98,6 @@ class Record
97
98
  alias :clinical_trial_participant :clinicalTrialParticipant
98
99
  alias :clinical_trial_participant= :clinicalTrialParticipant=
99
100
 
100
-
101
101
  # Remove duplicate entries from a section based on cda_identifier or id.
102
102
  # This method may lose information because it does not compare entries
103
103
  # based on clinical content
@@ -111,7 +111,7 @@ class Record
111
111
  unique_entries = {}
112
112
  self.send(section).each do |entry|
113
113
  if unique_entries[entry.identifier]
114
- unique_entries[entry.identifier].codes = unique_entries[entry.identifier].codes.deep_merge(entry.codes)
114
+ unique_entries[entry.identifier].codes = unique_entries[entry.identifier].codes.deep_merge(entry.codes){ |key, old, new| Array.wrap(old) + Array.wrap(new) }
115
115
  unique_entries[entry.identifier].values.concat(entry.values)
116
116
  else
117
117
  unique_entries[entry.identifier] = entry
@@ -121,7 +121,7 @@ class Record
121
121
  end
122
122
 
123
123
  def dedup_section!(section)
124
- [:results, :procedures].include?(section) ? dedup_section_merging_codes_and_values!(section) : dedup_section_ignoring_content!(section)
124
+ [:encounters, :procedures, :results].include?(section) ? dedup_section_merging_codes_and_values!(section) : dedup_section_ignoring_content!(section)
125
125
  end
126
126
  def dedup_record!
127
127
  Record::Sections.each {|section| self.dedup_section!(section)}