Class: IpaTestKit::Generator::MustSupportMetadataExtractor

Inherits:
Inferno::DSL::MustSupportMetadataExtractor
  • Object
show all
Defined in:
lib/ipa_test_kit/generator/must_support_metadata_extractor.rb

Instance Method Summary collapse

Instance Method Details

#add_device_distinct_identifierObject



132
133
134
135
136
137
138
139
140
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 132

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_document_reference_category_valuesObject



142
143
144
145
146
147
148
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 142

def add_document_reference_category_values
  return unless profile.type == 'DocumentReference'

  slice = @must_supports[:slices].find{|slice| slice[:path] == 'category'}

  slice[:discriminator][:values] = ['clinical-note'] if slice.present?
end

#add_must_support_choicesObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 91

def add_must_support_choices
  choices = []

  choices << { paths: ['content.attachment.data', 'content.attachment.url'] } if profile.type == 'DocumentReference'

  case profile.version
  when '3.1.1'
    choices << { paths: ['udiCarrier.carrierAIDC', 'udiCarrier.carrierHRF'] } if profile.type == 'Device'
  when '4.0.0'
    case profile.type
    when 'Encounter'
      choices << { paths: ['reasonCode', 'reasonReference'] }
      choices << { paths: ['location.location', 'serviceProvider'] }
    when 'MedicationRequest'
      choices << { paths: ['reportedBoolean', 'reportedReference'] }
    end
  when '5.0.1'
    case profile.type
    when 'CareTeam'
      choices << {
        target_profiles: [
          'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitioner',
          'http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole'
        ]
      }
    when 'Condition'
      choices << {
        paths: ['onsetDateTime'],
        extension_ids: ['Condition.extension:assertedDate']
      }
    when 'Encounter'
      choices << { paths: ['reasonCode', 'reasonReference'] }
      choices << { paths: ['location.location', 'serviceProvider'] }
    when 'MedicationRequest'
      choices << { paths: ['reportedBoolean', 'reportedReference'] }
    end
  end

  @must_supports[:choices] = choices if choices.present?
end

#handle_special_casesObject

SPECIAL CASE ####



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 18

def handle_special_cases
  remove_vital_sign_component
  remove_blood_pressure_value
  add_must_support_choices

  case profile.version
  when '3.1.1'
    remove_document_reference_custodian
  when '4.0.0'
    add_device_distinct_identifier
  when '5.0.1'
    add_document_reference_category_values
    remove_survey_questionnaire_response
  end
end

#is_blood_pressure?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 41

def is_blood_pressure?
  ['observation-bp', 'IpaBloodPressureProfile'].include?(profile.name)
end

#is_vital_sign?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
39
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 34

def is_vital_sign?
  [
    'http://hl7.org/fhir/StructureDefinition/vitalsigns',
    'http://hl7.org/fhir/us/core/StructureDefinition/us-core-vital-signs'
  ].include?(profile.baseDefinition)
end

#must_supportsObject



8
9
10
11
12
13
14
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 8

def must_supports
  @must_supports = super

  handle_special_cases

  @must_supports
end

#remove_blood_pressure_valueObject

Exclude Observation.value from observation-bp



55
56
57
58
59
60
61
62
63
64
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 55

def remove_blood_pressure_value
  if is_blood_pressure?
    @must_supports[:elements].delete_if do |element|
      element[:path].start_with?('value[x]') || element[:original_path]&.start_with?('value[x]')
    end
    @must_supports[:slices].delete_if do |slice|
      slice[:path].start_with?('value[x]')
    end
  end
end

#remove_device_carrierObject



66
67
68
69
70
71
72
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 66

def remove_device_carrier
  if profile.type == 'Device'
    @must_supports[:elements].delete_if do |element|
      ['udiCarrier.carrierAIDC', 'udiCarrier.carrierHRF'].include?(element[:path])
    end
  end
end

#remove_document_reference_attachment_data_urlObject



83
84
85
86
87
88
89
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 83

def remove_document_reference_attachment_data_url
  if profile.type == 'DocumentReference'
    @must_supports[:elements].delete_if do |element|
      ['content.attachment.data', 'content.attachment.url'].include?(element[:path])
    end
  end
end

#remove_document_reference_custodianObject

US Core clarified that server implmentation is not required to support DocumentReference.custodian (FHIR-28393)



75
76
77
78
79
80
81
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 75

def remove_document_reference_custodian
  if profile.type == 'DocumentReference'
    @must_supports[:elements].delete_if do |element|
      element[:path] == 'custodian'
    end
  end
end

#remove_survey_questionnaire_responseObject

FHIR-37794 Server systems are not required to support US Core QuestionnaireResponse



151
152
153
154
155
156
157
158
159
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 151

def remove_survey_questionnaire_response
  return unless profile.type == 'Observation' &&
    ['us-core-observation-survey', 'us-core-observation-sdoh-assessment'].include?(profile.id)

  element = @must_supports[:elements].find { |element| element[:path] == 'derivedFrom' }
  element[:target_profiles].delete_if do |url|
    url == 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-questionnaireresponse'
  end
end

#remove_vital_sign_componentObject

Exclude Observation.component from vital sign profiles except observation-bp and observation-pulse-ox



46
47
48
49
50
51
52
# File 'lib/ipa_test_kit/generator/must_support_metadata_extractor.rb', line 46

def remove_vital_sign_component
  if is_vital_sign? && !is_blood_pressure? && profile.name != 'IpaPulseOximetryProfile'
    @must_supports[:elements].delete_if do |element|
      element[:path].start_with?('component')
    end
  end
end