File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,23 @@ CREATE TABLE new_ingredient (
5656-- the RXCUI1 is the ingredient
5757-- and the RXCUI2 is the clinical drug form.
5858INSERT OR IGNORE INTO new_ingredient
59+ SELECT DISTINCT
60+ c .RXCUI AS rxcui,
61+ c .STR AS label
62+ FROM new_clinical_drug_form AS cdf
63+ LEFT JOIN rxnorm .RXNREL AS r ON r .RXCUI2 = cdf .rxcui
64+ LEFT JOIN rxnorm .RXNCONSO AS c ON c .RXCUI = r .RXCUI1
65+ WHERE r .RELA = ' has_ingredient'
66+ AND c .SAB = ' RXNORM'
67+ AND c .RXCUI NOT IN (SELECT rxcui FROM dron .ingredient );
68+
69+ -- Find new ingredients for existing clinical drug forms.
70+ -- Shouldn't happen going forward but needed to fix first time.
71+ -- We join the RXNREL table
72+ -- where the relation is 'has_ingredient'
73+ -- the RXCUI1 is the ingredient
74+ -- and the RXCUI2 is the clinical drug form.
75+ INSERT OR IGNORE INTO new_ingredient
5976SELECT DISTINCT
6077 c .RXCUI AS rxcui,
6178 c .STR AS label
You can’t perform that action at this time.
0 commit comments