File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed
Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -239,32 +239,33 @@ WHERE r.RELA = 'has_inactive_ingredient'
239239 AND c2 .RXAUI = r .RXAUI2
240240 AND c2 .RXCUI = bd .rxcui ;
241241
242- -- Add NDCs for clinical drugs not already in that table.
243- INSERT OR IGNORE INTO ndc_clinical_drug
242+ -- Add NDCs for branded drugs not already in that table.
243+ INSERT OR IGNORE INTO ndc_branded_drug
244244SELECT DISTINCT
245245 NULL AS curie,
246246 s .ATV AS ndc,
247- cd .curie AS drug
247+ bd .curie AS drug
248248FROM rxnorm .RXNSAT AS s
249- LEFT JOIN clinical_drug AS cd
250- LEFT JOIN ndc_clinical_drug AS n
249+ LEFT JOIN branded_drug AS bd
250+ LEFT JOIN ndc_branded_drug AS n
251251 ON s .ATV = n .ndc
252- WHERE s .RXCUI = cd .rxcui
252+ WHERE s .RXCUI = bd .rxcui
253253 AND s .SAB = ' RXNORM'
254254 AND s .ATN = ' NDC'
255255 AND n .curie IS NULL ;
256256
257- -- Add NDCs for branded drugs not already in that table.
258- INSERT OR IGNORE INTO ndc_branded_drug
257+ -- Add NDCs for clinical drugs not already in that table.
258+ INSERT OR IGNORE INTO ndc_clinical_drug
259259SELECT DISTINCT
260260 NULL AS curie,
261261 s .ATV AS ndc,
262- bd .curie AS drug
262+ cd .curie AS drug
263263FROM rxnorm .RXNSAT AS s
264- LEFT JOIN branded_drug AS bd
265- LEFT JOIN ndc_branded_drug AS n
264+ LEFT JOIN clinical_drug AS cd
265+ LEFT JOIN ndc_clinical_drug AS n
266266 ON s .ATV = n .ndc
267- WHERE s .RXCUI = bd .rxcui
267+ WHERE s .RXCUI = cd .rxcui
268268 AND s .SAB = ' RXNORM'
269269 AND s .ATN = ' NDC'
270- AND n .curie IS NULL ;
270+ AND n .curie IS NULL
271+ AND s .ATV not in (select ndc from ndc_branded_drug);
You can’t perform that action at this time.
0 commit comments