UPDATE akuz.T_CDA_MSE_REFERRAL mse
SET "cardnumber" = cast(evbase.AmbulanceCard as varchar(36))
from akuz.T_EVENT_BASE evbase
WHERE mse.EventBase = evbase.EventID AND length(mse.CardNumber) < 36;

ALTER TABLE AKUZ.T_CDA_MSE_REFERRAL ALTER COLUMN "cardnumber" SET DATA TYPE uuid USING "cardnumber"::uuid;
ALTER TABLE akuz.T_CDA_MSE_REFERRAL ALTER COLUMN "cardnumber" SET NOT NULL;