Module: FHIR::BundleExtras
- Included in:
- Bundle, DSTU2::Bundle, R4B::Bundle, R5::Bundle, STU3::Bundle
- Defined in:
- lib/fhir_client/ext/bundle.rb
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #first_link ⇒ Object
- #get_by_id(id) ⇒ Object
- #last_link ⇒ Object
- #next_bundle ⇒ Object
- #next_link ⇒ Object
- #previous_link ⇒ Object
- #self_link ⇒ Object
Instance Method Details
#each(&block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fhir_client/ext/bundle.rb', line 30 def each(&block) iterator = @entry.map(&:resource).each(&block) if next_bundle next_iterator = next_bundle.each(&block) Enumerator.new do |y| iterator.each { |r| y << r } next_iterator.each { |r| y << r } end else iterator end end |
#first_link ⇒ Object
7 8 9 |
# File 'lib/fhir_client/ext/bundle.rb', line 7 def first_link link.select { |n| n.relation == 'first' }.first end |
#get_by_id(id) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/fhir_client/ext/bundle.rb', line 23 def get_by_id(id) entry.each do |item| return item.resource if item.id == id || item.resource.id == id end nil end |
#last_link ⇒ Object
11 12 13 |
# File 'lib/fhir_client/ext/bundle.rb', line 11 def last_link link.select { |n| n.relation == 'last' }.first end |
#next_bundle ⇒ Object
43 44 45 46 |
# File 'lib/fhir_client/ext/bundle.rb', line 43 def next_bundle return nil unless client && next_link.try(:url) @next_bundle ||= client.parse_reply(self.class, client.default_format, client.raw_read_url(next_link.url)) end |
#next_link ⇒ Object
15 16 17 |
# File 'lib/fhir_client/ext/bundle.rb', line 15 def next_link link.select { |n| n.relation == 'next' }.first end |
#previous_link ⇒ Object
19 20 21 |
# File 'lib/fhir_client/ext/bundle.rb', line 19 def previous_link link.select { |n| n.relation == 'previous' || n.relation == 'prev' }.first end |
#self_link ⇒ Object
3 4 5 |
# File 'lib/fhir_client/ext/bundle.rb', line 3 def self_link link.select { |n| n.relation == 'self' }.first end |