Class: USCoreTestKit::Generator::GroupMetadata
- Inherits:
-
Object
- Object
- USCoreTestKit::Generator::GroupMetadata
- Defined in:
- lib/us_core_test_kit/generator/group_metadata.rb
Constant Summary collapse
- ATTRIBUTES =
[ :name, :class_name, :version, :reformatted_version, :resource, :profile_url, :profile_name, :title, :short_description, :interactions, :operations, :searches, :search_definitions, :include_params, :revincludes, :required_concepts, :must_supports, :mandatory_elements, :bindings, :references, :tests, :id, :file_name, :delayed_references ].freeze
- NON_USCDI_RESOURCES =
[ 'Encounter', 'Location', 'Organization', 'Practitioner', 'PractitionerRole', 'Provenance' ].freeze
Instance Method Summary collapse
- #add_delayed_references(delayed_profiles, ig_resources) ⇒ Object
- #add_test(id:, file_name:) ⇒ Object
- #delayed? ⇒ Boolean
-
#initialize(**params) ⇒ GroupMetadata
constructor
A new instance of GroupMetadata.
- #no_patient_searches? ⇒ Boolean
- #non_uscdi_resource? ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(**params) ⇒ GroupMetadata
Returns a new instance of GroupMetadata.
42 43 44 45 46 47 48 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 42 def initialize(**params) params.each do |key, value| raise "Unknown attribute #{key}" unless ATTRIBUTES.include? key instance_variable_set(:"@#{key}", value) end end |
Instance Method Details
#add_delayed_references(delayed_profiles, ig_resources) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 83 def add_delayed_references(delayed_profiles, ig_resources) self.delayed_references = references .select { |reference| (reference[:profiles] & delayed_profiles).present? } .map do |reference| profile_urls = (reference[:profiles] & delayed_profiles) delayed_resources = profile_urls.map { |url| ig_resources.resource_for_profile(url) } { path: reference[:path].gsub("#{resource}.", ''), resources: delayed_resources } end end |
#add_test(id:, file_name:) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 64 def add_test(id:, file_name:) self.tests ||= [] = { id: id, file_name: file_name } if delayed? && id.include?('read') self.tests.unshift() else self.tests << end end |
#delayed? ⇒ Boolean
50 51 52 53 54 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 50 def delayed? return false if resource == 'Patient' no_patient_searches? || non_uscdi_resource? end |
#no_patient_searches? ⇒ Boolean
56 57 58 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 56 def no_patient_searches? searches.none? { |search| search[:names].include? 'patient' } end |
#non_uscdi_resource? ⇒ Boolean
60 61 62 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 60 def non_uscdi_resource? NON_USCDI_RESOURCES.include? resource end |
#to_hash ⇒ Object
79 80 81 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 79 def to_hash ATTRIBUTES.each_with_object({}) { |key, hash| hash[key] = send(key) unless send(key).nil? } end |