lib/lifen/user.rb in lifen-1.6.4 vs lib/lifen/user.rb in lifen-1.6.5

- old
+ new

@@ -136,9 +136,30 @@ end user end + def create_channel(params) + filtered_params = {"resourceType" => "Practitioner"} + + address = { + "line": Array(params[:lines]), + "city": params[:city], + "postalCode": params[:postal_code], + "country": params[:country] + } + + filtered_params[params[:type]] = address + + json = application_client.post("fhir/Practitioner/#{uuid}/$add-address", filtered_params) + + channel = Communication::Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: "#{Array(params[:lines])[0]}, #{params[:postal_code]} #{params[:city]}") + + self.channels << channel + + channel + end + private def application_client @application_client ||= AppAuthenticatedClient.new end \ No newline at end of file