From 1b3b1cbf82fa50ceffb2565db8a70b341c7c4413 Mon Sep 17 00:00:00 2001 From: LoraLingrey-TriNetX Date: Wed, 17 Mar 2021 10:17:41 -0400 Subject: [PATCH] TNX v3.2 Update Adding extra delete from n3c_control_map --- PhenotypeScripts/N3C_phenotype_trinetx.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/PhenotypeScripts/N3C_phenotype_trinetx.sql b/PhenotypeScripts/N3C_phenotype_trinetx.sql index 68474ed..77685bb 100644 --- a/PhenotypeScripts/N3C_phenotype_trinetx.sql +++ b/PhenotypeScripts/N3C_phenotype_trinetx.sql @@ -106,7 +106,7 @@ CREATE TABLE IF NOT EXISTS data_a.n3c_control_map ( SELECT CURRENT_TIMESTAMP as date_time, 'UPDATING PHENO VERSION TABLE' as log_entry; TRUNCATE TABLE :TNX_SCHEMA.n3c_pheno_version; INSERT INTO :TNX_SCHEMA.n3c_pheno_version -SELECT '3.1'; +SELECT '3.2'; --------------------------------------------------------------------------------------------------------- -- 3. Clear out existing tables @@ -421,6 +421,9 @@ DELETE FROM data_a.n3c_control_map WHERE control_patient_id NOT IN (SELECT patie -- Remove if case no longer meets phenotype criteria DELETE FROM data_a.n3c_control_map WHERE case_patient_id NOT IN (SELECT patient_id FROM :TNX_SCHEMA.n3c_case_cohort); +-- Remove if control patient ID is null +DELETE FROM data_a.n3c_control_map WHERE control_patient_id IS NULL; + --------------------------------------------------------------------------------------------------------- -- 8. Create Additional Control Tables ---------------------------------------------------------------------------------------------------------