Class: CarinForBlueButtonTestKit::Generator::GroupMetadataExtractor
- Inherits:
-
Object
- Object
- CarinForBlueButtonTestKit::Generator::GroupMetadataExtractor
- Defined in:
- lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb
Instance Attribute Summary collapse
-
#ig_metadata ⇒ Object
Returns the value of attribute ig_metadata.
-
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
-
#profile_url ⇒ Object
Returns the value of attribute profile_url.
-
#resource_capabilities ⇒ Object
Returns the value of attribute resource_capabilities.
Instance Method Summary collapse
- #base_name ⇒ Object
- #bindings ⇒ Object
- #class_name ⇒ Object
- #conformance_expectation ⇒ Object
- #group_metadata ⇒ Object
- #group_metadata_hash ⇒ Object
- #include_params ⇒ Object
-
#initialize(resource_capabilities, profile_url, ig_metadata, ig_resources) ⇒ GroupMetadataExtractor
constructor
A new instance of GroupMetadataExtractor.
- #interactions ⇒ Object
- #mandatory_elements ⇒ Object
- #mark_mandatory_and_must_support_searches ⇒ Object
- #must_support_metadata_extractor ⇒ Object
- #must_supports ⇒ Object
- #name ⇒ Object
- #operations ⇒ Object
- #profile ⇒ Object
- #profile_elements ⇒ Object
- #profile_name ⇒ Object
- #profile_version ⇒ Object
- #references ⇒ Object
- #reformatted_version ⇒ Object
- #required_concepts ⇒ Object
- #resource ⇒ Object
- #revincludes ⇒ Object
- #search_definitions ⇒ Object
- #search_metadata_extractor ⇒ Object
- #searches ⇒ Object
- #short_description ⇒ Object
- #terminology_binding_metadata_extractor ⇒ Object
- #title ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(resource_capabilities, profile_url, ig_metadata, ig_resources) ⇒ GroupMetadataExtractor
Returns a new instance of GroupMetadataExtractor.
14 15 16 17 18 19 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 14 def initialize(resource_capabilities, profile_url, , ig_resources) self.resource_capabilities = resource_capabilities self.profile_url = profile_url self. = self.ig_resources = ig_resources end |
Instance Attribute Details
#ig_metadata ⇒ Object
Returns the value of attribute ig_metadata.
12 13 14 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 12 def @ig_metadata end |
#ig_resources ⇒ Object
Returns the value of attribute ig_resources.
12 13 14 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 12 def ig_resources @ig_resources end |
#profile_url ⇒ Object
Returns the value of attribute profile_url.
12 13 14 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 12 def profile_url @profile_url end |
#resource_capabilities ⇒ Object
Returns the value of attribute resource_capabilities.
12 13 14 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 12 def resource_capabilities @resource_capabilities end |
Instance Method Details
#base_name ⇒ Object
104 105 106 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 104 def base_name profile_url.split('StructureDefinition/').last end |
#bindings ⇒ Object
209 210 211 212 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 209 def bindings @bindings ||= .terminology_bindings end |
#class_name ⇒ Object
112 113 114 115 116 117 118 119 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 112 def class_name base_name .split('-') .map(&:capitalize) .join .gsub('CARIN4BB', "CARIN4BB#{.reformatted_version}") .concat('Sequence') end |
#conformance_expectation ⇒ Object
133 134 135 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 133 def conformance_expectation resource_capabilities.extension.first.valueCode end |
#group_metadata ⇒ Object
21 22 23 24 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 21 def @group_metadata ||= GroupMetadata.new() end |
#group_metadata_hash ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 26 def @group_metadata_hash ||= { name:, class_name:, version:, reformatted_version:, resource:, conformance_expectation:, profile_url:, profile_name:, profile_version:, title:, short_description:, interactions:, operations:, searches:, search_definitions:, include_params:, revincludes:, required_concepts:, must_supports:, mandatory_elements:, bindings:, references: } mark_mandatory_and_must_support_searches @group_metadata_hash end |
#include_params ⇒ Object
187 188 189 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 187 def include_params resource_capabilities.searchInclude || [] end |
#interactions ⇒ Object
154 155 156 157 158 159 160 161 162 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 154 def interactions @interactions ||= resource_capabilities.interaction.map do |interaction| { code: interaction.code, expectation: interaction.extension.first.valueCode # TODO: fix expectation extension finding } end end |
#mandatory_elements ⇒ Object
224 225 226 227 228 229 230 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 224 def mandatory_elements @mandatory_elements ||= profile_elements .select { |element| element.min.positive? } .map(&:path) .uniq end |
#mark_mandatory_and_must_support_searches ⇒ 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 92 93 94 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 58 def mark_mandatory_and_must_support_searches searches.each do |search| search[:names_not_must_support_or_mandatory] = search[:names].reject do |name| full_paths = search_definitions[name.to_sym][:full_paths] any_must_support_elements = must_supports[:elements].any? do |element| full_must_support_paths = ["#{resource}.#{element[:original_path]}", "#{resource}.#{element[:path]}"] full_paths.any? do |path| # allow for non-choice, choice types, and _id name == '_id' || full_must_support_paths.include?(path) || full_must_support_paths.include?("#{path}[x]") end end any_must_support_slices = must_supports[:slices].any? do |slice| # only handle type slices because that is all we need for now # for a slice like Observation.effective[x]:effectiveDateTime, the search parameter's expression could be # either Observation.effective or Observation.effectiveDateTime. if slice[:discriminator] && slice[:discriminator][:type] == 'type' full_must_support_path = "#{resource}.#{slice[:path].sub('[x]', slice[:discriminator][:code])}" base_must_support_path = "#{resource}.#{slice[:path].sub('[x]', '')}" full_paths.intersection([full_must_support_path, base_must_support_path]).present? else false end end any_mandatory_elements = mandatory_elements.any? do |element| full_paths.include?(element) end any_must_support_elements || any_must_support_slices || any_mandatory_elements end search[:must_support_or_mandatory] = search[:names_not_must_support_or_mandatory].empty? end end |
#must_support_metadata_extractor ⇒ Object
214 215 216 217 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 214 def @must_support_metadata_extractor ||= MustSupportMetadataExtractor.new(profile_elements, profile, resource, ig_resources) end |
#must_supports ⇒ Object
219 220 221 222 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 219 def must_supports @must_supports ||= .must_supports end |
#name ⇒ Object
108 109 110 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 108 def name base_name.tr('-', '_') end |
#operations ⇒ Object
164 165 166 167 168 169 170 171 172 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 164 def operations @operations ||= resource_capabilities.operation.map do |operation| { code: operation.name, expectation: operation.extension.first.valueCode # TODO: fix expectation extension finding } end end |
#profile ⇒ Object
96 97 98 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 96 def profile @profile ||= ig_resources.profile_by_url(profile_url) end |
#profile_elements ⇒ Object
100 101 102 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 100 def profile_elements @profile_elements ||= profile.snapshot.element end |
#profile_name ⇒ Object
137 138 139 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 137 def profile_name profile.title.gsub(' ', ' ') end |
#profile_version ⇒ Object
141 142 143 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 141 def profile_version profile.version end |
#references ⇒ Object
232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 232 def references @references ||= profile_elements .select { |element| element.type&.first&.code == 'Reference' } .map do |reference_definition| { path: reference_definition.path, profiles: reference_definition.type.first.targetProfile } end end |
#reformatted_version ⇒ Object
125 126 127 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 125 def reformatted_version .reformatted_version end |
#required_concepts ⇒ Object
195 196 197 198 199 200 201 202 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 195 def required_concepts return [] if resource == 'Observation' profile_elements .select { |element| element.type&.any? { |type| type.code == 'CodeableConcept' } } .select { |element| element.binding&.strength == 'required' } .map { |element| element.path.gsub("#{resource}.", '').gsub('[x]', 'CodeableConcept') } end |
#resource ⇒ Object
129 130 131 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 129 def resource resource_capabilities.type end |
#revincludes ⇒ Object
191 192 193 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 191 def revincludes resource_capabilities.searchRevInclude || [] end |
#search_definitions ⇒ Object
183 184 185 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 183 def search_definitions @search_definitions ||= .search_definitions end |
#search_metadata_extractor ⇒ Object
174 175 176 177 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 174 def @search_metadata_extractor ||= SearchMetadataExtractor.new(resource_capabilities, ig_resources, resource, profile_elements) end |
#searches ⇒ Object
179 180 181 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 179 def searches @searches ||= .searches end |
#short_description ⇒ Object
150 151 152 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 150 def short_description "Verify support for the server capabilities required by the #{profile_name}." end |
#terminology_binding_metadata_extractor ⇒ Object
204 205 206 207 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 204 def @terminology_binding_metadata_extractor ||= TerminologyBindingMetadataExtractor.new(profile_elements, ig_resources, resource) end |
#title ⇒ Object
145 146 147 148 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 145 def title puts profile.title profile.title.gsub(/C4BB\s*/, '').gsub(/\s*Profile/, '').strip end |
#version ⇒ Object
121 122 123 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata_extractor.rb', line 121 def version .ig_version end |