DROP PROCEDURE IF EXISTS public.sp_UpdatePatientAddressFromGAR;

CREATE PROCEDURE public.sp_UpdatePatientAddressFromGAR
(
    addressid uuid,
	aoguid uuid default null::uuid,
	houseguid uuid default null::uuid
)
    language plpgsql
as
$$
DECLARE 
    p_addressid uuid := addressid;
    p_aoguid uuid := aoguid;
    p_houseguid uuid := houseguid;
Begin

	update akuz.t_patient_address  
	set 
		AOGUID = Coalesce(p_aoguid,AOGUID), 
		HouseGUID = Coalesce(p_houseguid,HouseGUID), 
		FIASUpdateDate = current_date
	where AddressId = p_addressid;
End;
$$;