diff --git a/databases/cpt_descriptions.sql b/databases/cpt_descriptions.sql new file mode 100644 index 0000000..18be413 --- /dev/null +++ b/databases/cpt_descriptions.sql @@ -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 +; diff --git a/databases/umls.sh b/databases/umls.sh index 0218c9e..53cd1f9 100755 --- a/databases/umls.sh +++ b/databases/umls.sh @@ -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