cqm-models 1.1.1.0 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.json +1 -1
  3. data/.github/workflows/gitleaks_github_actions.yml +28 -0
  4. data/.travis.yml +3 -3
  5. data/README.md +12 -9
  6. data/app/assets/javascripts/AdverseEvent.js +9 -3
  7. data/app/assets/javascripts/AllDataElements.js +18 -6
  8. data/app/assets/javascripts/AllergyIntolerance.js +8 -2
  9. data/app/assets/javascripts/AssessmentOrder.js +8 -2
  10. data/app/assets/javascripts/AssessmentPerformed.js +11 -3
  11. data/app/assets/javascripts/AssessmentRecommended.js +8 -2
  12. data/app/assets/javascripts/CareGoal.js +10 -3
  13. data/app/assets/javascripts/CommunicationPerformed.js +12 -6
  14. data/app/assets/javascripts/DeviceApplied.js +9 -2
  15. data/app/assets/javascripts/DeviceOrder.js +8 -2
  16. data/app/assets/javascripts/DeviceRecommended.js +8 -2
  17. data/app/assets/javascripts/Diagnosis.js +8 -2
  18. data/app/assets/javascripts/DiagnosticStudyOrder.js +8 -2
  19. data/app/assets/javascripts/DiagnosticStudyPerformed.js +9 -2
  20. data/app/assets/javascripts/DiagnosticStudyRecommended.js +8 -2
  21. data/app/assets/javascripts/EncounterOrder.js +9 -2
  22. data/app/assets/javascripts/EncounterPerformed.js +11 -5
  23. data/app/assets/javascripts/EncounterRecommended.js +8 -2
  24. data/app/assets/javascripts/FamilyHistory.js +8 -2
  25. data/app/assets/javascripts/ImmunizationAdministered.js +9 -2
  26. data/app/assets/javascripts/ImmunizationOrder.js +8 -2
  27. data/app/assets/javascripts/InterventionOrder.js +8 -2
  28. data/app/assets/javascripts/InterventionPerformed.js +9 -2
  29. data/app/assets/javascripts/InterventionRecommended.js +8 -2
  30. data/app/assets/javascripts/LaboratoryTestOrder.js +8 -2
  31. data/app/assets/javascripts/LaboratoryTestPerformed.js +9 -2
  32. data/app/assets/javascripts/LaboratoryTestRecommended.js +8 -2
  33. data/app/assets/javascripts/MedicationActive.js +9 -2
  34. data/app/assets/javascripts/MedicationAdministered.js +9 -2
  35. data/app/assets/javascripts/MedicationDischarge.js +9 -2
  36. data/app/assets/javascripts/MedicationDispensed.js +10 -4
  37. data/app/assets/javascripts/MedicationOrder.js +9 -4
  38. data/app/assets/javascripts/Participation.js +8 -2
  39. data/app/assets/javascripts/PatientCareExperience.js +8 -2
  40. data/app/assets/javascripts/PatientCharacteristic.js +7 -2
  41. data/app/assets/javascripts/PatientCharacteristicBirthdate.js +7 -2
  42. data/app/assets/javascripts/PatientCharacteristicClinicalTrialParticipant.js +7 -2
  43. data/app/assets/javascripts/PatientCharacteristicEthnicity.js +7 -2
  44. data/app/assets/javascripts/PatientCharacteristicExpired.js +7 -2
  45. data/app/assets/javascripts/PatientCharacteristicPayer.js +7 -2
  46. data/app/assets/javascripts/PatientCharacteristicRace.js +7 -2
  47. data/app/assets/javascripts/PatientCharacteristicSex.js +7 -2
  48. data/app/assets/javascripts/PhysicalExamOrder.js +8 -2
  49. data/app/assets/javascripts/PhysicalExamPerformed.js +9 -2
  50. data/app/assets/javascripts/PhysicalExamRecommended.js +8 -2
  51. data/app/assets/javascripts/ProcedureOrder.js +10 -3
  52. data/app/assets/javascripts/ProcedurePerformed.js +11 -3
  53. data/app/assets/javascripts/ProcedureRecommended.js +9 -3
  54. data/app/assets/javascripts/ProviderCareExperience.js +8 -2
  55. data/app/assets/javascripts/QDMPatient.js +25 -9
  56. data/app/assets/javascripts/RelatedPerson.js +42 -0
  57. data/app/assets/javascripts/SubstanceAdministered.js +9 -2
  58. data/app/assets/javascripts/SubstanceOrder.js +9 -2
  59. data/app/assets/javascripts/SubstanceRecommended.js +8 -2
  60. data/app/assets/javascripts/Symptom.js +8 -2
  61. data/app/assets/javascripts/attributes/CarePartner.js +33 -0
  62. data/app/assets/javascripts/attributes/Component.js +22 -1
  63. data/app/assets/javascripts/attributes/DiagnosisComponent.js +34 -0
  64. data/app/assets/javascripts/attributes/Entity.js +58 -0
  65. data/app/assets/javascripts/attributes/FacilityLocation.js +4 -1
  66. data/app/assets/javascripts/attributes/Identifier.js +23 -0
  67. data/app/assets/javascripts/attributes/Organization.js +33 -0
  68. data/app/assets/javascripts/attributes/PatientEntity.js +32 -0
  69. data/app/assets/javascripts/attributes/Practitioner.js +35 -0
  70. data/app/assets/javascripts/attributes/ResultComponent.js +31 -0
  71. data/app/assets/javascripts/basetypes/Any.js +24 -15
  72. data/app/assets/javascripts/basetypes/AnyEntity.js +44 -0
  73. data/app/assets/javascripts/basetypes/Code.js +8 -12
  74. data/app/assets/javascripts/basetypes/DataElement.js +17 -6
  75. data/app/assets/javascripts/basetypes/Interval.js +10 -8
  76. data/app/assets/javascripts/basetypes/QDMDate.js +36 -0
  77. data/app/assets/javascripts/basetypes/Quantity.js +1 -1
  78. data/app/assets/javascripts/basetypes/Ratio.js +1 -1
  79. data/app/assets/javascripts/cqm/AllCQMModels.js +2 -0
  80. data/app/assets/javascripts/cqm/ClauseResult.js +28 -0
  81. data/app/assets/javascripts/{IndividualResult.js → cqm/IndividualResult.js} +28 -2
  82. data/app/assets/javascripts/cqm/Measure.js +1 -1
  83. data/app/assets/javascripts/cqm/Provider.js +0 -2
  84. data/app/assets/javascripts/cqm/StatementResult.js +41 -0
  85. data/app/assets/javascripts/index.js +6 -2
  86. data/app/models/cqm/clause_result.rb +21 -0
  87. data/app/models/{qdm/tacoma → cqm}/individual_result.rb +24 -3
  88. data/app/models/cqm/measure.rb +2 -0
  89. data/app/models/cqm/patient.rb +1 -0
  90. data/app/models/cqm/provider.rb +4 -4
  91. data/app/models/cqm/statement_result.rb +27 -0
  92. data/app/models/hqmfOid_to_datatype_map.json +5 -1
  93. data/app/models/model_finder.rb +1 -0
  94. data/app/models/models.rb +15 -6
  95. data/app/models/qdm/adverse_event.rb +3 -2
  96. data/app/models/qdm/allergy_intolerance.rb +2 -1
  97. data/app/models/qdm/assessment_order.rb +2 -1
  98. data/app/models/qdm/assessment_performed.rb +5 -2
  99. data/app/models/qdm/assessment_recommended.rb +2 -1
  100. data/app/models/qdm/attributes/attribute.rb +1 -0
  101. data/app/models/qdm/attributes/care_partner.rb +10 -0
  102. data/app/models/qdm/attributes/component.rb +1 -1
  103. data/app/models/qdm/attributes/diagnosis_component.rb +10 -0
  104. data/app/models/qdm/attributes/entity.rb +15 -0
  105. data/app/models/qdm/attributes/facility_location.rb +1 -1
  106. data/app/models/qdm/{id.rb → attributes/identifier.rb} +3 -4
  107. data/app/models/qdm/attributes/organization.rb +10 -0
  108. data/app/models/qdm/attributes/patient_entity.rb +9 -0
  109. data/app/models/qdm/attributes/practitioner.rb +12 -0
  110. data/app/models/qdm/{result_component.rb → attributes/result_component.rb} +1 -3
  111. data/app/models/qdm/basetypes/code.rb +9 -10
  112. data/app/models/qdm/basetypes/data_element.rb +64 -12
  113. data/app/models/qdm/basetypes/date.rb +39 -0
  114. data/app/models/qdm/basetypes/interval.rb +26 -3
  115. data/app/models/qdm/basetypes/quantity.rb +1 -0
  116. data/app/models/qdm/basetypes/ratio.rb +1 -0
  117. data/app/models/qdm/care_goal.rb +4 -2
  118. data/app/models/qdm/communication_performed.rb +6 -5
  119. data/app/models/qdm/device_applied.rb +3 -1
  120. data/app/models/qdm/device_order.rb +2 -1
  121. data/app/models/qdm/device_recommended.rb +2 -1
  122. data/app/models/qdm/diagnosis.rb +2 -1
  123. data/app/models/qdm/diagnostic_study_order.rb +2 -1
  124. data/app/models/qdm/diagnostic_study_performed.rb +3 -1
  125. data/app/models/qdm/diagnostic_study_recommended.rb +2 -1
  126. data/app/models/qdm/encounter_order.rb +3 -1
  127. data/app/models/qdm/encounter_performed.rb +3 -2
  128. data/app/models/qdm/encounter_recommended.rb +2 -1
  129. data/app/models/qdm/family_history.rb +2 -1
  130. data/app/models/qdm/immunization_administered.rb +3 -1
  131. data/app/models/qdm/immunization_order.rb +2 -1
  132. data/app/models/qdm/intervention_order.rb +2 -1
  133. data/app/models/qdm/intervention_performed.rb +3 -1
  134. data/app/models/qdm/intervention_recommended.rb +2 -1
  135. data/app/models/qdm/laboratory_test_order.rb +2 -1
  136. data/app/models/qdm/laboratory_test_performed.rb +3 -1
  137. data/app/models/qdm/laboratory_test_recommended.rb +2 -1
  138. data/app/models/qdm/medication_active.rb +3 -1
  139. data/app/models/qdm/medication_administered.rb +3 -1
  140. data/app/models/qdm/medication_discharge.rb +3 -1
  141. data/app/models/qdm/medication_dispensed.rb +4 -3
  142. data/app/models/qdm/medication_order.rb +3 -3
  143. data/app/models/qdm/participation.rb +2 -1
  144. data/app/models/qdm/patient.rb +2 -2
  145. data/app/models/qdm/patient_care_experience.rb +2 -1
  146. data/app/models/qdm/patient_characteristic.rb +1 -1
  147. data/app/models/qdm/patient_characteristic_birthdate.rb +1 -1
  148. data/app/models/qdm/patient_characteristic_clinical_trial_participant.rb +1 -1
  149. data/app/models/qdm/patient_characteristic_ethnicity.rb +1 -1
  150. data/app/models/qdm/patient_characteristic_expired.rb +1 -1
  151. data/app/models/qdm/patient_characteristic_payer.rb +1 -1
  152. data/app/models/qdm/patient_characteristic_race.rb +1 -1
  153. data/app/models/qdm/patient_characteristic_sex.rb +1 -1
  154. data/app/models/qdm/physical_exam_order.rb +2 -1
  155. data/app/models/qdm/physical_exam_performed.rb +3 -1
  156. data/app/models/qdm/physical_exam_recommended.rb +2 -1
  157. data/app/models/qdm/procedure_order.rb +4 -2
  158. data/app/models/qdm/procedure_performed.rb +5 -2
  159. data/app/models/qdm/procedure_recommended.rb +3 -2
  160. data/app/models/qdm/provider_care_experience.rb +2 -1
  161. data/app/models/qdm/related_person.rb +13 -0
  162. data/app/models/qdm/substance_administered.rb +3 -1
  163. data/app/models/qdm/substance_order.rb +3 -1
  164. data/app/models/qdm/substance_recommended.rb +2 -1
  165. data/app/models/qdm/symptom.rb +2 -1
  166. data/bin/validate_generator.sh +1 -1
  167. data/cqm-models.gemspec +5 -5
  168. data/data/oids_qdm_5.5.json +337 -0
  169. data/dist/browser.js +41069 -34668
  170. data/dist/index.js +41068 -34667
  171. data/lib/generate_entities.rb +56 -0
  172. data/lib/generate_models.rb +77 -39
  173. data/lib/generate_patients.rb +20 -14
  174. data/lib/generate_types.rb +54 -14
  175. data/lib/generator_helpers.rb +14 -0
  176. data/modelinfo/qdm-modelinfo-5.5.xml +982 -0
  177. data/package.json +4 -4
  178. data/templates/entity_extension.rb.erb +6 -0
  179. data/templates/identifier_extension.rb.erb +58 -0
  180. data/templates/{id_template.js.erb → identifier_template.js.erb} +6 -5
  181. data/templates/index_template.js.erb +6 -2
  182. data/templates/models_template.rb.erb +22 -5
  183. data/templates/mongoose_template.js.erb +86 -12
  184. data/templates/patient_extension.rb.erb +1 -1
  185. data/templates/patient_template.js.erb +0 -4
  186. data/yarn.lock +525 -391
  187. metadata +46 -21
  188. data/app/assets/javascripts/Id.js +0 -21
  189. data/app/assets/javascripts/ProviderCharacteristic.js +0 -36
  190. data/app/assets/javascripts/ResultComponent.js +0 -33
  191. data/app/models/qdm/provider_characteristic.rb +0 -12
