module FHIR::ReferenceExtras
Public Instance Methods
absolute?()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 22 def absolute? /^https?:\/\//.match reference.to_s end
base_uri()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 52 def base_uri return if !absolute? || contained? parts[:base_uri] end
contained?()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 18 def contained? reference.to_s.start_with?('#') end
has_version?()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 30 def has_version? /_history/.match reference.to_s end
parts()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 3 def parts return if contained? if has_version? *base_uri, type, id, _, version = reference.to_s.split '/' else *base_uri, type, id = reference.to_s.split '/' end { base_uri: (base_uri.empty?) ? nil : base_uri.join('/'), type: type, id: id, version: version } end
read()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 57 def read return if !(relative? || absolute?) if relative? || reference == client.full_resource_url(resource: resource_class, id: reference_id) read_client = client else read_client = FHIR::Client.new base_uri, default_format: client.default_format, proxy: client.proxy end resource_class.read(reference_id, read_client) end
reference_id()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 34 def reference_id if contained? reference.to_s[1..-1] else parts[:id] end end
relative?()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 26 def relative? !(reference.blank? || contained? || absolute?) end
resource_type()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 42 def resource_type return if contained? parts[:type] end
version_id()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 47 def version_id return if contained? parts[:version] end
vread()
click to toggle source
# File lib/fhir_client/ext/reference.rb, line 67 def vread return if !(relative? || absolute?) || version_id.blank? if relative? || reference == client.full_resource_url(resource: resource_class, id: reference_id) read_client = client else read_client = FHIR::Client.new base_uri, default_format: client.default_format, proxy: client.proxy end resource_class.vread(reference_id, version_id, read_client) end