Class: BundleDecorator

Inherits:
FHIR::Bundle
  • Object
show all
Defined in:
lib/au_ps_inferno/utils/bundle_decorator.rb

Overview

A decorator for FHIR::Bundle to add convenience methods

Instance Method Summary collapse

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_entryObject



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_resourceObject



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