-- Tables

-- Alters

ALTER TABLE AKUZ.T_VISION_ACUITY ADD "lightflashescriticalfrequency_r" integer NULL;

ALTER TABLE AKUZ.T_VISION_ACUITY ADD "lightflashescriticalfrequency_l" integer NULL;

ALTER TABLE AKUZ.T_VISION_DIAGNOSTICS ADD "retinalvisualacuity_r" decimal(7, 3) NULL;

ALTER TABLE AKUZ.T_VISION_DIAGNOSTICS ADD "retinalvisualacuity_l" decimal(7, 3) NULL;

update AKUZ.T_VISION_ACUITY va
set "lightflashescriticalfrequency_r" = vd."lightflashescriticalfrequency_r", "lightflashescriticalfrequency_l" = vd."lightflashescriticalfrequency_l"
from AKUZ.T_VISION_DIAGNOSTICS vd 
where vd.MedicalRecordId = va.VisionDiagnostics;

update AKUZ.T_VISION_DIAGNOSTICS vd
set "retinalvisualacuity_r" = va."retinalvisualacuity_r", "retinalvisualacuity_l" = va."retinalvisualacuity_l"
from AKUZ.T_VISION_ACUITY va 
where vd.MedicalRecordId = va.VisionDiagnostics;

ALTER TABLE AKUZ.T_VISION_ACUITY DROP COLUMN "retinalvisualacuity_r";
ALTER TABLE AKUZ.T_VISION_ACUITY DROP COLUMN "retinalvisualacuity_l";
ALTER TABLE AKUZ.T_VISION_DIAGNOSTICS DROP COLUMN "lightflashescriticalfrequency_r";
ALTER TABLE AKUZ.T_VISION_DIAGNOSTICS DROP COLUMN "lightflashescriticalfrequency_l";

