do $$ begin
	IF EXISTS(select * from information_schema.columns WHERE table_name='T_CDA_PATOBJ_STAGE_EPICRISIS' and column_name='conclusion')
		then
		ALTER TABLE AKUZ.T_CDA_PATOBJ_STAGE_EPICRISIS ALTER COLUMN "conclusion" TYPE text;
		UPDATE AKUZ.T_CDA_PATOBJ_STAGE_EPICRISIS SET "conclusion" = '' WHERE "conclusion" IS NULL;
		ALTER TABLE AKUZ.T_CDA_PATOBJ_STAGE_EPICRISIS ALTER COLUMN "conclusion" SET NOT NULL;
		END IF;
	IF EXISTS(select * from information_schema.columns WHERE table_name='T_CDA_DGN_CHILD_STAGE_EPICRISIS' and column_name='clinicaldiagnosis')
		then
			ALTER TABLE AKUZ.T_CDA_DGN_CHILD_STAGE_EPICRISIS ALTER COLUMN "clinicaldiagnosis" TYPE text;
			ALTER TABLE AKUZ.T_CDA_DGN_CHILD_STAGE_EPICRISIS ALTER COLUMN "clinicaldiagnosis" DROP NOT NULL;
		END IF;	
end; $$;