You can query the RxNorm REST API to know whether a given NDC is a brand name or a generic. Specifically, you can:
- query the /ndcproperties resource with your NDC to obtain its RxNorm CUI
- then query the /rxcui/{rxcui}/property to obtain its Term Type (TTY)
- the TTY will specify if the drug is a brand name as per the documentation at: https://www.nlm.nih.gov/research/umls/rxnorm/docs/2018/appendix5.html
The R function below returns true if the NDC is a brand name, false otherwise:
ndcBrandName <- function(ndc) { # Returns true if NDC is a brand name.
# Abbreviation reference: https://www.nlm.nih.gov/research/umls/rxnorm/docs/2018/appendix5.html
# BN Brand Name
# SBDC Semantic Branded Drug Component
# SBDF Semantic Branded Drug Form
# SBDG Semantic Branded Dose Form Group
# SBD Semantic Branded Drug
# BPCK Brand Name Pack
ndc_properties <- fromJSON(paste0('https://rxnav.nlm.nih.gov/REST/ndcproperties?id=', ndc))
rxnorm_cui <- ndc_properties[1]$ndcPropertyList[1]$ndcProperty$rxcui
tty <- fromJSON(paste0('https://rxnav.nlm.nih.gov/REST/rxcui/', rxnorm_cui, '/property?propName=TTY'))
tty[1]$propConceptGroup[1]$propConcept$propValue %in% c('BN', 'SBDC', 'SBDF', 'SBDG', 'SBD', 'BPCK')
}
It’s also possible to explore related drugs, for example find generic NDCs matching brand name NDCs – see the resouce /rxcui/{rxcui}/related?tty= values at:
https://mor.nlm.nih.gov/download/rxnav/RxNormAPIs.html#uLink=RxNorm_REST_getRelatedByType.
Regards!