@@ -1,9 +1,7 @@
1
1
  module QDM
2
2
  # app/models/qdm/result_component.rb
3
- class ResultComponent < DataElement
3
+ class ResultComponent < Component
4
4
  include Mongoid::Document
5
- embedded_in :patient
6
5
  field :referenceRange, type: QDM::Interval
7
- field :qdmVersion, type: String, default: '5.4'
8
6
  end
9
7
  end
@@ -1,20 +1,19 @@
1
1
  module QDM
2
2
  # Represents a Code
3
3
  class Code
4
- attr_accessor :code, :codeSystem, :descriptor, :codeSystemOid, :version
4
+ attr_accessor :code, :display, :system, :version
5
5
 
6
6
  # Code and code system are required (at minimum).
7
- def initialize(code, codeSystem, descriptor = nil, codeSystemOid = nil, version = nil)
7
+ def initialize(code, sys, display = nil, version = nil)
8
8
  @code = code
9
- @codeSystem = codeSystem
10
- @descriptor = descriptor
11
- @codeSystemOid = codeSystemOid
9
+ @system = sys
10
+ @display = display
12
11
  @version = version
13
12
  end
14
13
 
15
14
  # Converts an object of this instance into a database friendly value.
16
15
  def mongoize
17
- { code: @code, codeSystem: @codeSystem, descriptor: @descriptor, codeSystemOid: @codeSystemOid, version: @version, _type: 'QDM::Code' }
16
+ { code: @code, system: @system, display: @display, version: @version, _type: 'QDM::Code' }
18
17
  end
