ALTER TABLE AKUZ.T_AMBULANCE_CARD ADD COLUMN IF NOT EXISTS State uuid;

 update ac
 set ac.State = (select r.State 
				from akuz.T_REGISTRATION r
				where r.LpuMain = ac.CardLpu
				and r.Status = 1 
				and r.RegistrationID = fn_GetRegistration(ac.Patient, null, null)
				limit 1)
 from AKUZ.T_AMBULANCE_CARD ac;