drop procedure if exists public.sp_SetHospitalRegisterMainItems;
CREATE procedure public.sp_SetHospitalRegisterMainItems
(
	"HospitalReestrMain" UUID
)
AS
$$
BEGIN
	update akuz.T_MOVEMENT_RESULT t 
	set HospitalReestrItem = t1.HospitalReestrItemID
	from akuz.T_HOSPITAL_REESTR_ITEM t1 
	where t1.MovementResult = t.MedicalRecordID 
	and t1.HospitalReestrMain = "HospitalReestrMain";
END;
$$ LANGUAGE plpgsql;