Sha256: 2e7a444ece3b04654bec21b84a3004c8962f65c273ab77fc015b79520c97fb01
Contents?: true
Size: 1.79 KB
Versions: 2
Compression:
Stored size: 1.79 KB
Contents
module LifenFhir class Practitioner < Element attribute :channels, [Channel] attribute :last_name, String attribute :first_name, String attribute :rpps, String def fhir_payload { reference: reference } end def self.find_by_rpps(rpps) json = application_client.get("fhir/Practitioner/?identifier=#{rpps}") raise "Practitioner not found" if Array(json["entry"]).size != 1 user_json = Array(json["entry"]).first.fetch("resource") { {} } user_json[:uuid] = user_json["id"] user = new(user_json) Array(user_json["telecom"]).each do |telecom_json| user.channels << Channel.from_json(telecom_json, "telecom") end Array(user_json["address"]).each do |address_json| user.channels << Channel.from_json(address_json, "address") end user end def create_address(params) filtered_params = {"resourceType" => "Practitioner"} address = Address.new(params) filtered_params[params[:type]] = address.fhir_payload json = application_client.post("fhir/#{reference}/$add-address", filtered_params) channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: "#{Array(params[:lines]).join(", ")}, #{params[:postal_code]} #{params[:city]}") self.channels << channel channel end def create_telecom(params) filtered_params = {"resourceType" => "Practitioner"} telecom = Telecom.new(params) filtered_params[params[:type]] = telecom.fhir_payload json = application_client.post("fhir/#{reference}/$add-telecom", filtered_params) channel = Channel.new(uuid: json["issue"][0]["id"], type: params[:type], value: params[:value]) self.channels << channel channel end private end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lifen_fhir-0.7.1 | lib/lifen_fhir/practitioner.rb |
lifen_fhir-0.7.0 | lib/lifen_fhir/practitioner.rb |