Sha256: 835bea0b0a08e42fd48bb74cc1327007ba7371a97a1d8ad89f68c0dacb980d5c

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

module Lifen
  module Communication
    class Channel < Lifen::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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lifen-1.6.8 lib/lifen/communication/channel.rb