Class: FHIR::Reference

Inherits:
Object
  • Object
show all
Defined in:
lib/fhir_client/ext/reference.rb

Instance Method Summary collapse

Instance Method Details

#contained?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/fhir_client/ext/reference.rb', line 3

def contained?
  reference.to_s.start_with?('#')
end

#idObject



7
8
9
10
11
12
13
# File 'lib/fhir_client/ext/reference.rb', line 7

def id
  if contained?
    reference.to_s[1..-1]
  else
    reference.to_s.split('/').last
  end
end

#readObject



23
24
25
26
# File 'lib/fhir_client/ext/reference.rb', line 23

def read
  return if contained? || type.blank? || id.blank?
  resource_class.read(id, client)
end

#resource_classObject



19
20
21
# File 'lib/fhir_client/ext/reference.rb', line 19

def resource_class
  "FHIR::#{type}".constantize unless contained?
end

#typeObject



15
16
17
# File 'lib/fhir_client/ext/reference.rb', line 15

def type
  reference.to_s.split('/').first unless contained?
end