lib/lifen/communication/channel.rb in lifen-1.6.6 vs lib/lifen/communication/channel.rb in lifen-1.6.7

- old
+ new

@@ -5,18 +5,24 @@ attribute :uuid, String attribute :type, String attribute :value, String def fhir_payload(user) + raise Lifen::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"] || "#{json["line"].join(", ")}, #{json["postalCode"]} #{json["city"]}") end \ No newline at end of file