Class: AUCoreTestKit::Generator::IGMetadataExtractor
- Inherits:
-
Object
- Object
- AUCoreTestKit::Generator::IGMetadataExtractor
- Defined in:
- lib/au_core_test_kit/generator/ig_metadata_extractor.rb
Instance Attribute Summary collapse
-
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Instance Method Summary collapse
- #add_metadata_from_ig ⇒ Object
- #add_metadata_from_resources ⇒ Object
- #add_missing_supported_profiles ⇒ Object
- #extract ⇒ Object
-
#initialize(ig_resources) ⇒ IGMetadataExtractor
constructor
A new instance of IGMetadataExtractor.
- #remove_extra_supported_profiles ⇒ Object
- #resources_in_capability_statement ⇒ Object
Constructor Details
#initialize(ig_resources) ⇒ IGMetadataExtractor
Returns a new instance of IGMetadataExtractor.
11 12 13 14 15 16 |
# File 'lib/au_core_test_kit/generator/ig_metadata_extractor.rb', line 11 def initialize(ig_resources) self.ig_resources = ig_resources add_missing_supported_profiles remove_extra_supported_profiles self. = IGMetadata.new end |
Instance Attribute Details
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
9 10 11 |
# File 'lib/au_core_test_kit/generator/ig_metadata_extractor.rb', line 9 def ig_resources @ig_resources end |
#metadata ⇒ Object
Returns the value of attribute metadata.
9 10 11 |
# File 'lib/au_core_test_kit/generator/ig_metadata_extractor.rb', line 9 def @metadata end |
Instance Method Details
#add_metadata_from_ig ⇒ Object
24 25 26 |
# File 'lib/au_core_test_kit/generator/ig_metadata_extractor.rb', line 24 def .ig_version = "v#{ig_resources.ig.version}" end |
#add_metadata_from_resources ⇒ Object
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 87 88 89 90 91 |
# File 'lib/au_core_test_kit/generator/ig_metadata_extractor.rb', line 58 def profile_arr_to_skip = [ 'http://hl7.org.au/fhir/StructureDefinition/au-imagingresult', 'http://hl7.org.au/fhir/StructureDefinition/au-specimen', # https://github.com/hl7au/au-fhir-core-inferno/issues/244 'http://hl7.org/fhir/uv/sdc/StructureDefinition/sdc-questionnaire', 'http://hl7.org.au/fhir/core/StructureDefinition/au-core-norelevantfinding', 'http://hl7.org/fhir/StructureDefinition/DocumentReference' # https://github.com/hl7au/au-fhir-core-inferno/issues/216 ] # NOTE: We use two different groups because of CapabilityStatement.rest.resource # in AU Core IG supports two ways to describe the profile: # 1. "profile" element which is a string # 2. "supportedProfile" element which is an array of strings supported_profile_groups = resources_in_capability_statement.flat_map do |resource| resource.supportedProfile&.map do |supported_profile| supported_profile = supported_profile.split('|').first next if profile_arr_to_skip.include?(supported_profile) GroupMetadataExtractor.new(resource, supported_profile, , ig_resources). end end.compact profile_groups = resources_in_capability_statement.flat_map do |resource| next unless resource.profile.present? next if profile_arr_to_skip.include?(resource.profile) GroupMetadataExtractor.new(resource, resource.profile, , ig_resources). end.compact .groups = supported_profile_groups + profile_groups .postprocess_groups(ig_resources) end |
#add_missing_supported_profiles ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/au_core_test_kit/generator/ig_metadata_extractor.rb', line 32 def add_missing_supported_profiles case ig_resources.ig.version when '3.1.1' # The AU Core v3.1.1 Server Capability Statement does not list support for the # required vital signs profiles, so they need to be added ig_resources.capability_statement.rest.first.resource .find { |resource| resource.type == 'Observation' } .supportedProfile.concat [ 'http://hl7.org/fhir/StructureDefinition/bodyheight', 'http://hl7.org/fhir/StructureDefinition/bodytemp', 'http://hl7.org/fhir/StructureDefinition/bp', 'http://hl7.org/fhir/StructureDefinition/bodyweight', 'http://hl7.org/fhir/StructureDefinition/heartrate', 'http://hl7.org/fhir/StructureDefinition/resprate' ] end end |
#extract ⇒ Object
18 19 20 21 22 |
# File 'lib/au_core_test_kit/generator/ig_metadata_extractor.rb', line 18 def extract end |
#remove_extra_supported_profiles ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/au_core_test_kit/generator/ig_metadata_extractor.rb', line 50 def remove_extra_supported_profiles ig_resources.capability_statement.rest.first.resource .find { |resource| resource.type == 'Observation' } .supportedProfile.delete_if do |profile_url| SpecialCases::PROFILES_TO_EXCLUDE.include?(profile_url) end end |
#resources_in_capability_statement ⇒ Object
28 29 30 |
# File 'lib/au_core_test_kit/generator/ig_metadata_extractor.rb', line 28 def resources_in_capability_statement ig_resources.capability_statement.rest.first.resource end |