Skip to main content

Overview

The /api/safety-check endpoint provides rapid drug-drug interaction screening:
  • RxNorm API integration for FDA-sourced interaction data
  • DrugBank local database for mechanism-based interactions
  • Query-based lookup (no request body required)
  • Ideal for quick checks during prescribing workflows
For comprehensive medication safety analysis integrated with patient context, use the analyze endpoint which includes the full Medical Error Prevention Panel.

Endpoint

GET http://localhost:8000/api/safety-check?drugs=metformin,lisinopril,aspirin

Query Parameters

drugs
string
required
Comma-separated list of drug names (generic or brand names)
Drug names are case-insensitive. Use generic names for best results (e.g., “metformin” rather than “Glucophage”).

Response

rxnorm_interactions
array | string
RxNorm interaction results (array of interactions, or error message string)
drugbank
array | string
DrugBank interaction results (array of interactions, or error message string)

RxNorm Interaction Object

DrugBank Interaction Object

Example Request

curl "http://localhost:8000/api/safety-check?drugs=warfarin,aspirin,ibuprofen"

Example Response

{
  "rxnorm_interactions": [
    {
      "drug_a": "warfarin",
      "drug_b": "aspirin",
      "severity": "",
      "description": "The risk or severity of bleeding can be increased when Warfarin is combined with Aspirin."
    },
    {
      "drug_a": "warfarin",
      "drug_b": "ibuprofen",
      "severity": "",
      "description": "The risk or severity of bleeding can be increased when Warfarin is combined with Ibuprofen."
    },
    {
      "drug_a": "aspirin",
      "drug_b": "ibuprofen",
      "severity": "",
      "description": "Ibuprofen may decrease the cardioprotective effect of Aspirin."
    }
  ],
  "drugbank": [
    {
      "drug_a": "warfarin",
      "drug_b": "aspirin",
      "severity": "major",
      "description": "Concurrent use of warfarin and aspirin significantly increases bleeding risk.",
      "mechanism": "Additive antiplatelet and anticoagulant effects. Aspirin inhibits COX-1 (platelet aggregation) while warfarin inhibits vitamin K-dependent clotting factors.",
      "recommendation": "Avoid combination unless clinically necessary (e.g., mechanical heart valve). If used together, monitor INR closely and assess for bleeding signs."
    },
    {
      "drug_a": "warfarin",
      "drug_b": "ibuprofen",
      "severity": "major",
      "description": "NSAIDs like ibuprofen increase bleeding risk when combined with warfarin.",
      "mechanism": "NSAIDs inhibit platelet aggregation and may cause GI ulceration, increasing bleeding risk in anticoagulated patients.",
      "recommendation": "Avoid NSAIDs in patients on warfarin. Use acetaminophen for analgesia. If NSAID necessary, use lowest dose for shortest duration and monitor INR."
    },
    {
      "drug_a": "aspirin",
      "drug_b": "ibuprofen",
      "severity": "moderate",
      "description": "Ibuprofen may interfere with the cardioprotective effects of low-dose aspirin.",
      "mechanism": "Ibuprofen binds to COX-1 active site, preventing aspirin's irreversible acetylation of platelet COX-1.",
      "recommendation": "Take aspirin at least 2 hours before ibuprofen. Consider alternative analgesics (e.g., acetaminophen) in patients requiring daily aspirin."
    }
  ]
}

Example: No Interactions Found

curl "http://localhost:8000/api/safety-check?drugs=metformin,vitamin-d"
Response:
{
  "rxnorm_interactions": [],
  "drugbank": []
}

Example: Error Handling

If one data source fails, the other will still return results:
{
  "rxnorm_interactions": "Error: RxNorm API timeout",
  "drugbank": [
    {
      "drug_a": "warfarin",
      "drug_b": "aspirin",
      "severity": "major",
      "description": "Concurrent use of warfarin and aspirin significantly increases bleeding risk.",
      "mechanism": "Additive antiplatelet and anticoagulant effects.",
      "recommendation": "Avoid combination unless clinically necessary."
    }
  ]
}

Error Responses

400 Bad Request

{
  "detail": "Provide comma-separated drug names in 'drugs' param"
}

Data Sources

RxNorm

  • Source: NLM (National Library of Medicine) RxNorm Interaction API
  • Coverage: FDA-sourced drug interactions
  • Strengths: Comprehensive coverage, frequently updated
  • Limitations: Severity data often missing; descriptions may be generic

DrugBank

  • Source: Local DrugBank database (requires DrugBank download)
  • Coverage: Curated drug-drug interactions with mechanisms
  • Strengths: Detailed mechanisms, severity classifications, clinical recommendations
  • Limitations: Requires local database setup; may be less current than RxNorm
DrugBank data requires a local database. If DrugBank is not configured, that section will return an error message.

Use Cases

Prescribing Checks

Quick interaction screening before prescribing

EHR Integration

Embed in EHR workflows for real-time alerts

Medication Reconciliation

Screen patient med lists during transitions of care

Education

Teaching tool for pharmacy/medical students

Comparison: /api/safety-check vs Full Analysis

Feature/api/safety-check/api/analyze (Med Error Panel)
InputDrug names onlyFull patient context
OutputDrug-drug interactionsDrug-drug + drug-disease + dosing + population flags
ContextNo patient dataAge, weight, conditions, labs, allergies
Speed<1 secondPart of 15-30s full analysis
Use CaseQuick lookupComprehensive medication review
For patient-specific safety analysis (e.g., renal dosing, drug-disease contraindications), use the full analyze endpoint which considers patient age, weight, kidney function, and comorbidities.

Notes

This endpoint provides drug-drug interactions only. It does NOT account for patient-specific factors like renal function, weight, age, or comorbidities. For comprehensive safety analysis, use the analyze endpoint.
Drug names should be generic names for best results. Brand names may work but coverage varies.

Build docs developers (and LLMs) love