Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that the environ variable of database location is used through out. #8

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
49 changes: 49 additions & 0 deletions databases/cpt_descriptions.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
create table cpt_descriptions as
with short_desc as (
select
code,
str as short_desc
from mrconso
where SAB = 'CPT' and tty='AB' ),
consumer_desc as (
select
code,
str as consumer_desc
from mrconso
where SAB = 'CPT' and tty='ETCF'
),
clinician_desc as (
select
code,
str as clinician_desc
from mrconso
where SAB = 'CPT' and tty='ETCLIN'
),
medium_descriptor as (
select
code,
str as medium_desc
from mrconso
where SAB = 'CPT' and tty='SY'),
full_descriptor as (
select
code,
str as full_desc
from mrconso
where SAB = 'CPT' and tty='PT'
)

SELECT
sd.code,
short_desc,
consumer_desc,
clinician_desc,
medium_desc,
full_desc

from short_desc sd
join consumer_desc cd on sd.code = cd.code
join clinician_desc cl_d on sd.code = cl_d.code
join medium_descriptor md on sd.code = md.code
join full_descriptor fd on sd.code = fd.code
;
2 changes: 2 additions & 0 deletions databases/umls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ if [ ! -e umls.db ]; then
sqlite3 umls.db "ALTER TABLE descriptions ADD COLUMN STY TEXT"
sqlite3 umls.db "CREATE INDEX X_CUI_desc ON descriptions (CUI)"
sqlite3 umls.db "UPDATE descriptions SET STY = (SELECT GROUP_CONCAT(MRSTY.TUI, '|') FROM MRSTY WHERE MRSTY.CUI = descriptions.CUI GROUP BY MRSTY.CUI)"
sqlite3 umls.db "CREATE INDEX sab_tty on mrconso(sab,tty)"
sqlite3 umls.db ".read databases/cpt_descriptions.sql"
else
echo "=> umls.db already exists"
fi
Expand Down