Sha256: 70315100d7b4fab4e145a32b435503682d4cd0ab91c6030a8feb99332aefa603

Contents?: true

Size: 1.64 KB

Versions: 11

Compression:

Stored size: 1.64 KB

Contents

module CarinForBlueButtonTestKit
    class Generator
      class IGResources
        def add(resource)
          resources_by_type[resource.resourceType] << resource
        end

        def capability_statement(mode = 'server')
          resources_by_type['CapabilityStatement'].find do |capability_statement_resource|
            capability_statement_resource.rest.any? { |r| r.mode == mode }
          end
        end

        def ig
          resources_by_type['ImplementationGuide'].first
        end

        def inspect
          'IGResources'
        end

        def profile_by_url(url)
          resources_by_type['StructureDefinition'].find { |profile| profile.url == url }
        end

        def resource_for_profile(url)
          resources_by_type['StructureDefinition'].find { |profile| profile.url == url }.type
        end

        def value_set_by_url(url)
          resources_by_type['ValueSet'].find { |profile| profile.url == url }
        end

        def search_param_by_resource_and_name(resource, name)
          # remove '_' from search parameter name, such as _id or _tag
          normalized_name = normalized_name = name.to_s.delete_prefix('_')

          param = resources_by_type['SearchParameter']
            .find { |param| param.id == "#{resource.downcase}-#{normalized_name}" }

          if param.nil?
            param = resources_by_type['SearchParameter']
              .find { |param| param.id == "Resource-#{normalized_name}" }
          end

          return param
        end

        private

        def resources_by_type
          @resources_by_type ||= Hash.new { |hash, key| hash[key] = [] }
        end
      end
    end
  end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
carin_for_blue_button_test_kit-0.14.0 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.13.3 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.13.2 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.13.1 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.13.0 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.12.1 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.12.0 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.11.2 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.11.1 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.11.0 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb
carin_for_blue_button_test_kit-0.10.0 lib/carin_for_blue_button_test_kit/generator/ig_resources.rb