Skip to content

Commit

Permalink
Merge pull request #33 from mcwdsi/fix-dose-forms
Browse files Browse the repository at this point in the history
Fix dose forms for clinical drug forms
  • Loading branch information
jamesaoverton authored Jul 27, 2024
2 parents 1cb7ad6 + a10d7e5 commit a1274b1
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 98 deletions.
4 changes: 2 additions & 2 deletions src/ontology/dron.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $(IMPORTDIR)/uo_import.owl: $(MIRRORDIR)/uo.owl $(IMPORTDIR)/uo_terms_combined.t
# (no NDC) and the run a regular full release.

LITE_ARTEFACTS=$(COMPONENTSDIR)/dron-rxnorm.owl $(COMPONENTSDIR)/dron-ingredient.owl $(COMPONENTSDIR)/dron-obsolete.owl $(IMPORT_OWL_FILES)
$(TMPDIR)/dron-edit_lite.owl: $(SRC) $(LITE_ARTEFACTS)
$(TMPDIR)/dron-edit_lite.owl: $(SRC) $(LITE_ARTEFACTS) | $(TMPDIR)/
$(ROBOT) remove --input $(SRC) --select imports \
merge $(patsubst %, -i %, $(LITE_ARTEFACTS)) --output $@.tmp.owl && mv $@.tmp.owl $@

Expand All @@ -45,7 +45,7 @@ $(TMPDIR)/ldtab.jar: | $(TMPDIR)
LDTAB := java -jar $(TMPDIR)/ldtab.jar

# Load DrOn templates into SQLite.
$(TMPDIR)/dron.db: $(SCRIPTSDIR)/create-dron-tables.sql $(SCRIPTSDIR)/load-dron-tables.sql $(SCRIPTSDIR)/index-dron-tables.sql $(TEMPLATEDIR)/*.tsv
$(TMPDIR)/dron.db: $(SCRIPTSDIR)/create-dron-tables.sql $(SCRIPTSDIR)/load-dron-tables.sql $(SCRIPTSDIR)/index-dron-tables.sql $(TEMPLATEDIR)/*.tsv | $(TMPDIR)/
rm -f $@
sqlite3 $@ < $<
sqlite3 $@ < $(word 2,$^)
Expand Down
6 changes: 6 additions & 0 deletions src/scripts/create-dron-tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ CREATE TABLE unit (
ontology_label TEXT UNIQUE NOT NULL
);

CREATE TABLE dose_form (
rxcui INTEGER PRIMARY KEY NOT NULL,
label TEXT UNIQUE NOT NULL,
curie TEXT NOT NULL
);

-- Create triggers for automatically assigning DRON IDs.
-- First create a table with one row to track the current ID.
CREATE TABLE current_dron_id ( id INTEGER );
Expand Down
1 change: 1 addition & 0 deletions src/scripts/load-dron-tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ PRAGMA foreign_keys = ON;
.import --skip 1 ../templates/ndc_clinical_drug.tsv ndc_clinical_drug
.import --skip 1 ../templates/obsolete.tsv obsolete
.import --skip 1 ../templates/unit.tsv unit
.import --skip 1 ../templates/dose_form.tsv dose_form

-- Set current_dron_id.
DELETE FROM current_dron_id;
Expand Down
16 changes: 10 additions & 6 deletions src/scripts/update-dron-from-rxnorm.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ DROP TABLE IF EXISTS new_clinical_drug_form;
CREATE TABLE new_clinical_drug_form AS
SELECT
RXCUI AS rxcui,
STR AS label
FROM rxnorm.RXNCONSO
WHERE SAB = 'RXNORM'
AND TTY = 'SCDF'
AND RXCUI NOT IN (SELECT rxcui FROM dron.clinical_drug_form);
STR AS label,
COALESCE(df.curie, 'DRON:00000005') AS parent -- default 'drug product'
FROM rxnorm.RXNCONSO AS c
LEFT JOIN rxnorm.RXNREL AS r ON r.RXCUI2 = c.RXCUI
LEFT JOIN dron.dose_form AS df ON r.RXCUI1 = df.rxcui
WHERE c.SAB = 'RXNORM'
AND c.TTY = 'SCDF'
AND c.RXCUI NOT IN (SELECT rxcui FROM dron.clinical_drug_form)
AND r.RELA = 'has_dose_form';

-- Find new clinical drugs.
DROP TABLE IF EXISTS new_clinical_drug;
Expand Down Expand Up @@ -120,7 +124,7 @@ INSERT INTO dron.clinical_drug_form
SELECT
NULL AS curie,
label AS label,
NULL AS parent,
parent AS parent,
rxcui AS rxcui
FROM new_clinical_drug_form;

Expand Down
Loading

0 comments on commit a1274b1

Please sign in to comment.