ALTER TABLE AKUZ.T_CDA_SECTION_DRIVER_LICENSE_RESINFO ADD "noindications" boolean NULL;
UPDATE AKUZ.T_CDA_SECTION_DRIVER_LICENSE_RESINFO SET "noindications" = false;
ALTER TABLE AKUZ.T_CDA_SECTION_DRIVER_LICENSE_RESINFO ALTER COLUMN "noindications" SET NOT NULL;

ALTER TABLE AKUZ.T_CDA_SECTION_DRIVER_LICENSE_RESINFO ADD "norestrictions" boolean NULL;
UPDATE AKUZ.T_CDA_SECTION_DRIVER_LICENSE_RESINFO SET "norestrictions" = false;
ALTER TABLE AKUZ.T_CDA_SECTION_DRIVER_LICENSE_RESINFO ALTER COLUMN "norestrictions" SET NOT NULL;

ALTER TABLE AKUZ.T_CDA_SECTION_DRIVER_LICENSE_RESINFO ADD "nocontraindications" boolean NULL;
UPDATE AKUZ.T_CDA_SECTION_DRIVER_LICENSE_RESINFO SET "nocontraindications" = false;
ALTER TABLE AKUZ.T_CDA_SECTION_DRIVER_LICENSE_RESINFO ALTER COLUMN "nocontraindications" SET NOT NULL;

update akuz.t_CDA_SECTION_DRIVER_LICENSE_RESINFO resinfo
set NoIndications = true
where not exists (
    select 1 
    from akuz.t_CDA_DRIVER_LICENSE_RESINFO_INDICATIONS_LINK indication 
    where indication.CdaSectionDriverLicenseResinfo = resinfo.CdaSectionDriverLicenseResinfoID);

update akuz.t_CDA_SECTION_DRIVER_LICENSE_RESINFO resinfo
set NoRestrictions = true
where not exists (
    select 1 
    from akuz.t_CDA_DRIVER_LICENSE_RESINFO_RESTRICTIONS_LINK restriction 
    where restriction.CdaSectionDriverLicenseResinfo = resinfo.CdaSectionDriverLicenseResinfoID);

update akuz.t_CDA_SECTION_DRIVER_LICENSE_RESINFO resinfo
set NoContraindications = case when ehr.IdEHR = 39 then true else false end
from akuz.t_CDA_DRIVER_LICENSE_RESINFO_CONCLUSION_LINK conclusion
join ehr.T_EHR_RUS_876TV2P893 ehr on ehr.EhrRusID = conclusion.EhrRus876TV2P893
where conclusion.CdaSectionDriverLicenseResinfo = resinfo.CdaSectionDriverLicenseResinfoID;