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, :profile_version, :title, :short_description, :is_delayed, :interactions, :operations, :searches, :search_definitions, :include_params, :revincludes, :required_concepts, :must_supports, :mandatory_elements, :bindings, :references, :tests, :granular_scope_tests, :id, :file_name, :delayed_references ].freeze
Instance Method Summary collapse
- #add_delayed_references(delayed_profiles, ig_resources) ⇒ Object
- #add_granular_scope_test(id:, file_name:) ⇒ Object
- #add_test(id:, file_name:) ⇒ Object
- #delayed? ⇒ Boolean
- #exclude_search_tests? ⇒ Boolean
-
#initialize(metadata) ⇒ GroupMetadata
constructor
A new instance of GroupMetadata.
- #no_patient_searches? ⇒ Boolean
- #non_uscdi_resource? ⇒ Boolean
- #searchable_delayed_resource? ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(metadata) ⇒ GroupMetadata
Returns a new instance of GroupMetadata.
38 39 40 41 42 43 44 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 38 def initialize() .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
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 98 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_granular_scope_test(id:, file_name:) ⇒ Object
85 86 87 88 89 90 91 92 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 85 def add_granular_scope_test(id:, file_name:) self.granular_scope_tests ||= [] self.granular_scope_tests << { id:, file_name: } end |
#add_test(id:, file_name:) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 70 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
46 47 48 49 50 51 52 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 46 def delayed? @is_delayed ||= if resource == 'Patient' false else no_patient_searches? || non_uscdi_resource? end end |
#exclude_search_tests? ⇒ Boolean
54 55 56 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 54 def exclude_search_tests? delayed? && !searchable_delayed_resource? end |
#no_patient_searches? ⇒ Boolean
58 59 60 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 58 def no_patient_searches? searches.none? { |search| search[:names].include?('patient') && search[:expectation] == 'SHALL' } end |
#non_uscdi_resource? ⇒ Boolean
62 63 64 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 62 def non_uscdi_resource? SpecialCases::NON_USCDI_RESOURCES.key?(resource) && SpecialCases::NON_USCDI_RESOURCES[resource].include?(reformatted_version) end |
#searchable_delayed_resource? ⇒ Boolean
66 67 68 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 66 def searchable_delayed_resource? SpecialCases::SEARCHABLE_DELAYED_RESOURCES.key?(resource) && SpecialCases::SEARCHABLE_DELAYED_RESOURCES[resource].include?(reformatted_version) end |
#to_hash ⇒ Object
94 95 96 |
# File 'lib/us_core_test_kit/generator/group_metadata.rb', line 94 def to_hash ATTRIBUTES.each_with_object({}) { |key, hash| hash[key] = send(key) unless send(key).nil? } end |