Using RxNorm Identifiers for Drug Interaction Checking: A Developer's Guide
Drug name normalization is one of the hardest problems in health informatics. "Warfarin," "warfarin sodium," "Coumadin," and "Jantoven" are all the same drug — but a naive string comparison would treat them as four different entities. RxNorm solves this.
What is RxNorm?
RxNorm is a normalized naming system for clinical drugs maintained by the NLM. Every drug entity in RxNorm gets a unique identifier called an RxCUI (RxNorm Concept Unique Identifier). Warfarin's RxCUI is 11289. Aspirin's is 1191.
Resolving supported inputs to RxCUIs can reduce naming variation, but formulations, multi-ingredient products, ambiguous names, and unsupported aliases may resolve differently or fail. Always inspect the reported resolution method.
How RxCheck uses RxNorm
Every query to the RxCheck API goes through a resolution pipeline:
- Input received ("Coumadin")
- Check Redis cache for known mapping (30-day TTL)
- If cache miss: query RxNorm API for canonical RxCUI
- Cache result, use RxCUI for database lookup
- Return resolved name in response
The resolution_method field in every response tells you how the name was resolved: exact_match, cache, rxnorm_api, or rxcui_direct.
Looking up RxCUIs
import requests
def get_rxcui(drug_name: str) -> str | None:
"""Look up RxCUI for a drug name via RxNorm API."""
resp = requests.get(
"https://rxnav.nlm.nih.gov/REST/drugs.json",
params={"name": drug_name},
timeout=10,
)
data = resp.json()
for group in data.get("drugGroup", {}).get("conceptGroup", []):
for concept in group.get("conceptProperties", []):
return concept.get("rxcui")
return None
# "Coumadin" → "11289" (warfarin)
# "warfarin" → "11289"
# "coumadin" → "11289"
rxcui = get_rxcui("Coumadin")
print(rxcui) # "11289"Passing RxCUIs to RxCheck
Once you have RxCUI identifiers, you can pass them directly to avoid the name resolution overhead:
# Verify each reported resolution; do not assume brand aliases are equivalent
check_interaction("warfarin", "aspirin") # name resolution
check_interaction("Coumadin", "Bayer") # brand names
check_interaction("11289", "1191") # raw RxCUIs
check_interaction("rxcui:11289", "rxcui:1191") # prefixed RxCUIsBuilding a drug name autocomplete
The /v1/drugs/search endpoint supports autocomplete over stored names and generic names. Returned brand arrays are metadata, not currently searched aliases:
GET /v1/drugs/search?q=war
{
"results": [
{
"name": "Warfarin",
"rxcui": "11289",
"generic_name": "warfarin",
"brand_names": ["Coumadin", "Jantoven"],
"drug_class": "Anticoagulant"
}
],
"count": 1
}Common RxCUIs for testing
| Drug | RxCUI | Common Brand |
|---|---|---|
| Warfarin | 11289 | Coumadin |
| Aspirin | 1191 | Bayer |
| Metformin | 6809 | Glucophage |
| Atorvastatin | 83367 | Lipitor |
| Amiodarone | 703 | Pacerone |
| Digoxin | 3407 | Lanoxin |
| Clarithromycin | 21212 | Biaxin |
Try it live
Test with RxCUI identifiers or drug names: