Class: CarinForBlueButtonTestKit::Generator::GroupMetadata
- Inherits:
-
Object
- Object
- CarinForBlueButtonTestKit::Generator::GroupMetadata
- Defined in:
- lib/carin_for_blue_button_test_kit/generator/group_metadata.rb
Constant Summary collapse
- ATTRIBUTES =
%i[ 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 tests id file_name delayed_references ].freeze
Instance Method Summary collapse
- #add_delayed_references(delayed_profiles, ig_resources) ⇒ Object
- #add_test(id:, file_name:) ⇒ Object
- #delayed? ⇒ Boolean
-
#initialize(metadata) ⇒ GroupMetadata
constructor
A new instance of GroupMetadata.
- #no_patient_searches? ⇒ Boolean
- #to_hash ⇒ Object
Constructor Details
#initialize(metadata) ⇒ GroupMetadata
Returns a new instance of GroupMetadata.
37 38 39 40 41 42 43 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata.rb', line 37 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
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata.rb', line 74 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
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata.rb', line 54 def add_test(id:, file_name:) self.tests ||= [] = { id:, file_name: } if !delayed? && !id.include?('include') && id.include?('patient_search') self.tests.unshift() else self.tests << end end |
#delayed? ⇒ Boolean
45 46 47 48 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata.rb', line 45 def delayed? return false if resource == 'Patient' no_patient_searches? end |
#no_patient_searches? ⇒ Boolean
50 51 52 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata.rb', line 50 def no_patient_searches? searches.none? { |search| search[:names].include? 'patient' } end |
#to_hash ⇒ Object
70 71 72 |
# File 'lib/carin_for_blue_button_test_kit/generator/group_metadata.rb', line 70 def to_hash ATTRIBUTES.each_with_object({}) { |key, hash| hash[key] = send(key) unless send(key).nil? } end |