Sha256: e489670251f9030c15b62f80a61ebca1032ef99356cf714d99406e58c60cccc5

Contents?: true

Size: 512 Bytes

Versions: 7

Compression:

Stored size: 512 Bytes

Contents

module FHIR
  class Reference
    def contained?
      reference.to_s.start_with?('#')
    end

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

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fhir_client-3.0.2 lib/fhir_client/ext/reference.rb
fhir_client-3.0.1 lib/fhir_client/ext/reference.rb
fhir_client-1.8.0 lib/fhir_client/ext/reference.rb
fhir_client-1.6.10 lib/fhir_client/ext/reference.rb
fhir_client-1.6.9 lib/fhir_client/ext/reference.rb
fhir_client-1.6.8 lib/fhir_client/ext/reference.rb
fhir_client-1.6.7 lib/fhir_client/ext/reference.rb