CoolFace
Apppublic

Darkweb007/drug-interaction-agent

sourceHugging Facemitupdated 3mo agoView on Hugging Face
0likes
App README

๐Ÿ’Š Drug-Drug Interaction Safety Screener

๐Ÿ”— [Live n8n Workflow](https://aravind5.app.n8n.cloud/workflow/QaObEWNz4WserMiL)

An n8n-powered clinical pharmacy automation agent that intercepts new prescriptions via webhook, cross-checks against the patient's full medication list using OpenFDA and RxNorm APIs, and either holds the prescription with physician alerts or clears it for dispensing โ€” all within seconds of submission.

What It Does

The agent triggers on every new prescription submission and automatically:

  1. 1.Receives prescription via webhook โ€” patient data, new drug, current medications, and allergies
  2. 2.Queries OpenFDA โ€” retrieves contraindications and black-box warnings for the new drug
  3. 3.Queries RxNorm API โ€” checks all drug-drug interaction pairs with severity ratings
  4. 4.Analyzes severity โ€” classifies interactions as CRITICAL, HIGH, MODERATE, or LOW
  5. 5.Runs AI clinical reasoning โ€” GPT-4o-mini applies evidence-based pharmacology guidelines
  6. 6.Routes the decision โ€” HOLD triggers physician + pharmacist alerts, CLEAR sends dispensing note
  7. 7.Recommends alternatives โ€” suggests safer substitute medications when applicable

n8n Workflow Architecture

mermaid
flowchart TD
    A[Webhook Trigger\nNew Prescription] --> B[Extract Prescription Data\nSet Node]
    B --> C[Query OpenFDA\nContraindications + Warnings]
    C --> D[Query RxNorm API\nDrug Interaction Pairs]
    D --> E[Analyze Interaction Severity\nCode Node]
    E --> F{High Risk\nInteraction?}
    F -->|YES| G[AI Clinical Safety Reasoning\nGPT-4o-mini]
    G --> H[Extract Safety Assessment\nSet Node]
    H --> I[Alert Physician\nGmail - Prescription Hold]
    I --> J[Alert Pharmacist\nGmail - Hold Notice]
    F -->|NO| K[Send Clearance Note\nGmail - Pharmacist]

Setup Instructions

1. Clone or fork this Space

bash
git clone https://huggingface.co/spaces/Darkweb007/drug-interaction-agent
cd drug-interaction-agent

2. Install dependencies

bash
pip install -r requirements.txt

3. Configure Secrets

In your Hugging Face Space settings, add the following secret:

Secret NameDescriptionRequired
OPENAI_API_KEYOpenAI API key for GPT-4o-miniYes (for Tab 2)

Navigate to: Space Settings โ†’ Variables and Secrets โ†’ New Secret

4. Run locally

bash
python app.py

5. Deploy to HF Spaces

Push to your Space repository โ€” it will build and deploy automatically.

n8n Integration

To connect this UI to a real n8n workflow:

  1. 1.Open the live n8n workflow linked above
  2. 2.Copy the webhook URL from the trigger node
  3. 3.Configure your EHR/pharmacy system to POST new prescriptions to this webhook
  4. 4.Set physician and pharmacist email addresses in the Gmail nodes
  5. 5.Add Gmail OAuth2 credentials
  6. 6.Activate the workflow โ€” it responds in real time to every prescription submission

Supported Systems

SystemAction
OpenFDA APIContraindications and black-box warnings retrieval
RxNorm / NIH APIDrug-drug interaction pair severity lookup
GmailPhysician hold alert + pharmacist clearance or hold notice
OpenAI GPT-4o-miniClinical reasoning and alternative medication suggestions
EHR / PMS WebhookPrescription submission integration point

Decision Logic

Risk LevelCriteriaAction
๐Ÿ”ด CRITICALBlack-box warning or known fatal interactionHOLD โ€” immediate physician alert
๐ŸŸ  HIGHSevere interaction requiring managementHOLD โ€” physician + pharmacist alert
๐ŸŸก MODERATEClinically significant, monitoring neededAPPROVE with monitoring parameters
๐ŸŸข LOWMinor or theoretical riskAPPROVE โ€” clearance note sent

License

MIT