19
18
 
20
19
  class << self
@@ -22,11 +21,12 @@ module QDM
22
21
  # this custom class from it.
23
22
  #
24
23
  # The array elements in demongoize are the same 5 elements used in mongoize, i.e.
25
- # [ code, codeSystem, descriptor, codeSystemOid, version ].
24
+ # [ code, system, display, version ].
26
25
  def demongoize(object)
27
26
  return nil unless object
27
+
28
28
  object = object.symbolize_keys
29
- QDM::Code.new(object[:code], object[:codeSystem], object[:descriptor], object[:codeSystemOid], object[:version])
29
+ QDM::Code.new(object[:code], object[:system], object[:display], object[:version])
30
30
  end
31
31
 
32
32
  # Takes any possible object and converts it to how it would be
@@ -37,8 +37,7 @@ module QDM
37
37
  when QDM::Code then object.mongoize
38
38
  when Hash
39
39
  object = object.symbolize_keys
40
- codeSystem = object[:system] ? object[:system] : object[:codeSystem]
41
- QDM::Code.new(object[:code], codeSystem, object[:descriptor], object[:codeSystemOid], object[:version]).mongoize
40
+ QDM::Code.new(object[:code], object[:system], object[:display], object[:version]).mongoize
42
41
  else object
43
42
  end
