ALTER TABLE akuz.t_covid_registry_stage_ppd
RENAME COLUMN hasnt_complication TO hasnt_complication_old;

ALTER TABLE akuz.t_covid_registry_stage_ppd
ADD COLUMN hasnt_complication integer;

UPDATE akuz.t_covid_registry_stage_ppd
SET hasnt_complication = 
    CASE
        WHEN hasnt_complication_old IS TRUE THEN 1
        WHEN hasnt_complication_old IS FALSE THEN 0
        ELSE NULL
    END;

ALTER TABLE akuz.t_covid_registry_stage_ppd
DROP COLUMN hasnt_complication_old;


ALTER TABLE akuz.t_covid_registry_stage_fpd
RENAME COLUMN hasnt_complication TO hasnt_complication_old;

ALTER TABLE akuz.t_covid_registry_stage_fpd
ADD COLUMN hasnt_complication integer;

UPDATE akuz.t_covid_registry_stage_fpd
SET hasnt_complication = 
    CASE
        WHEN hasnt_complication_old IS TRUE THEN 1
        WHEN hasnt_complication_old IS FALSE THEN 0
        ELSE NULL
    END;

ALTER TABLE akuz.t_covid_registry_stage_fpd
DROP COLUMN hasnt_complication_old;


ALTER TABLE akuz.t_covid_registry_final_clinical_diag
RENAME COLUMN hasnt_complication TO hasnt_complication_old;

ALTER TABLE akuz.t_covid_registry_final_clinical_diag
ADD COLUMN hasnt_complication integer;

UPDATE akuz.t_covid_registry_final_clinical_diag
SET hasnt_complication = 
    CASE
        WHEN hasnt_complication_old IS TRUE THEN 1
        WHEN hasnt_complication_old IS FALSE THEN 0
        ELSE NULL
    END;

ALTER TABLE akuz.t_covid_registry_final_clinical_diag
DROP COLUMN hasnt_complication_old;