Sha256: a7acfa2ab9707ffc8eb63b79153bcae294e8ed606e12eaa0a207bd27ad134942

Contents?: true

Size: 641 Bytes

Versions: 7

Compression:

Stored size: 641 Bytes

Contents

module Lifen
  class Channel < Base

    attribute :uuid, String
    attribute :type, String
    attribute :value, String

    def fhir_payload(user)
      raise Lifen::Error, "Invalid channel: an UUID is required" if !valid?

      {
        id: user.uuid,
        resourceType: "Practitioner",
        type => [
          {
            id: uuid
          }
        ]
      }
    end

    def valid?
      uuid and uuid.length != 0
    end

    def self.from_json(json, type = nil)
      new(uuid: json["id"], type: type, value: json["value"] || "#{Array(json["line"]).join(", ")}, #{json["postalCode"]} #{json["city"]}")
    end

  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
lifen-fhir-0.1.0 lib/lifen/channel.rb
lifen-3.0.0 lib/lifen/channel.rb
lifen-2.4.0 lib/lifen/channel.rb
lifen-2.3.0 lib/lifen/channel.rb
lifen-2.2.0 lib/lifen/channel.rb
lifen-2.1.0 lib/lifen/channel.rb
lifen-2.0.0 lib/lifen/channel.rb