Class: USCoreTestKit::Generator::MustSupportMetadataExtractorUsCore4
- Inherits:
-
Object
- Object
- USCoreTestKit::Generator::MustSupportMetadataExtractorUsCore4
- Defined in:
- lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb
Instance Attribute Summary collapse
-
#must_supports ⇒ Object
Returns the value of attribute must_supports.
-
#profile ⇒ Object
Returns the value of attribute profile.
Instance Method Summary collapse
- #add_device_distinct_identifier ⇒ Object
- #add_must_support_choices ⇒ Object
- #add_patient_telecom_communication_uscdi ⇒ Object
- #add_patient_uscdi_elements ⇒ Object
- #handle_special_cases ⇒ Object
-
#initialize(profile, must_supports) ⇒ MustSupportMetadataExtractorUsCore4
constructor
A new instance of MustSupportMetadataExtractorUsCore4.
- #us_core_3_extractor ⇒ Object
Constructor Details
#initialize(profile, must_supports) ⇒ MustSupportMetadataExtractorUsCore4
Returns a new instance of MustSupportMetadataExtractorUsCore4.
8 9 10 11 |
# File 'lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb', line 8 def initialize(profile, must_supports) self.profile = profile self.must_supports = must_supports end |
Instance Attribute Details
#must_supports ⇒ Object
Returns the value of attribute must_supports.
6 7 8 |
# File 'lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb', line 6 def must_supports @must_supports end |
#profile ⇒ Object
Returns the value of attribute profile.
6 7 8 |
# File 'lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb', line 6 def profile @profile end |
Instance Method Details
#add_device_distinct_identifier ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb', line 39 def add_device_distinct_identifier if profile.type == 'Device' # FHIR-36303 US Core 4.0.0 mistakenly removed MS from Device.distinctIdentifier # This will be fixed in US Core 5.0.0 must_supports[:elements] << { path: 'distinctIdentifier' } end end |
#add_must_support_choices ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb', line 23 def add_must_support_choices choices = [] case profile.type when 'DocumentReference' choices << { paths: ['content.attachment.data', 'content.attachment.url'] } when 'Encounter' choices << { paths: ['reasonCode', 'reasonReference'] } choices << { paths: ['location.location', 'serviceProvider'] } when 'MedicationRequest' choices << { paths: ['reportedBoolean', 'reportedReference'] } end must_supports[:choices] = choices if choices.present? end |
#add_patient_telecom_communication_uscdi ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb', line 88 def add_patient_telecom_communication_uscdi return unless profile.type == 'Patient' # Though telecom.system, telecom.value, telecom.use, and communication.language are marked as MustSupport since US Core v4.0.0, # their parent elements telecom, and communication are not MustSupport but listed under "Additional USCDI requirements" # According to the updated FHIR spec that "When a child element is defined as Must Support and the parent element isn't, # a system must support the child if it support the parent, but there's no expectation that the system must support the parent.", # We add uscdi_only tag to these elements must_supports[:elements].each do |element| path = element[:path] element[:uscdi_only] = true if path.include?('telecom.') || path.include?('communication.') end end |
#add_patient_uscdi_elements ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb', line 49 def add_patient_uscdi_elements return unless profile.type == 'Patient' #US Core 4.0.0 Section 10.112.1.1 Additional USCDI v1 Requirement: must_supports[:extensions] << { id: 'Patient.extension:race', path: 'extension', url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race', uscdi_only: true } must_supports[:extensions] << { id: 'Patient.extension:ethnicity', path: 'extension', url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity', uscdi_only: true } must_supports[:extensions] << { id: 'Patient.extension:birthsex', path: 'extension', url: 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex', uscdi_only: true } must_supports[:elements] << { path: 'name.suffix', uscdi_only: true } must_supports[:elements] << { path: 'telecom', uscdi_only: true } must_supports[:elements] << { path: 'communication', uscdi_only: true } add_patient_telecom_communication_uscdi us_core_3_extractor.update_patient_previous_name_address end |
#handle_special_cases ⇒ Object
17 18 19 20 21 |
# File 'lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb', line 17 def handle_special_cases add_must_support_choices add_device_distinct_identifier add_patient_uscdi_elements end |
#us_core_3_extractor ⇒ Object
13 14 15 |
# File 'lib/us_core_test_kit/generator/must_support_metadata_extractor_us_core_4.rb', line 13 def us_core_3_extractor @us_core_3_extractor ||= MustSupportMetadataExtractorUsCore3.new(profile, must_supports) end |