Darkweb007/drug-interaction-agent
0
๐ 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:
- Receives prescription via webhook โ patient data, new drug, current medications, and allergies
- Queries OpenFDA โ retrieves contraindications and black-box warnings for the new drug
- Queries RxNorm API โ checks all drug-drug interaction pairs with severity ratings
- Analyzes severity โ classifies interactions as CRITICAL, HIGH, MODERATE, or LOW
- Runs AI clinical reasoning โ GPT-4o-mini applies evidence-based pharmacology guidelines
- Routes the decision โ HOLD triggers physician + pharmacist alerts, CLEAR sends dispensing note
- Recommends alternatives โ suggests safer substitute medications when applicable
n8n Workflow Architecture
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
git clone https://huggingface.co/spaces/Darkweb007/drug-interaction-agent
cd drug-interaction-agent2. Install dependencies
pip install -r requirements.txt3. Configure Secrets
In your Hugging Face Space settings, add the following secret:
Navigate to: Space Settings โ Variables and Secrets โ New Secret
4. Run locally
python app.py5. 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:
- Open the live n8n workflow linked above
- Copy the webhook URL from the trigger node
- Configure your EHR/pharmacy system to POST new prescriptions to this webhook
- Set physician and pharmacist email addresses in the Gmail nodes
- Add Gmail OAuth2 credentials
- Activate the workflow โ it responds in real time to every prescription submission
Supported Systems
Decision Logic
License
MIT