44
43
  end
@@ -14,12 +14,12 @@ module QDM
14
14
  # Valueset oid of the specific type.
15
15
  field :codeListId, type: String
16
16
 
17
- embeds_one :id, class_name: 'QDM::Id'
17
+ field :id, type: String
18
18
 
19
19
  def initialize(options = {})
20
20
  super(options)
21
21
  # default id to the mongo ObjectId for this DataElement if it isnt already defined
22
- self.id = QDM::Id.new(value: _id.to_s) unless id?
22
+ self.id = _id.to_s unless id?
23
23
  end
24
24
 
25
25
  # Returns the attribute requested on the datatype.
@@ -31,7 +31,7 @@ module QDM
31
31
  # to the CQL execution engine.
32
32
  def code_system_pairs
33
33
  codes.collect do |code|
34
- { code: code.code, system: code.codeSystem }
34
+ { code: code.code, system: code.system }
35
35
  end
36
36
  end
37
37
 
@@ -58,16 +58,9 @@ module QDM
58
58
  # Given value should be in seconds. Positive values shift forward, negative
59
59
  # values shift backwards.
60
60
  def shift_dates(seconds)
61
- # Iterate over fields
62
61
  fields.keys.each do |field|
63
- # Check if field is a DateTime
64
- if send(field).is_a? DateTime
65
- send(field + '=', (send(field).to_time + seconds.seconds).to_datetime)
66
- end
67
- # Check if field is an Interval
68
- if (send(field).is_a? Interval) || (send(field).is_a? DataElement)
69
- send(field + '=', send(field).shift_dates(seconds))
70
- end
62
+ send(field + '=', (send(field).to_time + seconds.seconds).to_datetime) if send(field).is_a? DateTime
63
+ send(field + '=', send(field).shift_dates(seconds)) if (send(field).is_a? Interval) || (send(field).is_a? DataElement)
71
64
 
