Class: BundleDecorator
- Inherits:
-
FHIR::Bundle
- Object
- FHIR::Bundle
- BundleDecorator
- Defined in:
- lib/au_ps_inferno/utils/bundle_decorator.rb
Overview
A decorator for FHIR::Bundle to add convenience methods
Instance Method Summary collapse
- #composition_entry ⇒ Object
- #composition_resource ⇒ Object
-
#initialize(data) ⇒ BundleDecorator
constructor
A new instance of BundleDecorator.
- #resource_by_reference(entry_reference) ⇒ Object
- #resources_by_references(entry_references) ⇒ Object
Constructor Details
#initialize(data) ⇒ BundleDecorator
Returns a new instance of BundleDecorator.
8 9 10 11 12 13 14 |
# File 'lib/au_ps_inferno/utils/bundle_decorator.rb', line 8 def initialize(data) if data.is_a?(Hash) super else super(data.respond_to?(:source_hash) ? data.source_hash : data.to_hash) end end |
Instance Method Details
#composition_entry ⇒ Object
22 23 24 |
# File 'lib/au_ps_inferno/utils/bundle_decorator.rb', line 22 def composition_entry entry.find { |entr| entr.resource.resourceType == 'Composition' } end |
#composition_resource ⇒ Object
16 17 18 19 20 |
# File 'lib/au_ps_inferno/utils/bundle_decorator.rb', line 16 def composition_resource return nil if composition_entry.nil? CompositionDecorator.new(composition_entry.resource) end |
#resource_by_reference(entry_reference) ⇒ Object
30 31 32 33 |
# File 'lib/au_ps_inferno/utils/bundle_decorator.rb', line 30 def resource_by_reference(entry_reference) entry = resolve_entry_reference(entry_reference) entry&.resource end |
#resources_by_references(entry_references) ⇒ Object
26 27 28 |
# File 'lib/au_ps_inferno/utils/bundle_decorator.rb', line 26 def resources_by_references(entry_references) entry_references.filter_map { |ref| resource_by_reference(ref) }.uniq end |