Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Use i.s.o. the back quote character, the backspace character as escape c... #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ddl/postgres/tm_cz/functions/i2b2_create_concept_counts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ???
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions ddl/postgres/tm_cz/functions/i2b2_delete_all_nodes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ddl/postgres/tm_cz/functions/i2b2_extend_clinical_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ddl/postgres/tm_cz/functions/i2b2_fill_in_tree.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions ddl/postgres/tm_cz/functions/i2b2_load_clinical_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ddl/postgres/tm_cz/functions/i2b2_process_acgh_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ddl/postgres/tm_cz/functions/i2b2_process_mrna_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ddl/postgres/tm_cz/functions/i2b2_process_rnaseq_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down