Class: LifenFhir::Channel
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Element
#attributes_from_json, #fhir_payload_as_reference, #reference
Class Method Details
.from_json(json, type = nil) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/lifen_fhir/channel.rb', line 27
def self.from_json(json, type = nil)
if type == "telecom"
telecom = Telecom.new.attributes_from_json(json)
new(uuid: telecom.uuid, type: type, value: telecom.value)
else
new(uuid: json["id"], type: type, value: "#{Array(json["line"]).join(", ")}, #{json["postalCode"]} #{json["city"]}")
end
end
|
Instance Method Details
#fhir_payload(user) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/lifen_fhir/channel.rb', line 9
def fhir_payload(user)
raise LifenFhir::Error, "Invalid channel: an UUID is required" if !valid?
{
id: user.uuid,
resourceType: "Practitioner",
type => [
{
id: uuid
}
]
}
end
|
#valid? ⇒ Boolean
23
24
25
|
# File 'lib/lifen_fhir/channel.rb', line 23
def valid?
uuid and uuid.length != 0
end
|