Class: Lifen::Channel

Inherits:
Base
  • Object
show all
Defined in:
lib/lifen/channel.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_json(json, type = nil) ⇒ Object



26
27
28
# File 'lib/lifen/channel.rb', line 26

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

Instance Method Details

#fhir_payload(user) ⇒ Object

Raises:



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/lifen/channel.rb', line 8

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

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

#valid?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/lifen/channel.rb', line 22

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