@pharmatools/drug-data
v0.2.2
Published
Deterministic drug-name resolution (RxNorm) and official label data (FDA openFDA + UK eMC SmPC), with US/UK comparison. The shared engine behind Pharmonym and PubCrawl.
Downloads
541
Maintainers
Readme
@pharmatools/drug-data
Shared drug-data engine behind Pharmonym and PubCrawl. Deterministic, sourced, no AI.
- Name resolution — brand ⇄ generic, drug class and indications via RxNorm/RxNav, with openFDA fallback.
- Labels — dosage, warnings, contraindications, indications and adverse reactions from the US FDA label (openFDA, cited to DailyMed) and the UK/EU SmPC (eMC / medicines.org.uk).
- Comparison — equivalent US ↔ UK label sections mapped side by side.
Pure fetch + parse: no caching, no secrets. Wraps public government APIs.
Dual-built (ESM + CJS), global fetch, Node ≥18.
Install
npm install @pharmatools/drug-dataUsage
import { resolveName, getLabels, compareLabels } from "@pharmatools/drug-data";
await resolveName("Lipitor");
// { inputType: "brand", genericName: "Atorvastatin", drugClass: "...", ... }
await getLabels("atorvastatin");
// { us: { dosage, warnings, ... , sourceUrl }, uk: { ... } }
await compareLabels("atorvastatin");
// { drug, comparisons: [{ topic, us, uk }], usSource, ukSource }CommonJS consumers use require("@pharmatools/drug-data") — same API.
General (all-section) access
getLabels returns a compact 5-field view (uses, dosing, contraindications,
warnings, adverse). For every available label section, use the general API:
import { getUsLabel, getUkSmpc } from "@pharmatools/drug-data";
await getUsLabel("atorvastatin"); // { drugName, setId, publishedDate, sections[], dailymedUrl }
await getUsLabel("atorvastatin", ["drug interactions"]); // filter to specific sections
await getUkSmpc("atorvastatin"); // { drugName, productId, sections[], url } — all SmPC sections
await getUkSmpc("atorvastatin", ["4.5"]); // filter by section number or nameEach section is { code, title, content }.
Develop
npm install
npm test # vitest (mocked fixtures, no network)
npm run build # tsup -> dist/{index.js,index.cjs,index.d.ts}Sources
RxNorm/RxNav, openFDA, DailyMed, eMC (medicines.org.uk). Not a substitute for professional medical advice; always verify against the full prescribing information.
