Class: LifenFhir::CommunicationRequest
- Inherits:
-
Element
show all
- Defined in:
- lib/lifen_fhir/communication_request.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Element
#fhir_payload_as_reference, #reference
Class Method Details
.find_by_uuid(uuid) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/lifen_fhir/communication_request.rb', line 27
def self.find_by_uuid(uuid)
json = application_client.get("fhir/CommunicationRequest/#{uuid}")
communication_request = new
communication_request.attributes_from_json(json)
communication_request
end
|
Instance Method Details
#attributes_from_json(json) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/lifen_fhir/communication_request.rb', line 36
def attributes_from_json(json)
self.uuid = json["id"]
self.status = json.fetch("status") { "unknown" }
if has_payload?(json)
self.binary = Binary.new.attributes_from_json(Array(json["payload"]).first)
end
if has_category?(json)
self.category = Category.new.attributes_from_json(Array(json["category"]).first)
end
if has_sender?(json)
self.sender = Practitioner.new.attributes_from_json(json["sender"])
end
if has_recipient?(json)
self.recipients = Array(json["recipient"]).map do |recipient_json|
Practitioner.new.attributes_from_json(recipient_json)
end
end
end
|
#send ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/lifen_fhir/communication_request.rb', line 18
def send
json = application_client.post("fhir/CommunicationRequest", fhir_payload)
self.uuid = json["id"]
self.number_communications = Array(json["issue"]).length
self
end
|