Querying Openfda Labels logo

Querying Openfda Labels

CommunityPopular
maziyarpanahi
querying-openfda-labels

Looks up FDA drug labels, NDC directory entries, indications, boxed warnings, and recalls/enforcement actions via the free public OpenFDA API to enrich drugs that OpenMed extracts. Use when the user wants the prescribing information for a drug, its boxed warning, approved indications, dosage forms and routes, package NDC codes, RxCUI, or whether a product has an open recall. Trigger keywords: OpenFDA, drug label, SPL, prescribing information, boxed warning, black box warning, indications, NDC, package code, recall, enforcement, Class I recall, drug enrichment. Pairs adjacent to OpenMed NER: take a drug name (or RxNorm RxCUI) from openmed.analyze_text and resolve its label, NDC, and recall status. OpenFDA is public and free — no license barrier; send only de-identified drug names, never raw clinical notes.

Overview

Publishermaziyarpanahi
Repositoryopenmed
Skill namequerying-openfda-labels
Stars
5.3K
Forks
677
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by maziyarpanahi on GitHub. Read the source before you install it.

Installation

Install the Querying Openfda Labels AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/maziyarpanahi/openmed.git /tmp/openmed
mkdir -p .claude/skills
cp -r /tmp/openmed/skills/querying-openfda-labels .claude/skills/querying-openfda-labels
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Querying Openfda Labels in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Querying Openfda Labels on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Querying Openfda Labels is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Querying OpenFDA drug labels, NDC, and recalls

Once OpenMed has pulled a drug name out of a note, you often need authoritative product facts: the boxed warning, approved indications, dosage form / route, package NDC codes, and whether the product is under recall. The FDA's OpenFDA API exposes the Structured Product Labeling (SPL), the NDC directory, and enforcement (recall) reports — all public and free.

This skill is enrichment: it attaches regulatory facts to an extracted drug. It is not clinical decision support — a label lookup informs a human, it does not prescribe.

When to use

  • You extracted a drug and need its boxed warning or indications for display, alerting, or expectedness checks.
  • You need NDC package codes, dosage form, or route for a product.
  • You want to know if a drug/lot is under an open recall (enforcement).
  • You want to map a brand name to its generic ingredient and RxCUI via the label's openfda block.

The three endpoints

EndpointUseKey fields
https://api.fda.gov/drug/label.jsonSPL prescribing infoboxed_warning, indications_and_usage, warnings, dosage_and_administration, openfda.brand_name, openfda.generic_name, openfda.rxcui, openfda.product_ndc
https://api.fda.gov/drug/ndc.jsonNDC directoryproduct_ndc, generic_name, brand_name, dosage_form, route, active_ingredients
https://api.fda.gov/drug/enforcement.jsonRecallsproduct_description, reason_for_recall, classification (Class I/II/III), recalling_firm, status, recall_initiation_date

No key needed to try it (240 req/min, 1,000/day per IP). A free api_key= raises the daily cap to 120,000.

Quick start (real OpenFDA queries)

python
import requests

def openfda(endpoint: str, search: str, limit: int = 1) -> list[dict]:
    url = f"https://api.fda.gov/drug/{endpoint}.json"
    r = requests.get(url, params={"search": search, "limit": limit}, timeout=30)
    if r.status_code == 404:        # OpenFDA returns 404 for zero matches
        return []
    r.raise_for_status()
    return r.json().get("results", [])

# 1) Label: boxed warning + indications for a generic drug.
label = openfda("label", 'openfda.generic_name:"warfarin"')
if label:
    rec = label[0]
    print("Boxed warning:", rec.get("boxed_warning", ["(none)"])[0][:200])
    print("Indication:", rec.get("indications_and_usage", ["(none)"])[0][:200])
    print("RxCUI:", rec.get("openfda", {}).get("rxcui"))

# 2) NDC: package codes, form, route.
ndc = openfda("ndc", 'generic_name:"warfarin"', limit=5)
for rec in ndc:
    print(rec["product_ndc"], rec.get("dosage_form"), rec.get("route"))