72
65
  # Special case for facility locations
73
66
  if field == 'facilityLocations'
@@ -89,12 +82,71 @@ module QDM
89
82
  facility_location['locationPeriod'][:high] = (facility_location['locationPeriod'][:high].to_time + seconds).to_datetime
90
83
  end
91
84
 
85
+ # The necessary reason for this function is to avoid a problem when shifting
86
+ # past a year that is a leap year. February 29th dates are handled by moving
87
+ # back to the 28th in non leap years
88
+ def shift_years(year_shift)
89
+ fields.keys.each do |field|
90
+ if send(field).is_a?(QDM::Date) || send(field).is_a?(DateTime)
91
+ # Do not shift Time values. They are stored as DateTimes with year 0.
92
+ next if send(field).year.zero?
93
+ raise RangeError, 'Year was shifted after 9999 or before 0001' if send(field).year + year_shift > 9999 || send(field).year + year_shift < 1
94
+
95
+ if send(field).month == 2 && send(field).day == 29 && !::Date.leap?(year_shift + send(field).year)
96
+ if send(field).is_a?(QDM::Date)
97
+ shifted_date = send(field)
98
+ shifted_date.year = shifted_date.year + year_shift
99
+ shifted_date.day = 28
100
+ send(field + '=', shifted_date)
101
+ else
102
+ send(field + '=', send(field).change(year: year_shift + send(field).year, day: 28))
103
+ end
104
+ elsif send(field).is_a?(QDM::Date)
105
+ shifted_date = send(field)
106
+ shifted_date.year = shifted_date.year + year_shift
107
+ send(field + '=', shifted_date)
108
+ else
109
+ send(field + '=', send(field).change(year: year_shift + send(field).year))
110
+ end
111
+ end
112
+
113
+ if send(field).is_a? FacilityLocation
114
+ facility_location = send(field)
115
+ unless facility_location.nil?
116
+ shift_facility_location_years(facility_location, year_shift)
117
+ send(field + '=', facility_location)
118
+ end
119
+ end
120
+
121
+ if field == 'facilityLocations'
122
+ facilityLocations = send(field)
123
+ unless facilityLocations.nil?
124
+ shiftedFacilityLocations = []
125
+ facilityLocations.each do |location|
126
+ # Need to convert to a QDM::FacilityLocation because it is being passed in as a Hash
127
+ facilityLocation = QDM::FacilityLocation.new(location)
128
+ shift_facility_location_years(facilityLocation, year_shift)
129
+ shiftedFacilityLocations << facilityLocation
130
+ end
131
+ send(field + '=', shiftedFacilityLocations)
132
+ end
133
+ end
134
+
135
+ send(field + '=', send(field).shift_years(year_shift)) if (send(field).is_a? Interval) || (send(field).is_a? DataElement)
136
+ end
137
+ end
138
+
139
+ def shift_facility_location_years(facility_location, year_shift)
140
+ facility_location.locationPeriod = facility_location.locationPeriod.shift_years(year_shift)
141
+ end
142
+
92
143
  class << self
