diff --git a/ddl/postgres/tm_cz/functions/i2b2_create_concept_counts.sql b/ddl/postgres/tm_cz/functions/i2b2_create_concept_counts.sql index aa1abe3a..1062e1ac 100644 --- a/ddl/postgres/tm_cz/functions/i2b2_create_concept_counts.sql +++ b/ddl/postgres/tm_cz/functions/i2b2_create_concept_counts.sql @@ -53,7 +53,7 @@ BEGIN begin delete from i2b2demodata.concept_counts - where concept_path like path || '%' escape '`'; + where concept_path like path || '%' escape E'\b'; get diagnostics rowCt := ROW_COUNT; exception when others then @@ -83,9 +83,9 @@ BEGIN ,i2b2metadata.i2b2 la ,i2b2demodata.observation_fact tpm ,i2b2demodata.patient_dimension p - where fa.c_fullname like path || '%' escape '`' + where fa.c_fullname like path || '%' escape E'\b' and substr(fa.c_visualattributes,2,1) != 'H' - and la.c_fullname like fa.c_fullname || '%' escape '`' + and la.c_fullname like fa.c_fullname || '%' escape E'\b' and la.c_visualattributes like 'L%' and tpm.patient_num = p.patient_num and la.c_basecode = tpm.concept_cd -- outer join in oracle ??? @@ -110,7 +110,7 @@ BEGIN begin update i2b2metadata.i2b2 set c_visualattributes = substr(c_visualattributes,1,1) || 'H' || substr(c_visualattributes,3,1) - where c_fullname like path || '%' escape '`' + where c_fullname like path || '%' escape E'\b' and (not exists (select 1 from concept_counts nc where c_fullname = nc.concept_path) diff --git a/ddl/postgres/tm_cz/functions/i2b2_delete_all_nodes.sql b/ddl/postgres/tm_cz/functions/i2b2_delete_all_nodes.sql index 1557a502..4672cf10 100644 --- a/ddl/postgres/tm_cz/functions/i2b2_delete_all_nodes.sql +++ b/ddl/postgres/tm_cz/functions/i2b2_delete_all_nodes.sql @@ -55,7 +55,7 @@ Begin begin DELETE FROM i2b2demodata.OBSERVATION_FACT WHERE - concept_cd IN (SELECT C_BASECODE FROM i2b2metadata.I2B2 WHERE C_FULLNAME LIKE PATH || '%' escape '`'); + concept_cd IN (SELECT C_BASECODE FROM i2b2metadata.I2B2 WHERE C_FULLNAME LIKE PATH || '%' escape E'\b'); get diagnostics rowCt := ROW_COUNT; exception when others then @@ -73,7 +73,7 @@ Begin --CONCEPT DIMENSION begin DELETE FROM i2b2demodata.CONCEPT_DIMENSION - WHERE CONCEPT_PATH LIKE path || '%' escape '`'; + WHERE CONCEPT_PATH LIKE path || '%' escape E'\b'; get diagnostics rowCt := ROW_COUNT; exception when others then @@ -91,7 +91,7 @@ Begin --I2B2 begin DELETE FROM i2b2metadata.i2b2 - WHERE C_FULLNAME LIKE PATH || '%' escape '`'; + WHERE C_FULLNAME LIKE PATH || '%' escape E'\b'; get diagnostics rowCt := ROW_COUNT; exception when others then @@ -109,7 +109,7 @@ Begin --i2b2_secure begin DELETE FROM i2b2metadata.i2b2_secure - WHERE C_FULLNAME LIKE PATH || '%' escape '`'; + WHERE C_FULLNAME LIKE PATH || '%' escape E'\b'; get diagnostics rowCt := ROW_COUNT; exception when others then @@ -128,7 +128,7 @@ Begin --concept_counts begin DELETE FROM i2b2demodata.concept_counts - WHERE concept_path LIKE PATH || '%' escape '`'; + WHERE concept_path LIKE PATH || '%' escape E'\b'; get diagnostics rowCt := ROW_COUNT; exception when others then diff --git a/ddl/postgres/tm_cz/functions/i2b2_extend_clinical_data.sql b/ddl/postgres/tm_cz/functions/i2b2_extend_clinical_data.sql index c0db1ae4..ab220f18 100644 --- a/ddl/postgres/tm_cz/functions/i2b2_extend_clinical_data.sql +++ b/ddl/postgres/tm_cz/functions/i2b2_extend_clinical_data.sql @@ -62,7 +62,7 @@ Declare delNodes CURSOR is select distinct c_fullname from i2b2metadata.i2b2 - where c_fullname like topNode || '%' escape '`' + where c_fullname like topNode || '%' escape E'\b' and substr(c_visualattributes,2,1) = 'H'; -- cursor to determine if any leaf nodes exist in i2b2 that are not used in this reload (node changes from text to numeric or numeric to text) @@ -71,7 +71,7 @@ Declare select l.c_fullname from i2b2metadata.i2b2 l where l.c_visualattributes like 'L%' - and l.c_fullname like topNode || '%' escape '`' + and l.c_fullname like topNode || '%' escape E'\b' and l.c_fullname not in (select t.leaf_node from tm_wz.wt_trial_nodes t @@ -1059,7 +1059,7 @@ select count(*) into pExists from i2b2demodata.observation_fact of where (of.pat and t.leaf_node = i.c_fullname and not exists -- don't insert if lower level node exists (select 1 from tm_wz.wt_trial_nodes x - where x.leaf_node like t.leaf_node || '%_' escape '`') + where x.leaf_node like t.leaf_node || '%_' escape E'\b') and a.data_value is not null; get diagnostics rowCt := ROW_COUNT; exception diff --git a/ddl/postgres/tm_cz/functions/i2b2_fill_in_tree.sql b/ddl/postgres/tm_cz/functions/i2b2_fill_in_tree.sql index 6cade9e3..ff6ae80b 100644 --- a/ddl/postgres/tm_cz/functions/i2b2_fill_in_tree.sql +++ b/ddl/postgres/tm_cz/functions/i2b2_fill_in_tree.sql @@ -43,7 +43,7 @@ Declare --Trimming off the last node as it would never need to be added. select distinct substr(c_fullname, 1,instr(c_fullname,'\',-2,1)) as c_fullname from i2b2metadata.i2b2 - where c_fullname like path || '%' escape '`'; + where c_fullname like path || '%' escape E'\b'; BEGIN diff --git a/ddl/postgres/tm_cz/functions/i2b2_load_clinical_data.sql b/ddl/postgres/tm_cz/functions/i2b2_load_clinical_data.sql index b52f12dc..72257e3c 100644 --- a/ddl/postgres/tm_cz/functions/i2b2_load_clinical_data.sql +++ b/ddl/postgres/tm_cz/functions/i2b2_load_clinical_data.sql @@ -55,7 +55,7 @@ Declare delNodes CURSOR is select distinct c_fullname from i2b2metadata.i2b2 - where c_fullname like topNode || '%' escape '`' + where c_fullname like topNode || '%' escape E'\b' and substr(c_visualattributes,2,1) = 'H'; -- cursor to determine if any leaf nodes exist in i2b2 that are not used in this reload (node changes from text to numeric or numeric to text) @@ -64,7 +64,7 @@ Declare select l.c_fullname from i2b2metadata.i2b2 l where l.c_visualattributes like 'L%' - and l.c_fullname like topNode || '%' escape '`' + and l.c_fullname like topNode || '%' escape E'\b' and l.c_fullname not in (select t.leaf_node from tm_wz.wt_trial_nodes t @@ -512,11 +512,13 @@ BEGIN select tm_cz.cz_write_audit(jobId,databaseName,procedureName,'Set visit_name to null when only DATALABE in category_cd',rowCt,stepCt,'Done') into rtnCd; -- change any % to Pct and & and + to ' and ' and _ to space in data_label only + -- change any % to Pct and & and + to ' and ' and \ to space in data_value only + -- -- changing \ to space is to prevent data value to be interpreteted as a (sub)path begin update tm_wz.wrk_clinical_data set data_label=replace(replace(replace(replace(data_label,'%',' Pct'),'&',' and '),'+',' and '),'_',' ') - ,data_value=replace(replace(replace(data_value,'%',' Pct'),'&',' and '),'+',' and ') + ,data_value=replace(replace(replace(replace(data_value,'%',' Pct'),'&',' and '),'+',' and '),'\',' ') ,category_cd=replace(replace(category_cd,'%',' Pct'),'&',' and ') ,category_path=replace(replace(category_path,'%',' Pct'),'&',' and '); exception @@ -1136,7 +1138,7 @@ BEGIN and t.leaf_node = i.c_fullname and not exists -- don't insert if lower level node exists (select 1 from tm_wz.wt_trial_nodes x - where x.leaf_node like t.leaf_node || '%_' escape '`') + where x.leaf_node like t.leaf_node || '%_' escape E'\b') and a.data_value is not null; get diagnostics rowCt := ROW_COUNT; exception @@ -1158,8 +1160,8 @@ BEGIN with upd as (select p.c_fullname, count(*) as nbr_children from i2b2metadata.i2b2 p ,i2b2metadata.i2b2 c - where p.c_fullname like topNode || '%' escape '`' - and c.c_fullname like p.c_fullname || '%' escape '`' + where p.c_fullname like topNode || '%' escape E'\b' + and c.c_fullname like p.c_fullname || '%' escape E'\b' group by p.c_fullname) update i2b2metadata.i2b2 b set c_visualattributes=case when upd.nbr_children = 1 @@ -1173,7 +1175,7 @@ BEGIN where b.c_fullname = upd.c_fullname and b.c_fullname in (select x.c_fullname from i2b2 x - where x.c_fullname like topNode || '%' escape '`'); + where x.c_fullname like topNode || '%' escape E'\b'); get diagnostics rowCt := ROW_COUNT; exception when others then diff --git a/ddl/postgres/tm_cz/functions/i2b2_process_acgh_data.sql b/ddl/postgres/tm_cz/functions/i2b2_process_acgh_data.sql index 3a7a505e..daedb9a5 100644 --- a/ddl/postgres/tm_cz/functions/i2b2_process_acgh_data.sql +++ b/ddl/postgres/tm_cz/functions/i2b2_process_acgh_data.sql @@ -74,7 +74,7 @@ Declare delNodes CURSOR is select distinct c_fullname from i2b2metadata.i2b2 - where c_fullname like topNode || '%' escape '`' + where c_fullname like topNode || '%' escape E'\b' and substr(c_visualattributes,2,1) = 'H'; BEGIN diff --git a/ddl/postgres/tm_cz/functions/i2b2_process_mrna_data.sql b/ddl/postgres/tm_cz/functions/i2b2_process_mrna_data.sql index c6611eb3..ccda965f 100644 --- a/ddl/postgres/tm_cz/functions/i2b2_process_mrna_data.sql +++ b/ddl/postgres/tm_cz/functions/i2b2_process_mrna_data.sql @@ -74,7 +74,7 @@ Declare delNodes CURSOR is select distinct c_fullname from i2b2metadata.i2b2 - where c_fullname like topNode || '%' escape '`' + where c_fullname like topNode || '%' escape E'\b' and substr(c_visualattributes,2,1) = 'H'; BEGIN diff --git a/ddl/postgres/tm_cz/functions/i2b2_process_rnaseq_data.sql b/ddl/postgres/tm_cz/functions/i2b2_process_rnaseq_data.sql index 41e5603b..38b2b257 100644 --- a/ddl/postgres/tm_cz/functions/i2b2_process_rnaseq_data.sql +++ b/ddl/postgres/tm_cz/functions/i2b2_process_rnaseq_data.sql @@ -76,7 +76,7 @@ Declare delNodes CURSOR is select distinct c_fullname from i2b2metadata.i2b2 - where c_fullname like topNode || '%' escape '`' + where c_fullname like topNode || '%' escape E'\b' and substr(c_visualattributes,2,1) = 'H'; BEGIN