Sha256: 3c5fa50cf5415a3571388c62a9c3906a392959a1812ed4a23d28a53c1695b2ec

Contents?: true

Size: 649 Bytes

Versions: 5

Compression:

Stored size: 649 Bytes

Contents

module LifenFhir
  class Channel < Base

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

    def fhir_payload(user)
      raise LifenFhir::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

5 entries across 5 versions & 1 rubygems

Version Path
lifen_fhir-0.4.1 lib/lifen_fhir/channel.rb
lifen_fhir-0.4.0 lib/lifen_fhir/channel.rb
lifen_fhir-0.3.0 lib/lifen_fhir/channel.rb
lifen_fhir-0.2.0 lib/lifen_fhir/channel.rb
lifen_fhir-0.1.1 lib/lifen_fhir/channel.rb