93
144
  # Get the object as it was stored in the database, and instantiate
94
145
  # this custom class from it.
95
146
  #
96
147
  def demongoize(object)
97
148
  return nil unless object
149
+
98
150
  object = object.symbolize_keys
99
151
  if object.is_a?(Hash)
100
152
  data_element = QDM.const_get(object[:_type])
@@ -0,0 +1,39 @@
1
+ module QDM
2
+ # Represents a QDM/CQL Date
3
+ class Date
4
+ attr_accessor :year, :month, :day
5
+
6
+ def initialize(year = nil, month = nil, day = nil)
7
+ @year = year
8
+ @month = month
9
+ @day = day
10
+ end
11
+
12
+ # Converts an object of this instance into a database friendly value.
13
+ def mongoize
14
+ "#{format('%04d', year)}-#{format('%02d', month)}-#{format('%02d', day)}"
15
+ end
16
+
17
+ class << self
18
+ # Get the string as it was stored in the database, and instantiate
19
+ # this custom class from it.
20
+ def demongoize(date_str)
21
+ return nil unless date_str
22
+
23
+ year = date_str[0..3].to_i
24
+ month = date_str[5..6].to_i
25
+ day = date_str[8..10].to_i
26
+ QDM::Date.new(year, month, day)
27
+ end
28
+
29
+ # Converts the object that was supplied to a criteria and converts it
30
+ # into a database friendly form.
31
+ def evolve(object)
32
+ case object
33
+ when QDM::Date then object.mongoize
34
+ else object
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -22,9 +22,7 @@ module QDM
22
22
  #
23
23
  # NOTE: This will only shift if @high and @low are DateTimes.
24
24
  def shift_dates(seconds)
25
- if (@low.is_a? DateTime) || (@low.is_a? Time)
26
- @low = (@low.utc.to_time + seconds.seconds).to_datetime.new_offset(0)
27
- end
25
+ @low = (@low.utc.to_time + seconds.seconds).to_datetime.new_offset(0) if (@low.is_a? DateTime) || (@low.is_a? Time)
28
26
  if (@high.is_a? DateTime) || (@high.is_a? Time)
29
27
  @high = (@high.utc.to_time + seconds.seconds).to_datetime.new_offset(0)
30
28
  @high = @high.year > 9999 ? @high.change(year: 9999) : @high
@@ -32,6 +30,30 @@ module QDM
32
30
  self
33
31
  end
34
32
 
33
+ def shift_years(year_shift)
34
+ if (@low.is_a? DateTime) || (@low.is_a? Time)
35
+ raise RangeError, 'Year was shifted after 9999 or before 0001' if @low.year + year_shift < 1 || @low.year + year_shift > 9999
36
+
37
+ low_shift = @low.year + year_shift
38
+ @low = if @low.month == 2 && @low.day == 29 && !::Date.leap?(low_shift)
39
+ @low.change(year: low_shift, day: 28)
40
+ else
41
+ @low.change(year: low_shift)
42
+ end
43
+ end
44
+ if (@high.is_a? DateTime) || (@high.is_a? Time)
45
+ raise RangeError, 'Year was shifted after 9999 or before 0001' if @high.year + year_shift < 1 || @high.year + year_shift > 9999
46
+
47
+ high_shift = @high.year + year_shift
48
+ @high = if @high.month == 2 && @high.day == 29 && !::Date.leap?(high_shift)
49
+ @high.change(year: high_shift, day: 28)
50
+ else
51
+ @high.change(year: high_shift)
52
+ end
53
+ end
54
+ self
55
+ end
56
+
35
57
  class << self
36
58
  # Get the object as it was stored in the database, and instantiate
37
59
  # this custom class from it.
@@ -40,6 +62,7 @@ module QDM
40
62
  # [ low, high ].
41
63
  def demongoize(object)
42
64
  return nil unless object
65
+
43
66
  object = object.symbolize_keys
44
67
  fix_datetime(object)
45
68
  QDM::Interval.new(object[:low], object[:high], object[:lowClosed], object[:highClosed]) if object.is_a?(Hash)
@@ -22,6 +22,7 @@ module QDM
22
22
  # [ value, unit ].
23
23
  def demongoize(object)
24
24
  return nil unless object
25
+
25
26
  object = object.symbolize_keys
26
27
  QDM::Quantity.new(object[:value], object[:unit]) if object.is_a?(Hash)
