--T_EHR_RUS_2ERNPH8TQ8
update EHR.T_EHR_RUS_2ERNPH8TQ8 ehr
set 
	ehr.START_DATE = 
		case 
			when ehr.START_DATE <> '' then to_date(ehr.START_DATE, 'DD.MM.YYYY')
			else null
		end,
	ehr.END_DATE = 
		case 
			when ehr.END_DATE <> '' then to_date(ehr.END_DATE, 'DD.MM.YYYY')
			else null
		end;

ALTER TABLE EHR.T_EHR_RUS_2ERNPH8TQ8 ALTER COLUMN "start_date" SET DATA TYPE timestamp;
ALTER TABLE EHR.T_EHR_RUS_2ERNPH8TQ8 ALTER COLUMN "end_date" SET DATA TYPE timestamp;

--T_EHR_RUS_2M69I03GTD
update EHR.T_EHR_RUS_2M69I03GTD ehr
set ehr.DATE_REGISTRATION = 
	case 
		when ehr.DATE_REGISTRATION <> '' then to_date(ehr.DATE_REGISTRATION, 'DD.MM.YYYY')
		else null
	end;
ALTER TABLE EHR.T_EHR_RUS_2M69I03GTD ALTER COLUMN "date_registration" SET DATA TYPE timestamp;

-- T_EHR_RUS_EP3FVD4DUL
update EHR.T_EHR_RUS_EP3FVD4DUL ehr
set ehr.depart_liquidation_date = 
		case 
			when ehr.depart_liquidation_date <> '' then to_date(ehr.depart_liquidation_date, 'DD.MM.YYYY')
			else null
		end,
	ehr.hospital_liquidation_date = 
		case 
			when ehr.hospital_liquidation_date <> '' then to_date(ehr.hospital_liquidation_date, 'DD.MM.YYYY')
			else null
		end;

ALTER TABLE EHR.T_EHR_RUS_EP3FVD4DUL ALTER COLUMN "depart_liquidation_date" SET DATA TYPE timestamp;
ALTER TABLE EHR.T_EHR_RUS_EP3FVD4DUL ALTER COLUMN "hospital_liquidation_date" SET DATA TYPE timestamp;

--T_EHR_RUS_FRV440
update EHR.T_EHR_RUS_FRV440 ehr
set ehr.DATE_END = 
		case 
			when ehr.DATE_END <> '' then convert(datetime, ehr.DATE_END, 'DD.MM.YYYY')
			else null
		end;

ALTER TABLE EHR.T_EHR_RUS_FRV440 ALTER COLUMN "date_end" SET DATA TYPE timestamp;

--T_EHR_RUS_MDR308 
update EHR.T_EHR_RUS_MDR308 ehr
set ehr.createDate = 
		case 
			when ehr.createDate <> '' then to_date(ehr.createDate, 'DD.MM.YYYY')
			else null
		end,
	ehr.deleteDate = 
		case 
			when ehr.deleteDate <> '' then to_date(ehr.deleteDate, 'DD.MM.YYYY')
			else null
		end,
	ehr.modifyDate = 
		case 
			when ehr.modifyDate <> '' then to_date(ehr.modifyDate, 'DD.MM.YYYY')
			else null
		end;

ALTER TABLE EHR.T_EHR_RUS_MDR308 ALTER COLUMN "createdate" SET DATA TYPE timestamp;
ALTER TABLE EHR.T_EHR_RUS_MDR308 ALTER COLUMN "deletedate" SET DATA TYPE timestamp;
ALTER TABLE EHR.T_EHR_RUS_MDR308 ALTER COLUMN "modifydate" SET DATA TYPE timestamp;

--EHR_RUS_SF8U7PKK0U 
update EHR.T_EHR_RUS_SF8U7PKK0U ehr
set ehr.Registration_date = 
		case 
			when ehr.Registration_date <> '' then to_date(ehr.Registration_date, 'DD.MM.YYYY')
			else null
		end,
	ehr.Registration_date_end = 
		case 
			when ehr.Registration_date_end <> '' then to_date(ehr.Registration_date_end, 'DD.MM.YYYY')
			else null
		end;

ALTER TABLE EHR.T_EHR_RUS_SF8U7PKK0U ALTER COLUMN "registration_date" SET DATA TYPE timestamp;
ALTER TABLE EHR.T_EHR_RUS_SF8U7PKK0U ALTER COLUMN "registration_date_end" SET DATA TYPE timestamp;