-- Tables

-- Alters

ALTER TABLE AKUZ.T_ASSOCIATED_DISEASE ADD "typedisease" integer NULL;

UPDATE AKUZ.T_ASSOCIATED_DISEASE SET "typedisease" = 0;

ALTER TABLE AKUZ.T_ASSOCIATED_DISEASE ALTER COLUMN "typedisease" SET NOT NULL;

INSERT INTO AKUZ.T_ASSOCIATED_DISEASE (MedicalExamination, AssociatedDiseaseID, Mkb, Diagnosis, TypeDisease) 
									SELECT me.MedicalRecordID, uuid_generate_v4(), me.ComplicationMkb, me.ComplicationDiagnosis, 1
									FROM AKUZ.T_MEDICAL_EXAMINATION me
									WHERE me.ComplicationMkb is NOT NULL And me.ComplicationDiagnosis is NOT NULL;

ALTER TABLE AKUZ.T_MEDICAL_EXAMINATION DROP COLUMN "complicationmkb";

ALTER TABLE AKUZ.T_MEDICAL_EXAMINATION DROP COLUMN "complicationdiagnosis";
