Class: DaVinciPASTestKit::Generator::ProfileMetadata
- Inherits:
-
Object
- Object
- DaVinciPASTestKit::Generator::ProfileMetadata
- Defined in:
- lib/davinci_pas_test_kit/generator/profile_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 required_concepts must_supports mandatory_elements bindings references tests id file_name delayed_references ].freeze
Instance Method Summary collapse
- #add_test(id:, file_name:) ⇒ Object
- #delayed? ⇒ Boolean
-
#initialize(metadata) ⇒ ProfileMetadata
constructor
A new instance of ProfileMetadata.
-
#must_support_list_string(indent: 8) ⇒ Object
A sorted, bulleted markdown list of this profile's must support elements (slices, elements, extensions, and choices), each line prefixed with
indentspaces. - #to_hash ⇒ Object
Constructor Details
#initialize(metadata) ⇒ ProfileMetadata
Returns a new instance of ProfileMetadata.
31 32 33 34 35 36 37 |
# File 'lib/davinci_pas_test_kit/generator/profile_metadata.rb', line 31 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_test(id:, file_name:) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/davinci_pas_test_kit/generator/profile_metadata.rb', line 70 def add_test(id:, file_name:) self.tests ||= [] = { id:, file_name: } tests << end |
#delayed? ⇒ Boolean
39 40 41 |
# File 'lib/davinci_pas_test_kit/generator/profile_metadata.rb', line 39 def delayed? !['Patient', 'Claim', 'ClaimResponse'].include?(resource) end |
#must_support_list_string(indent: 8) ⇒ Object
A sorted, bulleted markdown list of this profile's must support elements (slices, elements,
extensions, and choices), each line prefixed with indent spaces. Shared by the per-profile
must support tests and the collapsed attestation tests so both stay in sync with the metadata.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/davinci_pas_test_kit/generator/profile_metadata.rb', line 46 def must_support_list_string(indent: 8) slice_names = must_supports[:slices].map { |slice| slice[:slice_id] } element_names = must_supports[:elements].map { |element| "#{resource}.#{element[:path]}" } extension_names = must_supports[:extensions].map { |extension| extension[:id] } must_supports[:choices]&.each do |choice| next unless choice.key?(:paths) choice[:paths].each { |path| element_names.delete("#{resource}.#{path}") } choice[:extension_ids].each { |id| extension_names.delete(id.to_s) } if choice[:extension_ids].present? element_paths = choice[:paths].map { |path| "#{resource}.#{path}" }.join(' or ') extension_ids = choice[:extension_ids].join(' or ') element_names << "#{element_paths} or #{extension_ids}" end (slice_names + element_names + extension_names) .uniq .sort .map { |name| "#{' ' * indent}* #{name}" } .join("\n") end |
#to_hash ⇒ Object
81 82 83 |
# File 'lib/davinci_pas_test_kit/generator/profile_metadata.rb', line 81 def to_hash ATTRIBUTES.each_with_object({}) { |key, hash| hash[key] = send(key) unless send(key).nil? } end |