27
28
  end
@@ -22,6 +22,7 @@ module QDM
22
22
  # [ numerator, denominator ].
23
23
  def demongoize(object)
24
24
  return nil unless object
25
+
25
26
  object = object.symbolize_keys
26
27
  QDM::Ratio.new(object[:numerator], object[:denominator]) if object.is_a?(Hash)
27
28
  end
@@ -3,12 +3,14 @@ module QDM
3
3
  class CareGoal < DataElement
4
4
  include Mongoid::Document
5
5
  embedded_in :patient
6
+ field :statusDate, type: Date
6
7
  field :relevantPeriod, type: QDM::Interval
7
- embeds_many :relatedTo, class_name: 'QDM::Id'
8
+ field :relatedTo, type: Array
8
9
  field :targetOutcome
10
+ embeds_one :performer, class_name: 'QDM::Entity'
9
11
  field :qdmTitle, type: String, default: 'Care Goal'
10
12
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.7'
11
13
  field :qdmCategory, type: String, default: 'care_goal'
12
- field :qdmVersion, type: String, default: '5.4'
14
+ field :qdmVersion, type: String, default: '5.5'
13
15
  end
14
16
  end
@@ -6,15 +6,16 @@ module QDM
6
6
  field :authorDatetime, type: DateTime
7
7
  field :category, type: QDM::Code
8
8
  field :medium, type: QDM::Code
9
- field :sender, type: QDM::Code
10
- field :recipient, type: QDM::Code
11
- embeds_many :relatedTo, class_name: 'QDM::Id'
12
- field :relevantPeriod, type: QDM::Interval
9
+ embeds_one :sender, class_name: 'QDM::Entity'
10
+ embeds_one :recipient, class_name: 'QDM::Entity'
11
+ field :relatedTo, type: Array
12
+ field :sentDatetime, type: DateTime
13
+ field :receivedDatetime, type: DateTime
13
14
  field :negationRationale, type: QDM::Code
14
15
  field :qdmTitle, type: String, default: 'Communication, Performed'
15
16
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.132'
16
17
  field :qdmCategory, type: String, default: 'communication'
17
18
  field :qdmStatus, type: String, default: 'performed'
18
- field :qdmVersion, type: String, default: '5.4'
19
+ field :qdmVersion, type: String, default: '5.5'
19
20
  end
20
21
  end
@@ -4,14 +4,16 @@ module QDM
4
4
  include Mongoid::Document
5
5
  embedded_in :patient
6
6
  field :authorDatetime, type: DateTime
7
+ field :relevantDatetime, type: DateTime
7
8
  field :relevantPeriod, type: QDM::Interval
8
9
  field :negationRationale, type: QDM::Code
9
10
  field :reason, type: QDM::Code
10
11
  field :anatomicalLocationSite, type: QDM::Code
12
+ embeds_one :performer, class_name: 'QDM::Entity'
11
13
  field :qdmTitle, type: String, default: 'Device, Applied'
12
14
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.13'
13
15
  field :qdmCategory, type: String, default: 'device'
14
16
  field :qdmStatus, type: String, default: 'applied'
15
- field :qdmVersion, type: String, default: '5.4'
17
+ field :qdmVersion, type: String, default: '5.5'
16
18
  end
17
19
  end
@@ -6,10 +6,11 @@ module QDM
6
6
  field :authorDatetime, type: DateTime
7
7
  field :negationRationale, type: QDM::Code
8
8
  field :reason, type: QDM::Code
9
+ embeds_one :requester, class_name: 'QDM::Entity'
9
10
  field :qdmTitle, type: String, default: 'Device, Order'
10
11
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.15'
11
12
  field :qdmCategory, type: String, default: 'device'
12
13
  field :qdmStatus, type: String, default: 'order'
13
- field :qdmVersion, type: String, default: '5.4'
14
+ field :qdmVersion, type: String, default: '5.5'
14
15
  end
15
16
  end
@@ -6,10 +6,11 @@ module QDM
6
6
  field :authorDatetime, type: DateTime
7
7
  field :negationRationale, type: QDM::Code
8
8
  field :reason, type: QDM::Code
9
+ embeds_one :requester, class_name: 'QDM::Entity'
9
10
  field :qdmTitle, type: String, default: 'Device, Recommended'
10
11
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.16'
11
12
  field :qdmCategory, type: String, default: 'device'
