[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73G93XZC9GVA5SZS2BY9XJM":3,"skill-same:01M73G93XZC9GVA5SZS2BY9XJM":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M73G93XZC9GVA5SZS2BY9XJM","dailymed-database",null,"Query FDA drug labels (DailyMed) via REST API. Search structured product labels (SPLs) by name, NDC, set ID, or RxCUI; get indications, dosage, warnings, adverse reactions, packaging. No auth. For adverse events use fda-database; for DDIs use ddinter-database.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"CC0-1.0","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fdailymed-database\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: \"dailymed-database\"\ndescription: \"Query FDA drug labels (DailyMed) via REST API. Search structured product labels (SPLs) by name, NDC, set ID, or RxCUI; get indications, dosage, warnings, adverse reactions, packaging. No auth. For adverse events use fda-database; for DDIs use ddinter-database.\"\nlicense: \"CC0-1.0\"\n---\n\n# DailyMed Drug Label Database\n\n## Overview\n\nDailyMed is the National Library of Medicine's official repository of FDA-approved drug labeling information, containing 140,000+ structured product labels (SPLs) for prescription drugs, OTC medications, biologics, and vaccines. The REST API (v2) provides structured JSON\u002FXML access to the full label content including indications, dosage, warnings, contraindications, adverse reactions, and packaging data — with no authentication required.\n\n## When to Use\n\n- Retrieving official FDA-approved prescribing information for a drug by name, NDC code, or set ID\n- Extracting structured label sections (indications, warnings, dosage, adverse reactions) for pharmacological research\n- Looking up all marketed formulations of an active ingredient with packaging and NDC codes\n- Cross-referencing drug labels using RxCUI identifiers from RxNorm integration\n- Building drug information pipelines that require authoritative FDA label content (not user-reported data)\n- Comparing label content across brand name and generic formulations of the same drug\n- For adverse event reports from FAERS, use `fda-database` instead; DailyMed contains label text, not post-market safety signals\n- For drug-drug interaction severity data, use `ddinter-database`; DailyMed label text is unstructured for interactions\n\n## Prerequisites\n\n- **Python packages**: `requests`, `pandas`, `matplotlib`\n- **Data requirements**: drug names, NDC codes, set IDs, or RxCUI identifiers\n- **Environment**: internet connection; no API key required\n- **Rate limits**: no officially published limit; ~100 requests\u002Fminute is safe for polite access; add `time.sleep(0.3)` in batch loops\n\n```bash\npip install requests pandas matplotlib\n```\n\n## Quick Start\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\n# Search drug labels by name\nr = requests.get(f\"{BASE}\u002Fspls.json\", params={\"drug_name\": \"metformin\", \"pagesize\": 5})\nr.raise_for_status()\ndata = r.json()\nprint(f\"Total labels found: {data['metadata']['total_elements']}\")\nfor spl in data[\"data\"][:3]:\n    print(f\"  {spl['title']!r:60s}  setid={spl['setid']}\")\n```\n\n## Core API\n\n### Query 1: Search Drug Labels by Name\n\nSearch for structured product labels (SPLs) using drug name. Returns paginated list of matching labels with set IDs.\n\n```python\nimport requests\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_spls(drug_name, pagesize=20, page=1):\n    \"\"\"Search DailyMed SPLs by drug name. Returns list of label summaries.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"drug_name\": drug_name, \"pagesize\": pagesize, \"page\": page},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()\n\nresult = search_spls(\"atorvastatin\", pagesize=10)\nmeta = result[\"metadata\"]\nprint(f\"Search: 'atorvastatin' → {meta['total_elements']} labels across {meta['total_pages']} pages\")\n\ndf = pd.DataFrame(result[\"data\"])\nprint(df[[\"setid\", \"title\", \"published_date\"]].to_string(index=False))\n# setid                                  title                                   published_date\n# 8f6c7c7c-...  ATORVASTATIN CALCIUM tablet                               2024-03-15\n# a4b7d3e1-...  ATORVASTATIN CALCIUM tablet, film coated                  2023-11-20\n```\n\n### Query 2: Retrieve Full Label by Set ID\n\nFetch the complete structured product label for a specific drug using its set ID. Returns all label sections including indications, warnings, dosage, and adverse reactions.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef get_spl(setid):\n    \"\"\"Retrieve full SPL document by set ID. Returns label metadata and XML\u002FJSON.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}.json\", timeout=20)\n    r.raise_for_status()\n    return r.json()\n\n# Use a known set ID from search results\nsetid = \"8f6c7c7c-1f7f-4f1a-af86-8b2eef2a8b2c\"   # example atorvastatin label\nlabel = get_spl(setid)\ndata = label[\"data\"]\n\nprint(f\"Title: {data.get('title')}\")\nprint(f\"Set ID: {data.get('setid')}\")\nprint(f\"Published: {data.get('published_date')}\")\nprint(f\"Version: {data.get('version')}\")\n\n# Access structured sections\nif \"sections\" in data:\n    sections = data[\"sections\"]\n    print(f\"\\nLabel sections ({len(sections)} total):\")\n    for sec in sections[:5]:\n        print(f\"  [{sec.get('loinc_code', 'N\u002FA')}] {sec.get('title', 'Untitled')}\")\n```\n\n### Query 3: Search by NDC Code\n\nLook up drug labels by National Drug Code (NDC) — useful when you have a product barcode or dispensing record.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_by_ndc(ndc_code):\n    \"\"\"Find SPL by NDC code (formatted as XXXXX-XXXX-XX or without dashes).\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"ndc\": ndc_code},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()\n\n# NDC for Lipitor 10mg (atorvastatin)\nresult = search_by_ndc(\"0071-0155-23\")\nif result[\"data\"]:\n    spl = result[\"data\"][0]\n    print(f\"Drug: {spl['title']}\")\n    print(f\"Set ID: {spl['setid']}\")\n    print(f\"Published: {spl['published_date']}\")\nelse:\n    print(\"No label found for this NDC\")\n```\n\n### Query 4: Retrieve Packaging Information\n\nGet detailed packaging data (NDC codes, package types, quantities) for a specific drug label by set ID.\n\n```python\nimport requests\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef get_packaging(setid):\n    \"\"\"Retrieve packaging information for a label (NDC codes, dosage forms, quantities).\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}\u002Fpackaging.json\", timeout=15)\n    r.raise_for_status()\n    return r.json()\n\nsetid = \"8f6c7c7c-1f7f-4f1a-af86-8b2eef2a8b2c\"   # example setid\npkg = get_packaging(setid)\n\nif pkg[\"data\"]:\n    packages = pkg[\"data\"]\n    print(f\"Packaging variants: {len(packages)}\")\n    df = pd.DataFrame(packages)\n    # Common fields: ndc, dosage_form, route, marketing_status\n    for col in [\"ndc\", \"dosage_form\", \"route\", \"marketing_status\"]:\n        if col in df.columns:\n            print(f\"\\n{col.upper()}:\")\n            print(df[col].value_counts().head(5))\n```\n\n### Query 5: Look Up by RxCUI\n\nRetrieve drug labels using RxNorm Concept Unique Identifier (RxCUI) for integration with RxNorm-based clinical systems.\n\n```python\nimport requests\nimport time\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef get_spls_by_rxcui(rxcui):\n    \"\"\"Get all SPLs associated with an RxCUI. Returns list of set IDs and titles.\"\"\"\n    r = requests.get(f\"{BASE}\u002Frxcuis\u002F{rxcui}\u002Fspls.json\", timeout=15)\n    r.raise_for_status()\n    return r.json()\n\n# RxCUI for atorvastatin: 83367\nrxcui = \"83367\"\nresult = get_spls_by_rxcui(rxcui)\nprint(f\"SPLs for RxCUI {rxcui} (atorvastatin):\")\nfor spl in result[\"data\"][:5]:\n    print(f\"  {spl['setid']} | {spl['title'][:70]}\")\nprint(f\"  Total: {result['metadata']['total_elements']} labels\")\n```\n\n### Query 6: Search Drug Names Index\n\nList all standardized drug names in DailyMed — useful for name normalization and autocomplete in drug lookup pipelines.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_drug_names(query, pagesize=20):\n    \"\"\"Search the DailyMed drug name index for name normalization.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fdrugnames.json\",\n                     params={\"drug_name\": query, \"pagesize\": pagesize},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()\n\nresult = search_drug_names(\"metformin\")\nprint(f\"Drug name matches for 'metformin': {result['metadata']['total_elements']}\")\nfor entry in result[\"data\"][:8]:\n    print(f\"  {entry['drug_name']}\")\n# METFORMIN HYDROCHLORIDE\n# METFORMIN HYDROCHLORIDE AND SITAGLIPTIN PHOSPHATE\n# METFORMIN HYDROCHLORIDE AND SAXAGLIPTIN\n```\n\n### Query 7: Batch Label Section Extraction\n\nExtract specific label sections (e.g., indications, warnings) from multiple drug labels for comparative analysis.\n\n```python\nimport requests\nimport time\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\n# LOINC codes for common SPL sections\nSECTION_LOINC = {\n    \"34067-9\": \"Indications and Usage\",\n    \"34068-7\": \"Dosage and Administration\",\n    \"34071-1\": \"Warnings\",\n    \"34084-4\": \"Adverse Reactions\",\n    \"34070-3\": \"Contraindications\",\n    \"43685-7\": \"Warnings and Precautions\",\n}\n\ndef get_label_sections(setid):\n    \"\"\"Extract structured sections from an SPL by set ID.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}.json\", timeout=20)\n    r.raise_for_status()\n    data = r.json()[\"data\"]\n    sections = {}\n    for sec in data.get(\"sections\", []):\n        loinc = sec.get(\"loinc_code\")\n        if loinc in SECTION_LOINC:\n            sections[SECTION_LOINC[loinc]] = sec.get(\"text\", \"\")\n    return sections\n\n# Get indications for two statin labels\nstatins = [\n    (\"Atorvastatin\", \"8f6c7c7c-1f7f-4f1a-af86-8b2eef2a8b2c\"),\n    (\"Rosuvastatin\", \"a3b2c4d5-1234-5678-abcd-ef0123456789\"),   # example\n]\nrecords = []\nfor drug_name, setid in statins:\n    try:\n        sections = get_label_sections(setid)\n        records.append({\"drug\": drug_name, \"indications_length\": len(sections.get(\"Indications and Usage\", \"\"))})\n    except Exception as e:\n        print(f\"Warning: {drug_name} failed — {e}\")\n    time.sleep(0.3)\n\ndf = pd.DataFrame(records)\nprint(df.to_string(index=False))\n```\n\n## Key Concepts\n\n### Structured Product Label (SPL) and Set ID\n\nAn SPL is the official FDA-approved drug label in XML format, structured using Health Level 7 (HL7) Clinical Document Architecture (CDA). Each unique drug product label has a globally unique **set ID** (UUID format). Multiple versions of the same label share the same set ID but have different version numbers. Always use the most recent published version for current prescribing information.\n\n### LOINC Section Codes\n\nDailyMed SPLs use standardized LOINC codes to identify label sections, enabling consistent programmatic extraction across all labels:\n\n| LOINC Code | Section Name |\n|------------|-------------|\n| `34067-9` | Indications and Usage |\n| `34068-7` | Dosage and Administration |\n| `34070-3` | Contraindications |\n| `34071-1` | Warnings |\n| `43685-7` | Warnings and Precautions |\n| `34084-4` | Adverse Reactions |\n| `34073-7` | Drug Interactions |\n| `34076-0` | Patient Counseling Information |\n| `42229-5` | Mechanism of Action |\n| `34069-5` | How Supplied\u002FStorage |\n\n### NDC Code Format\n\nNational Drug Codes (NDCs) identify drug products with a three-segment numeric format: `labeler-product-package` (e.g., `0071-0155-23`). NDCs can also appear without dashes in some systems. DailyMed accepts both formats in API queries.\n\n## Common Workflows\n\n### Workflow 1: Drug Label Comparison by Active Ingredient\n\n**Goal**: Retrieve and compare label content for all formulations of an active ingredient — useful for generic vs. brand name comparison.\n\n```python\nimport requests\nimport time\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_spls(drug_name, pagesize=50):\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"drug_name\": drug_name, \"pagesize\": pagesize},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()\n\ndef get_packaging(setid):\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}\u002Fpackaging.json\", timeout=15)\n    r.raise_for_status()\n    return r.json()\n\n# Search for all metformin labels\nresult = search_spls(\"metformin\", pagesize=20)\nlabels = result[\"data\"]\nprint(f\"Found {len(labels)} metformin labels\")\n\nrows = []\nfor label in labels[:10]:   # limit for demo\n    setid = label[\"setid\"]\n    try:\n        pkg = get_packaging(setid)\n        for item in pkg[\"data\"][:2]:\n            rows.append({\n                \"title\": label[\"title\"][:60],\n                \"setid\": setid,\n                \"ndc\": item.get(\"ndc\"),\n                \"dosage_form\": item.get(\"dosage_form\"),\n                \"route\": item.get(\"route\"),\n                \"marketing_status\": item.get(\"marketing_status\"),\n                \"published_date\": label.get(\"published_date\"),\n            })\n    except Exception as e:\n        print(f\"Skipping {setid}: {e}\")\n    time.sleep(0.3)\n\ndf = pd.DataFrame(rows)\nprint(f\"\\nFormulations with packaging data: {len(df)}\")\nprint(df[[\"title\", \"dosage_form\", \"route\", \"marketing_status\"]].drop_duplicates().to_string(index=False))\ndf.to_csv(\"metformin_formulations.csv\", index=False)\nprint(\"\\nSaved: metformin_formulations.csv\")\n```\n\n### Workflow 2: Extract Warnings and Adverse Reactions for Safety Analysis\n\n**Goal**: Systematically extract structured warning and adverse reaction text from a set of drug labels for pharmacovigilance research.\n\n```python\nimport requests\nimport time\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\nTARGET_SECTIONS = {\n    \"34071-1\": \"Warnings\",\n    \"43685-7\": \"Warnings_and_Precautions\",\n    \"34084-4\": \"Adverse_Reactions\",\n    \"34070-3\": \"Contraindications\",\n}\n\ndef search_and_get_sections(drug_name, max_labels=5):\n    \"\"\"Search for labels and extract safety-relevant sections.\"\"\"\n    search_r = requests.get(f\"{BASE}\u002Fspls.json\",\n                            params={\"drug_name\": drug_name, \"pagesize\": max_labels},\n                            timeout=15)\n    search_r.raise_for_status()\n    labels = search_r.json()[\"data\"][:max_labels]\n\n    records = []\n    for label in labels:\n        setid = label[\"setid\"]\n        try:\n            label_r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}.json\", timeout=20)\n            label_r.raise_for_status()\n            spl_data = label_r.json()[\"data\"]\n\n            row = {\"drug_name\": drug_name, \"title\": label[\"title\"][:80], \"setid\": setid}\n            for loinc, col in TARGET_SECTIONS.items():\n                text = \"\"\n                for sec in spl_data.get(\"sections\", []):\n                    if sec.get(\"loinc_code\") == loinc:\n                        text = sec.get(\"text\", \"\")[:500]   # first 500 chars\n                        break\n                row[col] = text\n            records.append(row)\n        except Exception as e:\n            print(f\"  Skipping {setid}: {e}\")\n        time.sleep(0.3)\n\n    return pd.DataFrame(records)\n\n# Compare safety sections across ACE inhibitor labels\ndrugs = [\"lisinopril\", \"enalapril\"]\nall_records = []\nfor drug in drugs:\n    print(f\"Processing: {drug}\")\n    df = search_and_get_sections(drug, max_labels=3)\n    all_records.append(df)\n\ncombined = pd.concat(all_records, ignore_index=True)\nprint(f\"\\nExtracted safety sections: {len(combined)} labels\")\nprint(combined[[\"drug_name\", \"title\"]].to_string(index=False))\ncombined.to_csv(\"ace_inhibitor_safety_sections.csv\", index=False)\nprint(\"Saved: ace_inhibitor_safety_sections.csv\")\n```\n\n### Workflow 3: Visualize Label Distribution by Drug Class\n\n**Goal**: Query multiple drugs in a class, count their labeled formulations, and visualize the distribution.\n\n```python\nimport requests\nimport time\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef count_labels(drug_name):\n    \"\"\"Return total SPL count for a drug name.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"drug_name\": drug_name, \"pagesize\": 1},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()[\"metadata\"][\"total_elements\"]\n\n# Count labels for common statins\nstatins = {\n    \"atorvastatin\": \"Atorvastatin\",\n    \"rosuvastatin\": \"Rosuvastatin\",\n    \"simvastatin\": \"Simvastatin\",\n    \"pravastatin\": \"Pravastatin\",\n    \"lovastatin\": \"Lovastatin\",\n    \"fluvastatin\": \"Fluvastatin\",\n    \"pitavastatin\": \"Pitavastatin\",\n}\n\ncounts = {}\nfor query, label in statins.items():\n    try:\n        counts[label] = count_labels(query)\n        print(f\"  {label}: {counts[label]} labels\")\n    except Exception as e:\n        print(f\"  {label}: error — {e}\")\n    time.sleep(0.3)\n\n# Visualization\ndf = pd.DataFrame(list(counts.items()), columns=[\"Drug\", \"Label_Count\"])\ndf = df.sort_values(\"Label_Count\", ascending=True)\n\nfig, ax = plt.subplots(figsize=(9, 5))\nbars = ax.barh(df[\"Drug\"], df[\"Label_Count\"], color=\"#2196F3\", edgecolor=\"white\")\nax.bar_label(bars, fmt=\"%d\", padding=4, fontsize=9)\nax.set_xlabel(\"Number of DailyMed SPL Entries\")\nax.set_title(\"DailyMed: FDA Drug Label Count by Statin\\n(includes brand + generic formulations)\")\nax.set_xlim(0, df[\"Label_Count\"].max() * 1.15)\nplt.tight_layout()\nplt.savefig(\"statin_label_counts.png\", dpi=150, bbox_inches=\"tight\")\nprint(f\"Saved: statin_label_counts.png  (total labels: {df['Label_Count'].sum()})\")\n```\n\n## Key Parameters\n\n| Parameter | Endpoint | Default | Range \u002F Options | Effect |\n|-----------|----------|---------|-----------------|--------|\n| `drug_name` | `\u002Fspls`, `\u002Fdrugnames` | — | any drug name string | Filter labels by drug name (partial match supported) |\n| `ndc` | `\u002Fspls` | — | NDC code string | Filter labels by National Drug Code |\n| `pagesize` | `\u002Fspls`, `\u002Fdrugnames` | `20` | `1`–`100` | Results per page; max 100 |\n| `page` | `\u002Fspls`, `\u002Fdrugnames` | `1` | positive integer | Page number for pagination |\n| `setid` | `\u002Fspls\u002F{setid}`, `\u002Fspls\u002F{setid}\u002Fpackaging` | — | UUID string | Unique label identifier; required for direct access |\n| `rxcui` | `\u002Frxcuis\u002F{rxcui}\u002Fspls` | — | RxNorm concept ID | Look up labels by RxCUI for clinical system integration |\n| `format` | any endpoint | `json` | `json`, `xml` | Response format; JSON is default and preferred |\n\n## Best Practices\n\n1. **Resolve set IDs before batch processing**: Use the `\u002Fspls` search to get set IDs, then fetch full labels by set ID. Do not construct set IDs from drug names — they are UUID identifiers assigned by FDA.\n\n2. **Add `time.sleep(0.3)` in batch loops**: DailyMed has no published rate limits but is public NIH infrastructure. Polite delays prevent throttling.\n   ```python\n   import time\n   for drug in drug_list:\n       result = search_spls(drug)\n       time.sleep(0.3)   # 200 requests\u002Fminute safe upper bound\n   ```\n\n3. **Use LOINC codes for section extraction, not text parsing**: Label sections are indexed by LOINC code, providing consistent section access across all SPL documents without brittle regex on section headers.\n\n4. **Pagination for comprehensive results**: The default `pagesize=20` may miss formulations. Use `metadata[\"total_elements\"]` to detect if pagination is needed:\n   ```python\n   meta = result[\"metadata\"]\n   total_pages = meta[\"total_pages\"]\n   if total_pages > 1:\n       for p in range(2, total_pages + 1):\n           result = search_spls(drug_name, page=p)\n   ```\n\n5. **Prefer RxCUI for clinical integration**: When integrating with clinical systems (EHR, dispensing), use RxCUI-based lookups (`\u002Frxcuis\u002F{rxcui}\u002Fspls`) for standardized, unambiguous drug identification.\n\n## Common Recipes\n\n### Recipe: Check if a Drug Has Black Box Warnings\n\nWhen to use: Quickly determine whether a drug carries the FDA's strongest warning level.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\nBLACK_BOX_LOINC = \"34066-1\"\n\ndef has_black_box_warning(setid):\n    \"\"\"Return True and warning text if drug label has a black box (boxed) warning.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}.json\", timeout=20)\n    r.raise_for_status()\n    sections = r.json()[\"data\"].get(\"sections\", [])\n    for sec in sections:\n        if sec.get(\"loinc_code\") == BLACK_BOX_LOINC:\n            return True, sec.get(\"text\", \"\")[:300]\n    return False, \"\"\n\n# Example: check warfarin label\nsetid = \"8b7c3d4e-5678-90ab-cdef-1234567890ab\"   # example warfarin setid\nhas_warning, text = has_black_box_warning(setid)\nprint(f\"Black box warning: {has_warning}\")\nif has_warning:\n    print(f\"Warning text (first 300 chars): {text}\")\n```\n\n### Recipe: Multi-Page Search with All Results\n\nWhen to use: Retrieve all matching labels for a drug when total count exceeds one page.\n\n```python\nimport requests\nimport time\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_all_spls(drug_name, pagesize=100, delay=0.3):\n    \"\"\"Retrieve all SPLs for a drug name across multiple pages.\"\"\"\n    all_labels = []\n    page = 1\n    while True:\n        r = requests.get(f\"{BASE}\u002Fspls.json\",\n                         params={\"drug_name\": drug_name, \"pagesize\": pagesize, \"page\": page},\n                         timeout=15)\n        r.raise_for_status()\n        data = r.json()\n        all_labels.extend(data[\"data\"])\n        if page >= data[\"metadata\"][\"total_pages\"]:\n            break\n        page += 1\n        time.sleep(delay)\n    return all_labels\n\nlabels = search_all_spls(\"ibuprofen\")\nprint(f\"Total ibuprofen labels: {len(labels)}\")\n```\n\n### Recipe: Export Label Summary to CSV\n\nWhen to use: Build a flat reference table of drug labels for offline analysis.\n\n```python\nimport requests\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef export_drug_labels(drug_name, pagesize=50):\n    \"\"\"Export label summaries for a drug name to DataFrame.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"drug_name\": drug_name, \"pagesize\": pagesize},\n                     timeout=15)\n    r.raise_for_status()\n    data = r.json()\n    df = pd.DataFrame(data[\"data\"])\n    df[\"drug_query\"] = drug_name\n    return df, data[\"metadata\"][\"total_elements\"]\n\ndf, total = export_drug_labels(\"amoxicillin\")\nprint(f\"Retrieved {len(df)} of {total} amoxicillin labels\")\ndf[[\"setid\", \"title\", \"published_date\"]].to_csv(\"amoxicillin_labels.csv\", index=False)\nprint(f\"Saved: amoxicillin_labels.csv  (columns: {list(df.columns[:5])})\")\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `404 Not Found` on `\u002Fspls\u002F{setid}` | Invalid or retired set ID | Re-search by drug name to get current set IDs |\n| Empty `data` list from search | Drug name not matching any labels | Try shorter name (e.g., `\"metformin\"` not `\"metformin HCl tablets\"`); check spelling |\n| Missing sections in SPL JSON | Older labels may not have all LOINC-coded sections | Check `len(sections)` before iterating; fall back to XML format for legacy labels |\n| `ConnectionError` \u002F timeout | DailyMed server overload | Retry with exponential backoff; increase `timeout=30` |\n| Pagination returning duplicates | Page boundary race condition | De-duplicate results by `setid` after all pages collected |\n| Packaging endpoint returns empty | Label exists but has no packaging records | Some biologics and vaccines lack packaging data; use label data directly |\n| RxCUI lookup returns no results | RxCUI not mapped in DailyMed | Verify RxCUI via RxNorm API before querying; some experimental drugs are not mapped |\n\n## Related Skills\n\n- `fda-database` — openFDA for adverse event reports (FAERS), drug recalls, and enforcement actions\n- `ddinter-database` — drug-drug interaction severity and mechanisms from DDInter\n- `drugbank-database-access` — comprehensive drug information including targets, pathways, and chemical properties\n- `clinicaltrials-database-search` — ClinicalTrials.gov for clinical trial data on drugs\n\n## References\n\n- [DailyMed](https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002F) — official drug label repository (NLM\u002FNIH)\n- [DailyMed Web Services API v2](https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fwebservices.cfm) — complete REST API documentation\n- [SPL Standard (HL7)](https:\u002F\u002Fwww.hl7.org\u002Fimplement\u002Fstandards\u002Fproduct_brief.cfm?product_id=4) — Structured Product Labeling standard documentation\n- [LOINC Document Ontology](https:\u002F\u002Floinc.org\u002Fdocument-ontology\u002F) — LOINC codes for SPL section identification\n- [NLM DailyMed Overview](https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fabout-dailymed.cfm) — data coverage and update frequency\n","# DailyMed Drug Label Database\n\n## Overview\n\nDailyMed is the National Library of Medicine's official repository of FDA-approved drug labeling information, containing 140,000+ structured product labels (SPLs) for prescription drugs, OTC medications, biologics, and vaccines. The REST API (v2) provides structured JSON\u002FXML access to the full label content including indications, dosage, warnings, contraindications, adverse reactions, and packaging data — with no authentication required.\n\n## When to Use\n\n- Retrieving official FDA-approved prescribing information for a drug by name, NDC code, or set ID\n- Extracting structured label sections (indications, warnings, dosage, adverse reactions) for pharmacological research\n- Looking up all marketed formulations of an active ingredient with packaging and NDC codes\n- Cross-referencing drug labels using RxCUI identifiers from RxNorm integration\n- Building drug information pipelines that require authoritative FDA label content (not user-reported data)\n- Comparing label content across brand name and generic formulations of the same drug\n- For adverse event reports from FAERS, use `fda-database` instead; DailyMed contains label text, not post-market safety signals\n- For drug-drug interaction severity data, use `ddinter-database`; DailyMed label text is unstructured for interactions\n\n## Prerequisites\n\n- **Python packages**: `requests`, `pandas`, `matplotlib`\n- **Data requirements**: drug names, NDC codes, set IDs, or RxCUI identifiers\n- **Environment**: internet connection; no API key required\n- **Rate limits**: no officially published limit; ~100 requests\u002Fminute is safe for polite access; add `time.sleep(0.3)` in batch loops\n\n```bash\npip install requests pandas matplotlib\n```\n\n## Quick Start\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\n# Search drug labels by name\nr = requests.get(f\"{BASE}\u002Fspls.json\", params={\"drug_name\": \"metformin\", \"pagesize\": 5})\nr.raise_for_status()\ndata = r.json()\nprint(f\"Total labels found: {data['metadata']['total_elements']}\")\nfor spl in data[\"data\"][:3]:\n    print(f\"  {spl['title']!r:60s}  setid={spl['setid']}\")\n```\n\n## Core API\n\n### Query 1: Search Drug Labels by Name\n\nSearch for structured product labels (SPLs) using drug name. Returns paginated list of matching labels with set IDs.\n\n```python\nimport requests\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_spls(drug_name, pagesize=20, page=1):\n    \"\"\"Search DailyMed SPLs by drug name. Returns list of label summaries.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"drug_name\": drug_name, \"pagesize\": pagesize, \"page\": page},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()\n\nresult = search_spls(\"atorvastatin\", pagesize=10)\nmeta = result[\"metadata\"]\nprint(f\"Search: 'atorvastatin' → {meta['total_elements']} labels across {meta['total_pages']} pages\")\n\ndf = pd.DataFrame(result[\"data\"])\nprint(df[[\"setid\", \"title\", \"published_date\"]].to_string(index=False))\n# setid                                  title                                   published_date\n# 8f6c7c7c-...  ATORVASTATIN CALCIUM tablet                               2024-03-15\n# a4b7d3e1-...  ATORVASTATIN CALCIUM tablet, film coated                  2023-11-20\n```\n\n### Query 2: Retrieve Full Label by Set ID\n\nFetch the complete structured product label for a specific drug using its set ID. Returns all label sections including indications, warnings, dosage, and adverse reactions.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef get_spl(setid):\n    \"\"\"Retrieve full SPL document by set ID. Returns label metadata and XML\u002FJSON.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}.json\", timeout=20)\n    r.raise_for_status()\n    return r.json()\n\n# Use a known set ID from search results\nsetid = \"8f6c7c7c-1f7f-4f1a-af86-8b2eef2a8b2c\"   # example atorvastatin label\nlabel = get_spl(setid)\ndata = label[\"data\"]\n\nprint(f\"Title: {data.get('title')}\")\nprint(f\"Set ID: {data.get('setid')}\")\nprint(f\"Published: {data.get('published_date')}\")\nprint(f\"Version: {data.get('version')}\")\n\n# Access structured sections\nif \"sections\" in data:\n    sections = data[\"sections\"]\n    print(f\"\\nLabel sections ({len(sections)} total):\")\n    for sec in sections[:5]:\n        print(f\"  [{sec.get('loinc_code', 'N\u002FA')}] {sec.get('title', 'Untitled')}\")\n```\n\n### Query 3: Search by NDC Code\n\nLook up drug labels by National Drug Code (NDC) — useful when you have a product barcode or dispensing record.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_by_ndc(ndc_code):\n    \"\"\"Find SPL by NDC code (formatted as XXXXX-XXXX-XX or without dashes).\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"ndc\": ndc_code},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()\n\n# NDC for Lipitor 10mg (atorvastatin)\nresult = search_by_ndc(\"0071-0155-23\")\nif result[\"data\"]:\n    spl = result[\"data\"][0]\n    print(f\"Drug: {spl['title']}\")\n    print(f\"Set ID: {spl['setid']}\")\n    print(f\"Published: {spl['published_date']}\")\nelse:\n    print(\"No label found for this NDC\")\n```\n\n### Query 4: Retrieve Packaging Information\n\nGet detailed packaging data (NDC codes, package types, quantities) for a specific drug label by set ID.\n\n```python\nimport requests\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef get_packaging(setid):\n    \"\"\"Retrieve packaging information for a label (NDC codes, dosage forms, quantities).\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}\u002Fpackaging.json\", timeout=15)\n    r.raise_for_status()\n    return r.json()\n\nsetid = \"8f6c7c7c-1f7f-4f1a-af86-8b2eef2a8b2c\"   # example setid\npkg = get_packaging(setid)\n\nif pkg[\"data\"]:\n    packages = pkg[\"data\"]\n    print(f\"Packaging variants: {len(packages)}\")\n    df = pd.DataFrame(packages)\n    # Common fields: ndc, dosage_form, route, marketing_status\n    for col in [\"ndc\", \"dosage_form\", \"route\", \"marketing_status\"]:\n        if col in df.columns:\n            print(f\"\\n{col.upper()}:\")\n            print(df[col].value_counts().head(5))\n```\n\n### Query 5: Look Up by RxCUI\n\nRetrieve drug labels using RxNorm Concept Unique Identifier (RxCUI) for integration with RxNorm-based clinical systems.\n\n```python\nimport requests\nimport time\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef get_spls_by_rxcui(rxcui):\n    \"\"\"Get all SPLs associated with an RxCUI. Returns list of set IDs and titles.\"\"\"\n    r = requests.get(f\"{BASE}\u002Frxcuis\u002F{rxcui}\u002Fspls.json\", timeout=15)\n    r.raise_for_status()\n    return r.json()\n\n# RxCUI for atorvastatin: 83367\nrxcui = \"83367\"\nresult = get_spls_by_rxcui(rxcui)\nprint(f\"SPLs for RxCUI {rxcui} (atorvastatin):\")\nfor spl in result[\"data\"][:5]:\n    print(f\"  {spl['setid']} | {spl['title'][:70]}\")\nprint(f\"  Total: {result['metadata']['total_elements']} labels\")\n```\n\n### Query 6: Search Drug Names Index\n\nList all standardized drug names in DailyMed — useful for name normalization and autocomplete in drug lookup pipelines.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_drug_names(query, pagesize=20):\n    \"\"\"Search the DailyMed drug name index for name normalization.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fdrugnames.json\",\n                     params={\"drug_name\": query, \"pagesize\": pagesize},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()\n\nresult = search_drug_names(\"metformin\")\nprint(f\"Drug name matches for 'metformin': {result['metadata']['total_elements']}\")\nfor entry in result[\"data\"][:8]:\n    print(f\"  {entry['drug_name']}\")\n# METFORMIN HYDROCHLORIDE\n# METFORMIN HYDROCHLORIDE AND SITAGLIPTIN PHOSPHATE\n# METFORMIN HYDROCHLORIDE AND SAXAGLIPTIN\n```\n\n### Query 7: Batch Label Section Extraction\n\nExtract specific label sections (e.g., indications, warnings) from multiple drug labels for comparative analysis.\n\n```python\nimport requests\nimport time\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\n# LOINC codes for common SPL sections\nSECTION_LOINC = {\n    \"34067-9\": \"Indications and Usage\",\n    \"34068-7\": \"Dosage and Administration\",\n    \"34071-1\": \"Warnings\",\n    \"34084-4\": \"Adverse Reactions\",\n    \"34070-3\": \"Contraindications\",\n    \"43685-7\": \"Warnings and Precautions\",\n}\n\ndef get_label_sections(setid):\n    \"\"\"Extract structured sections from an SPL by set ID.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}.json\", timeout=20)\n    r.raise_for_status()\n    data = r.json()[\"data\"]\n    sections = {}\n    for sec in data.get(\"sections\", []):\n        loinc = sec.get(\"loinc_code\")\n        if loinc in SECTION_LOINC:\n            sections[SECTION_LOINC[loinc]] = sec.get(\"text\", \"\")\n    return sections\n\n# Get indications for two statin labels\nstatins = [\n    (\"Atorvastatin\", \"8f6c7c7c-1f7f-4f1a-af86-8b2eef2a8b2c\"),\n    (\"Rosuvastatin\", \"a3b2c4d5-1234-5678-abcd-ef0123456789\"),   # example\n]\nrecords = []\nfor drug_name, setid in statins:\n    try:\n        sections = get_label_sections(setid)\n        records.append({\"drug\": drug_name, \"indications_length\": len(sections.get(\"Indications and Usage\", \"\"))})\n    except Exception as e:\n        print(f\"Warning: {drug_name} failed — {e}\")\n    time.sleep(0.3)\n\ndf = pd.DataFrame(records)\nprint(df.to_string(index=False))\n```\n\n## Key Concepts\n\n### Structured Product Label (SPL) and Set ID\n\nAn SPL is the official FDA-approved drug label in XML format, structured using Health Level 7 (HL7) Clinical Document Architecture (CDA). Each unique drug product label has a globally unique **set ID** (UUID format). Multiple versions of the same label share the same set ID but have different version numbers. Always use the most recent published version for current prescribing information.\n\n### LOINC Section Codes\n\nDailyMed SPLs use standardized LOINC codes to identify label sections, enabling consistent programmatic extraction across all labels:\n\n| LOINC Code | Section Name |\n|------------|-------------|\n| `34067-9` | Indications and Usage |\n| `34068-7` | Dosage and Administration |\n| `34070-3` | Contraindications |\n| `34071-1` | Warnings |\n| `43685-7` | Warnings and Precautions |\n| `34084-4` | Adverse Reactions |\n| `34073-7` | Drug Interactions |\n| `34076-0` | Patient Counseling Information |\n| `42229-5` | Mechanism of Action |\n| `34069-5` | How Supplied\u002FStorage |\n\n### NDC Code Format\n\nNational Drug Codes (NDCs) identify drug products with a three-segment numeric format: `labeler-product-package` (e.g., `0071-0155-23`). NDCs can also appear without dashes in some systems. DailyMed accepts both formats in API queries.\n\n## Common Workflows\n\n### Workflow 1: Drug Label Comparison by Active Ingredient\n\n**Goal**: Retrieve and compare label content for all formulations of an active ingredient — useful for generic vs. brand name comparison.\n\n```python\nimport requests\nimport time\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_spls(drug_name, pagesize=50):\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"drug_name\": drug_name, \"pagesize\": pagesize},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()\n\ndef get_packaging(setid):\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}\u002Fpackaging.json\", timeout=15)\n    r.raise_for_status()\n    return r.json()\n\n# Search for all metformin labels\nresult = search_spls(\"metformin\", pagesize=20)\nlabels = result[\"data\"]\nprint(f\"Found {len(labels)} metformin labels\")\n\nrows = []\nfor label in labels[:10]:   # limit for demo\n    setid = label[\"setid\"]\n    try:\n        pkg = get_packaging(setid)\n        for item in pkg[\"data\"][:2]:\n            rows.append({\n                \"title\": label[\"title\"][:60],\n                \"setid\": setid,\n                \"ndc\": item.get(\"ndc\"),\n                \"dosage_form\": item.get(\"dosage_form\"),\n                \"route\": item.get(\"route\"),\n                \"marketing_status\": item.get(\"marketing_status\"),\n                \"published_date\": label.get(\"published_date\"),\n            })\n    except Exception as e:\n        print(f\"Skipping {setid}: {e}\")\n    time.sleep(0.3)\n\ndf = pd.DataFrame(rows)\nprint(f\"\\nFormulations with packaging data: {len(df)}\")\nprint(df[[\"title\", \"dosage_form\", \"route\", \"marketing_status\"]].drop_duplicates().to_string(index=False))\ndf.to_csv(\"metformin_formulations.csv\", index=False)\nprint(\"\\nSaved: metformin_formulations.csv\")\n```\n\n### Workflow 2: Extract Warnings and Adverse Reactions for Safety Analysis\n\n**Goal**: Systematically extract structured warning and adverse reaction text from a set of drug labels for pharmacovigilance research.\n\n```python\nimport requests\nimport time\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\nTARGET_SECTIONS = {\n    \"34071-1\": \"Warnings\",\n    \"43685-7\": \"Warnings_and_Precautions\",\n    \"34084-4\": \"Adverse_Reactions\",\n    \"34070-3\": \"Contraindications\",\n}\n\ndef search_and_get_sections(drug_name, max_labels=5):\n    \"\"\"Search for labels and extract safety-relevant sections.\"\"\"\n    search_r = requests.get(f\"{BASE}\u002Fspls.json\",\n                            params={\"drug_name\": drug_name, \"pagesize\": max_labels},\n                            timeout=15)\n    search_r.raise_for_status()\n    labels = search_r.json()[\"data\"][:max_labels]\n\n    records = []\n    for label in labels:\n        setid = label[\"setid\"]\n        try:\n            label_r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}.json\", timeout=20)\n            label_r.raise_for_status()\n            spl_data = label_r.json()[\"data\"]\n\n            row = {\"drug_name\": drug_name, \"title\": label[\"title\"][:80], \"setid\": setid}\n            for loinc, col in TARGET_SECTIONS.items():\n                text = \"\"\n                for sec in spl_data.get(\"sections\", []):\n                    if sec.get(\"loinc_code\") == loinc:\n                        text = sec.get(\"text\", \"\")[:500]   # first 500 chars\n                        break\n                row[col] = text\n            records.append(row)\n        except Exception as e:\n            print(f\"  Skipping {setid}: {e}\")\n        time.sleep(0.3)\n\n    return pd.DataFrame(records)\n\n# Compare safety sections across ACE inhibitor labels\ndrugs = [\"lisinopril\", \"enalapril\"]\nall_records = []\nfor drug in drugs:\n    print(f\"Processing: {drug}\")\n    df = search_and_get_sections(drug, max_labels=3)\n    all_records.append(df)\n\ncombined = pd.concat(all_records, ignore_index=True)\nprint(f\"\\nExtracted safety sections: {len(combined)} labels\")\nprint(combined[[\"drug_name\", \"title\"]].to_string(index=False))\ncombined.to_csv(\"ace_inhibitor_safety_sections.csv\", index=False)\nprint(\"Saved: ace_inhibitor_safety_sections.csv\")\n```\n\n### Workflow 3: Visualize Label Distribution by Drug Class\n\n**Goal**: Query multiple drugs in a class, count their labeled formulations, and visualize the distribution.\n\n```python\nimport requests\nimport time\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef count_labels(drug_name):\n    \"\"\"Return total SPL count for a drug name.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"drug_name\": drug_name, \"pagesize\": 1},\n                     timeout=15)\n    r.raise_for_status()\n    return r.json()[\"metadata\"][\"total_elements\"]\n\n# Count labels for common statins\nstatins = {\n    \"atorvastatin\": \"Atorvastatin\",\n    \"rosuvastatin\": \"Rosuvastatin\",\n    \"simvastatin\": \"Simvastatin\",\n    \"pravastatin\": \"Pravastatin\",\n    \"lovastatin\": \"Lovastatin\",\n    \"fluvastatin\": \"Fluvastatin\",\n    \"pitavastatin\": \"Pitavastatin\",\n}\n\ncounts = {}\nfor query, label in statins.items():\n    try:\n        counts[label] = count_labels(query)\n        print(f\"  {label}: {counts[label]} labels\")\n    except Exception as e:\n        print(f\"  {label}: error — {e}\")\n    time.sleep(0.3)\n\n# Visualization\ndf = pd.DataFrame(list(counts.items()), columns=[\"Drug\", \"Label_Count\"])\ndf = df.sort_values(\"Label_Count\", ascending=True)\n\nfig, ax = plt.subplots(figsize=(9, 5))\nbars = ax.barh(df[\"Drug\"], df[\"Label_Count\"], color=\"#2196F3\", edgecolor=\"white\")\nax.bar_label(bars, fmt=\"%d\", padding=4, fontsize=9)\nax.set_xlabel(\"Number of DailyMed SPL Entries\")\nax.set_title(\"DailyMed: FDA Drug Label Count by Statin\\n(includes brand + generic formulations)\")\nax.set_xlim(0, df[\"Label_Count\"].max() * 1.15)\nplt.tight_layout()\nplt.savefig(\"statin_label_counts.png\", dpi=150, bbox_inches=\"tight\")\nprint(f\"Saved: statin_label_counts.png  (total labels: {df['Label_Count'].sum()})\")\n```\n\n## Key Parameters\n\n| Parameter | Endpoint | Default | Range \u002F Options | Effect |\n|-----------|----------|---------|-----------------|--------|\n| `drug_name` | `\u002Fspls`, `\u002Fdrugnames` | — | any drug name string | Filter labels by drug name (partial match supported) |\n| `ndc` | `\u002Fspls` | — | NDC code string | Filter labels by National Drug Code |\n| `pagesize` | `\u002Fspls`, `\u002Fdrugnames` | `20` | `1`–`100` | Results per page; max 100 |\n| `page` | `\u002Fspls`, `\u002Fdrugnames` | `1` | positive integer | Page number for pagination |\n| `setid` | `\u002Fspls\u002F{setid}`, `\u002Fspls\u002F{setid}\u002Fpackaging` | — | UUID string | Unique label identifier; required for direct access |\n| `rxcui` | `\u002Frxcuis\u002F{rxcui}\u002Fspls` | — | RxNorm concept ID | Look up labels by RxCUI for clinical system integration |\n| `format` | any endpoint | `json` | `json`, `xml` | Response format; JSON is default and preferred |\n\n## Best Practices\n\n1. **Resolve set IDs before batch processing**: Use the `\u002Fspls` search to get set IDs, then fetch full labels by set ID. Do not construct set IDs from drug names — they are UUID identifiers assigned by FDA.\n\n2. **Add `time.sleep(0.3)` in batch loops**: DailyMed has no published rate limits but is public NIH infrastructure. Polite delays prevent throttling.\n   ```python\n   import time\n   for drug in drug_list:\n       result = search_spls(drug)\n       time.sleep(0.3)   # 200 requests\u002Fminute safe upper bound\n   ```\n\n3. **Use LOINC codes for section extraction, not text parsing**: Label sections are indexed by LOINC code, providing consistent section access across all SPL documents without brittle regex on section headers.\n\n4. **Pagination for comprehensive results**: The default `pagesize=20` may miss formulations. Use `metadata[\"total_elements\"]` to detect if pagination is needed:\n   ```python\n   meta = result[\"metadata\"]\n   total_pages = meta[\"total_pages\"]\n   if total_pages > 1:\n       for p in range(2, total_pages + 1):\n           result = search_spls(drug_name, page=p)\n   ```\n\n5. **Prefer RxCUI for clinical integration**: When integrating with clinical systems (EHR, dispensing), use RxCUI-based lookups (`\u002Frxcuis\u002F{rxcui}\u002Fspls`) for standardized, unambiguous drug identification.\n\n## Common Recipes\n\n### Recipe: Check if a Drug Has Black Box Warnings\n\nWhen to use: Quickly determine whether a drug carries the FDA's strongest warning level.\n\n```python\nimport requests\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\nBLACK_BOX_LOINC = \"34066-1\"\n\ndef has_black_box_warning(setid):\n    \"\"\"Return True and warning text if drug label has a black box (boxed) warning.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls\u002F{setid}.json\", timeout=20)\n    r.raise_for_status()\n    sections = r.json()[\"data\"].get(\"sections\", [])\n    for sec in sections:\n        if sec.get(\"loinc_code\") == BLACK_BOX_LOINC:\n            return True, sec.get(\"text\", \"\")[:300]\n    return False, \"\"\n\n# Example: check warfarin label\nsetid = \"8b7c3d4e-5678-90ab-cdef-1234567890ab\"   # example warfarin setid\nhas_warning, text = has_black_box_warning(setid)\nprint(f\"Black box warning: {has_warning}\")\nif has_warning:\n    print(f\"Warning text (first 300 chars): {text}\")\n```\n\n### Recipe: Multi-Page Search with All Results\n\nWhen to use: Retrieve all matching labels for a drug when total count exceeds one page.\n\n```python\nimport requests\nimport time\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef search_all_spls(drug_name, pagesize=100, delay=0.3):\n    \"\"\"Retrieve all SPLs for a drug name across multiple pages.\"\"\"\n    all_labels = []\n    page = 1\n    while True:\n        r = requests.get(f\"{BASE}\u002Fspls.json\",\n                         params={\"drug_name\": drug_name, \"pagesize\": pagesize, \"page\": page},\n                         timeout=15)\n        r.raise_for_status()\n        data = r.json()\n        all_labels.extend(data[\"data\"])\n        if page >= data[\"metadata\"][\"total_pages\"]:\n            break\n        page += 1\n        time.sleep(delay)\n    return all_labels\n\nlabels = search_all_spls(\"ibuprofen\")\nprint(f\"Total ibuprofen labels: {len(labels)}\")\n```\n\n### Recipe: Export Label Summary to CSV\n\nWhen to use: Build a flat reference table of drug labels for offline analysis.\n\n```python\nimport requests\nimport pandas as pd\n\nBASE = \"https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fservices\u002Fv2\"\n\ndef export_drug_labels(drug_name, pagesize=50):\n    \"\"\"Export label summaries for a drug name to DataFrame.\"\"\"\n    r = requests.get(f\"{BASE}\u002Fspls.json\",\n                     params={\"drug_name\": drug_name, \"pagesize\": pagesize},\n                     timeout=15)\n    r.raise_for_status()\n    data = r.json()\n    df = pd.DataFrame(data[\"data\"])\n    df[\"drug_query\"] = drug_name\n    return df, data[\"metadata\"][\"total_elements\"]\n\ndf, total = export_drug_labels(\"amoxicillin\")\nprint(f\"Retrieved {len(df)} of {total} amoxicillin labels\")\ndf[[\"setid\", \"title\", \"published_date\"]].to_csv(\"amoxicillin_labels.csv\", index=False)\nprint(f\"Saved: amoxicillin_labels.csv  (columns: {list(df.columns[:5])})\")\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `404 Not Found` on `\u002Fspls\u002F{setid}` | Invalid or retired set ID | Re-search by drug name to get current set IDs |\n| Empty `data` list from search | Drug name not matching any labels | Try shorter name (e.g., `\"metformin\"` not `\"metformin HCl tablets\"`); check spelling |\n| Missing sections in SPL JSON | Older labels may not have all LOINC-coded sections | Check `len(sections)` before iterating; fall back to XML format for legacy labels |\n| `ConnectionError` \u002F timeout | DailyMed server overload | Retry with exponential backoff; increase `timeout=30` |\n| Pagination returning duplicates | Page boundary race condition | De-duplicate results by `setid` after all pages collected |\n| Packaging endpoint returns empty | Label exists but has no packaging records | Some biologics and vaccines lack packaging data; use label data directly |\n| RxCUI lookup returns no results | RxCUI not mapped in DailyMed | Verify RxCUI via RxNorm API before querying; some experimental drugs are not mapped |\n\n## Related Skills\n\n- `fda-database` — openFDA for adverse event reports (FAERS), drug recalls, and enforcement actions\n- `ddinter-database` — drug-drug interaction severity and mechanisms from DDInter\n- `drugbank-database-access` — comprehensive drug information including targets, pathways, and chemical properties\n- `clinicaltrials-database-search` — ClinicalTrials.gov for clinical trial data on drugs\n\n## References\n\n- [DailyMed](https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002F) — official drug label repository (NLM\u002FNIH)\n- [DailyMed Web Services API v2](https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fwebservices.cfm) — complete REST API documentation\n- [SPL Standard (HL7)](https:\u002F\u002Fwww.hl7.org\u002Fimplement\u002Fstandards\u002Fproduct_brief.cfm?product_id=4) — Structured Product Labeling standard documentation\n- [LOINC Document Ontology](https:\u002F\u002Floinc.org\u002Fdocument-ontology\u002F) — LOINC codes for SPL section identification\n- [NLM DailyMed Overview](https:\u002F\u002Fdailymed.nlm.nih.gov\u002Fdailymed\u002Fabout-dailymed.cfm) — data coverage and update frequency\n",{"name":5,"license":15,"description":7},"master","63f17866001c5ca854bf2fa0b678ce277133de5b","skills\u002Fawesome-skills\u002Fdailymed-database",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill dailymed-database",{"tool":40,"command":41},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill dailymed-database",{"tool":43,"command":44},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill dailymed-database","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fdailymed-database\u002FSKILL.md",true,[],[49,58,65,72,79,86],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":57},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":57},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":57},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":57},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":57},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":57},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]