lib/lifen/user.rb in lifen-2.0.0 vs lib/lifen/user.rb in lifen-2.1.0

- old
+ new

@@ -14,10 +14,11 @@ attribute :profile_picture_url, String attribute :rpps, String @@create_lock = Mutex.new + def flows Lifen::Flows.new(user: self).all end def create(persisted_lifen_uuid: ->(user) {}, save_to_db: ->(user) {}) @@ -136,11 +137,11 @@ end user end - def create_channel(params) + def create_address(params) filtered_params = {"resourceType" => "Practitioner"} address = { "line": Array(params[:lines]), "city": params[:city], @@ -157,18 +158,40 @@ self.channels << channel channel end + alias_method :create_channel, :create_address + def self.from_json(json) reference = json["reference"] uuid = reference.gsub("Practitioner/", "") new(uuid: uuid) end + def create_telecom(params) + filtered_params = {"resourceType" => "Practitioner"} + + telecom = { + "system": params[:system], + "value": params[:value] + } + + filtered_params[params[:type]] = telecom + + json = application_client.post("fhir/Practitioner/#{uuid}/$add-telecom", filtered_params) + + channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: params[:value]) + + self.channels << channel + + channel + + end + private def application_client @application_client ||= AppAuthenticatedClient.new end @@ -176,6 +199,6 @@ def self.application_client @application_client ||= AppAuthenticatedClient.new end end -end \ No newline at end of file +end