12
13
  field :qdmStatus, type: String, default: 'recommended'
13
- field :qdmVersion, type: String, default: '5.4'
14
+ field :qdmVersion, type: String, default: '5.5'
14
15
  end
15
16
  end
@@ -7,10 +7,11 @@ module QDM
7
7
  field :prevalencePeriod, type: QDM::Interval
8
8
  field :anatomicalLocationSite, type: QDM::Code
9
9
  field :severity, type: QDM::Code
10
+ embeds_one :recorder, class_name: 'QDM::Entity'
10
11
  field :qdmTitle, type: String, default: 'Diagnosis'
11
12
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.110'
12
13
  field :qrdaOid, type: String, default: '2.16.840.1.113883.10.20.24.3.135'
13
14
  field :qdmCategory, type: String, default: 'condition'
14
- field :qdmVersion, type: String, default: '5.4'
15
+ field :qdmVersion, type: String, default: '5.5'
15
16
  end
16
17
  end
@@ -6,10 +6,11 @@ module QDM
6
6
  field :authorDatetime, type: DateTime
7
7
  field :reason, type: QDM::Code
8
8
  field :negationRationale, type: QDM::Code
9
+ embeds_one :requester, class_name: 'QDM::Entity'
9
10
  field :qdmTitle, type: String, default: 'Diagnostic Study, Order'
10
11
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.22'
11
12
  field :qdmCategory, type: String, default: 'diagnostic_study'
12
13
  field :qdmStatus, type: String, default: 'order'
13
- field :qdmVersion, type: String, default: '5.4'
14
+ field :qdmVersion, type: String, default: '5.5'
14
15
  end
15
16
  end
@@ -4,6 +4,7 @@ module QDM
4
4
  include Mongoid::Document
5
5
  embedded_in :patient
6
6
  field :authorDatetime, type: DateTime
7
+ field :relevantDatetime, type: DateTime
7
8
  field :relevantPeriod, type: QDM::Interval
8
9
  field :reason, type: QDM::Code
9
10
  field :result
@@ -13,10 +14,11 @@ module QDM
13
14
  field :facilityLocation, type: QDM::FacilityLocation
14
15
  field :negationRationale, type: QDM::Code
15
16
  field :components, type: Array
17
+ embeds_one :performer, class_name: 'QDM::Entity'
16
18
  field :qdmTitle, type: String, default: 'Diagnostic Study, Performed'
17
19
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.23'
18
20
  field :qdmCategory, type: String, default: 'diagnostic_study'
19
21
  field :qdmStatus, type: String, default: 'performed'
20
- field :qdmVersion, type: String, default: '5.4'
22
+ field :qdmVersion, type: String, default: '5.5'
21
23
  end
22
24
  end
@@ -5,11 +5,12 @@ module QDM
5
5
  embedded_in :patient
6
6
  field :authorDatetime, type: DateTime
7
7
  field :negationRationale, type: QDM::Code
8
+ embeds_one :requester, class_name: 'QDM::Entity'
8
9
  field :qdmTitle, type: String, default: 'Diagnostic Study, Recommended'
9
10
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.24'
10
11
  field :qrdaOid, type: String, default: '2.16.840.1.113883.10.20.24.3.19'
11
12
  field :qdmCategory, type: String, default: 'diagnostic_study'
12
13
  field :qdmStatus, type: String, default: 'recommended'
13
- field :qdmVersion, type: String, default: '5.4'
14
+ field :qdmVersion, type: String, default: '5.5'
14
15
  end
15
16
  end
@@ -7,10 +7,12 @@ module QDM
7
7
  field :reason, type: QDM::Code
8
8
  field :facilityLocation, type: QDM::FacilityLocation
9
9
  field :negationRationale, type: QDM::Code
10
+ embeds_one :requester, class_name: 'QDM::Entity'
11
+ field :priority, type: QDM::Code
10
12
  field :qdmTitle, type: String, default: 'Encounter, Order'
11
13
  field :hqmfOid, type: String, default: '2.16.840.1.113883.10.20.28.4.27'
12
14
  field :qdmCategory, type: String, default: 'encounter'
13
15
  field :qdmStatus, type: String, default: 'order'
14
- field :qdmVersion, type: String, default: '5.4'
16
+ field :qdmVersion, type: String, default: '5.5'
15
17
  end
16
18
  end