Class: Lifen::Communication

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(uuid) ⇒ Object

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/lifen/communication.rb', line 28

def self.find(uuid)
  json = application_client.get("fhir/Communication/#{uuid}")

  resource_type = json["resourceType"]

  raise Error, "Invalid resourceType (#{resource_type})" if resource_type != "Communication"

  attributes = {}

  attributes[:uuid]                 = json["id"]
  attributes[:status]               = json["status"]
  attributes[:sent_at]              = json["sent"]
  attributes[:received_at]          = json["received"]

  attributes[:sender]               = User.from_json(json["sender"])
  attributes[:recipient]            = User.from_json(Array(json["recipient"]).first)

  new(attributes)
end

Instance Method Details

#sendObject



20
21
22
23
24
25
26
# File 'lib/lifen/communication.rb', line 20

def send
  json = application_client.post("fhir/CommunicationRequest", fhir_payload)

  self.uuid = json["id"]

  self
end