# 3) Enforcement: open recalls for a product.
recalls = openfda("enforcement",
                  'product_description:"warfarin"+AND+status:"Ongoing"', limit=5)
for rec in recalls:
    print(rec["classification"], "-", rec["reason_for_recall"][:120])

Workflow

  1. Normalize the drug name first. Use openmed.analyze_text to get the span, then prefer the RxNorm ingredient (see normalizing-rxnorm) as your query term — openfda.generic_name and the NDC generic_name index on the ingredient, so a normalized name hits far more records than raw note text.
  2. Query /drug/label with openfda.generic_name:"<ingredient>" (or openfda.rxcui:"<rxcui>" for an exact product). Read boxed_warning, indications_and_usage, warnings_and_cautions.
  3. Query /drug/ndc for package-level codes, dosage form, and route.
  4. Query /drug/enforcement filtered to status:"Ongoing" to surface open recalls; gate alerts on classification (Class I = most serious).
  5. Cache results — labels change rarely; you do not need to re-query per note.
  6. Attach the facts to the extracted drug keyed by RxCUI/NDC for traceability.

Hand-off to / from OpenMed

OpenMed's analyze_text returns a dict; result["entities"] items carry text, label, confidence, start, end.

  • From extracting-clinical-entities: Pharmaceutical/Chemical entities are the query seeds. From normalizing-rxnorm: pass the RxCUI to openfda.rxcui:"..." for an exact label match.
  • To reporting-adverse-events: the boxed warning / indications support an expectedness judgment (is this reaction labeled?). To detecting-pv-signals: confirm whether a disproportionality signal is already on-label before escalating.
  • OpenMed runs NER on-device; only a de-identified drug name or RxCUI leaves the process to hit OpenFDA. Never send a raw note containing PHI to the API — de-identify with openmed.deidentify first if you must derive the query from patient text.

Edge cases & gotchas

  • OpenFDA returns 404 for an empty result set, not an empty results list — handle it as "no match" (the helper above does).
  • Multi-value fields are lists. boxed_warning, indications_and_usage, and most SPL sections are arrays of strings (rec["boxed_warning"][0]). Many products have no boxed warning — the key is simply absent.
  • Brand vs generic. openfda.brand_name and openfda.generic_name differ; query the generic (ingredient) for coverage, the brand for a specific product.
  • Labels are SPL snapshots, not real-time. OpenFDA mirrors DailyMed SPL; a brand-new labeling change may lag. For the definitive current label, cross-check DailyMed.
  • NDC formats vary (product_ndc is the 2-segment labeler-product code; package NDCs add a third segment). Normalize before joining to claims data.
  • Recall status is one of Ongoing, Completed, Terminated — filter to Ongoing for active risk; classification Class I > II > III by severity.
  • Public and free, but rate-limited. Register a free key and cache; do not hammer the API per-note in a batch pipeline.

Standards & references

Frequently asked questions

What does the Querying Openfda Labels AI skill do?

Looks up FDA drug labels, NDC directory entries, indications, boxed warnings, and recalls/enforcement actions via the free public OpenFDA API to enrich drugs that OpenMed extracts. Use when the user wants the prescribing information for a drug, its boxed warning, approved indications, dosage forms and routes, package NDC codes, RxCUI, or whether a product has an open recall. Trigger keywords: OpenFDA, drug label, SPL, prescribing information, boxed warning, black box warning, indications, NDC, package code, recall, enforcement, Class I recall, drug enrichment. Pairs adjacent to OpenMed NER:...

Why use Querying Openfda Labels on TypingMind?

Because you install it once and use it with any model. Querying Openfda Labels is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Querying Openfda Labels in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/maziyarpanahi/openmed/tree/master/skills/querying-openfda-labels. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Querying Openfda Labels?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Querying Openfda Labels?

As many as you like. As long as a model supports skills, you can use Querying Openfda Labels with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Querying Openfda Labels AI skill free?

Yes. It is published on GitHub by maziyarpanahi under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