do $$
begin
	if exists 
	(
		select * from pg_proc p
		where p.proname = 'sp_UpdatePatientAddressFromGAR'
	)
	then
		drop function akuz.sp_UpdatePatientAddressFromGAR;
	end if;
end;
$$ language plpgsql;


CREATE or Replace Function akuz.sp_UpdatePatientAddressFromGAR(
	"AOGUID" UUID,
	"HouseGUID" UUID,
	"AddressId" UUID)
RETURNS void As 
$$
Begin
		update akuz.t_patient_address  
		set 
			AOGUID = Coalesce("AOGUID",AOGUID), 
			HouseGUID = Coalesce("HouseGUID",HouseGUID), 
			FIASUpdateDate = current_date
		where AddressId = "AddressId";
End;
$$ Language plpgsql;