Skip to content

Commit

Permalink
manual build steps work by changing "curated.tsv" for each CURATED bu…
Browse files Browse the repository at this point in the history
…ild target and running "make.sh"
  • Loading branch information
comorbidity committed Jul 25, 2024
1 parent e98082f commit 194a3cb
Show file tree
Hide file tree
Showing 12 changed files with 881,088 additions and 45 deletions.
53 changes: 30 additions & 23 deletions cumulus_library_opioid/vocab/analyze/curate.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,40 @@ order by trim(STR);
delete from curated where (RXCUI like '%RXCUI%');

-- ##############################################
call log('RXNCONSO_curated', 'refresh');
call log('RXNCONSO_curated', 'refresh');

drop table if exists RXNCONSO_curated;
create table RXNCONSO_curated
(
RXCUI varchar(8) NOT NULL,
STR varchar(3000) NOT NULL,
TTY varchar(20) NOT NULL,
SAB varchar(20) NOT NULL,
CODE varchar(50) NOT NULL,
keyword_str varchar(50) NULL,
keyword_len int NULL
);

insert into RXNCONSO_curated
( RXCUI, STR, TTY, SAB, CODE)
select distinct
C.RXCUI, C.STR, C.TTY, C.SAB, C.CODE
from rxnorm.RXNCONSO as C, curated
select C.*
from all_rxcui_str.RXNCONSO_curated C, curated
where C.RXCUI = curated.RXCUI
order by RXCUI,STR;

update RXNCONSO_curated C, keywords K
set
C.keyword_str = K.STR,
C.keyword_len = K.LEN
where lower(C.STR) like concat('%',K.STR, '%');
order by C.RXCUI, C.STR;

-- drop table if exists RXNCONSO_curated;
-- create table RXNCONSO_curated
-- (
-- RXCUI varchar(8) NOT NULL,
-- STR varchar(3000) NOT NULL,
-- TTY varchar(20) NOT NULL,
-- SAB varchar(20) NOT NULL,
-- CODE varchar(50) NOT NULL,
-- keyword_str varchar(50) NULL,
-- keyword_len int NULL
-- );
--
-- insert into RXNCONSO_curated
-- ( RXCUI, STR, TTY, SAB, CODE, keyword_str, keyword_len)
-- select distinct
-- C.RXCUI, C.STR, C.TTY, C.SAB, C.CODE
-- from all_rxcui_str.RXNCONSO as C, curated
-- where C.RXCUI = curated.RXCUI
-- order by RXCUI,STR;
--
-- update RXNCONSO_curated C, keywords K
-- set
-- C.keyword_str = K.STR,
-- C.keyword_len = K.LEN
-- where lower(C.STR) like concat('%',K.STR, '%');

-- call create_index('RXNCONSO_curated','STR(255)');
-- call create_index('RXNCONSO_curated','RXCUI');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
-- Its unclear where all_rxcui_str.RXNCONSO_curated comes from

-- #############################################################################
call log('keywords_db.sql', 'begin');

Expand All @@ -17,6 +15,5 @@ from RXNCONSO_curated
where keyword_len >= 4
order by RXCUI,STR;


-- #############################################################################
call log('keywords_db.sql', 'done');
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
-- ##############################################
call log('all_rxcui_str.sql', 'begin');
call log('all_rxcui_str.sql', 'refresh');

drop table if exists MRCONSO_drug;
create table MRCONSO_drug
select distinct * from umls.MRCONSO
where SAB in ('ATC','CVX','DRUGBANK','GS','MMSL','MMX','MTHCMSFRFMTHSPL','NDDF','RXNORM','SNOMEDCT_US','USP','VANDF');
-- ##############################################
call log('RXNCONSO_curated', 'refresh');

call create_index('MRCONSO_drug', 'CUI');
call create_index('MRCONSO_drug', 'CODE,SAB');
drop table if exists RXNCONSO_curated;
create table RXNCONSO_curated
(
RXCUI varchar(8) NOT NULL,
STR varchar(3000) NOT NULL,
TTY varchar(20) NOT NULL,
SAB varchar(20) NOT NULL,
CODE varchar(50) NOT NULL,
keyword_str varchar(50) NULL,
keyword_len int NULL
);

insert into RXNCONSO_curated
( RXCUI, STR, TTY, SAB, CODE)
select distinct
C.RXCUI, C.STR, C.TTY, C.SAB, C.CODE
from rxnorm.RXNCONSO as C
order by RXCUI,STR;

update RXNCONSO_curated C, keywords K
set
C.keyword_str = K.STR,
C.keyword_len = K.LEN
where lower(C.STR) like concat('%',K.STR, '%');

-- ##############################################
call log('rxcui_str', 'refresh');

drop table if exists rxcui_str;
create table rxcui_str
select distinct RXCUI, STR from rxnorm.RXNCONSO order by RXCUI,STR;

call create_index('rxcui_str', 'RXCUI');
call create_index('rxcui_str', 'STR');
call create_index('rxcui_str', 'STR(255)');

-- ##############################################
call log('MRCONSO_drug', 'refresh');

drop table if exists MRCONSO_drug;
create table MRCONSO_drug
select distinct * from umls.MRCONSO
where SAB in ('ATC','CVX','DRUGBANK','GS','MMSL','MMX','MTHCMSFRFMTHSPL','NDDF','RXNORM','SNOMEDCT_US','USP','VANDF');

call create_index('MRCONSO_drug', 'CUI');
call create_index('MRCONSO_drug', 'CODE,SAB');

-- TODO: deprecated?
-- TODO: deprecated
-- drop table if exists rxcui_cui;
-- create table rxcui_cui
-- select distinct R.RXCUI, U.CUI, U.SAB, U.CODE
Expand Down
Binary file not shown.
Loading

0 comments on commit 194a3cb

Please sign in to comment.