ALTER TABLE AKUZ.T_DISPANSERISATION_INIT ADD "attendingpost" uuid NULL;

UPDATE AKUZ.T_DISPANSERISATION_INIT di
SET AttendingPost = mr.Post
FROM AKUZ.T_MEDICAL_RECORD mr
WHERE di.MedicalRecordID = mr.MedicalRecordID;

ALTER TABLE AKUZ.T_DISPANSERISATION_INIT ALTER COLUMN "attendingpost" SET NOT NULL;

ALTER TABLE AKUZ.T_DISPANSERISATION_INIT ADD CONSTRAINT FK_T_POST_T_DISPANSERISATION_INIT_AttendingPost
FOREIGN KEY("attendingpost") REFERENCES AKUZ.T_POST (ResourceID);
