Class: CancerRegistryReportingTestKit::HdeaGenerator::IGMetadataExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ig_resources) ⇒ IGMetadataExtractor

Returns a new instance of IGMetadataExtractor.



11
12
13
14
15
16
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 11

def initialize(ig_resources)
  self.ig_resources = ig_resources
  add_missing_supported_profiles
  remove_version_from_supported_profiles
  self. = IGMetadata.new
end

Instance Attribute Details

#ig_resourcesObject

Returns the value of attribute ig_resources.



9
10
11
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 9

def ig_resources
  @ig_resources
end

#metadataObject

Returns the value of attribute metadata.



9
10
11
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 9

def 
  @metadata
end

Instance Method Details

#add_metadata_from_igObject



24
25
26
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 24

def 
  .ig_version = "v#{ig_resources.ig.version}"
end

#add_metadata_from_resourcesObject



69
70
71
72
73
74
75
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 69

def 
  .groups =
    resources_in_structure_definitions.flat_map do |resource|
      supported_profile = resource.url
      GroupMetadataExtractor.new(resource, supported_profile, , ig_resources).
    end.compact
end

#add_missing_supported_profilesObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 36

def add_missing_supported_profiles
  case ig_resources.ig.version
  when '3.1.1'
    # The US 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'
      ]
                
  when '5.0.1'
    # The US Core v5.0.1 Server Capability Statement does not have supported-profile for Encounter
    ig_resources.capability_statement.rest.first.resource
      .find { |resource| resource.type == 'Encounter' }
      .supportedProfile.concat [
                  'http://hl7.org/fhir/us/core/StructureDefinition/us-core-encounter'
      ]
                
  end
end

#extractObject



18
19
20
21
22
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 18

def extract
  
  
  
end

#remove_version_from_supported_profilesObject



63
64
65
66
67
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 63

def remove_version_from_supported_profiles
  resources_in_capability_statement.each do |resource|
    resource.supportedProfile.map! { |profile_url| profile_url.split('|').first }
  end
end

#resources_in_capability_statementObject



28
29
30
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 28

def resources_in_capability_statement
  ig_resources.capability_statement.rest.first.resource
end

#resources_in_structure_definitionsObject



32
33
34
# File 'lib/cancer_registry_reporting_test_kit/hdea_generator/ig_metadata_extractor.rb', line 32

def resources_in_structure_definitions
  ig_resources.resources_by_type['StructureDefinition'].map
end