Skip to content

Guembri01/rxsafe-ai

Repository files navigation

RxSafe AI

Catches every drug-drug interaction and allergy contradiction during a pharmacist consultation in seconds — instead of an MD calling the pharmacist after the patient is home.

RxSafe Interaction Knowledge Base showing 35 drug-drug interactions, FDA-sourced, AI-powered mechanism notes; severity pills (6 contraindicated, 19 major, 10 moderate); table with Metformin/Iodinated Contrast Media, MAOIs/SSRIs, Sildenafil/Nitrates with CYP3A4 enzyme tag, Warfarin/Aspirin with CYP2C9.


The problem

Pharmacists at independent and community pharmacies counsel patients on dozens of prescriptions per day. The clinically critical question — does this new drug interact dangerously with what they already take or with their allergies? — gets answered by memory and a quick Drugs.com lookup. Cross-reactivity (penicillin → amoxicillin → augmentin) is easy to miss. Critical interactions like Linezolid + Tramadol (serotonin syndrome) require the pharmacist to remember that both enzyme pathways are involved.

What this does

RxSafe ingests the voice consultation between pharmacist and patient (Whisper Large v3), extracts OTC mentions across 8 drug categories, extracts supplement mentions across 8 categories, extracts allergies from "allergic to X" patterns, cross-checks against the patient's active prescriptions, runs a curated drug-interaction map keyed by CYP enzyme pathway, surfaces critical allergy contradictions with cross-reactivity heuristics (penicillin → amoxicillin/ampicillin/augmentin), and generates a consultation brief PDF for the patient and the pharmacist's audit trail.

Real-world scenario

A pharmacist counsels Barbara, 67, on a new Warfarin prescription. She mentions she's been taking St John's Wort for mood and her grandson's leftover Tramadol when she pulled her back. RxSafe surfaces: CRITICAL: Warfarin + Aspirin via CYP2C9 (she's also taking 81 mg aspirin for cardiac); MAJOR: St John's Wort + SSRI / serotonergic agents — serotonin syndrome risk with Tramadol; CONTRAINDICATED: Linezolid + Tramadol if she's still on Linezolid from her recent UTI course. The pharmacist swaps Tramadol for Tylenol Arthritis, schedules a Warfarin level in 3 days, and prints the consultation brief.

Why it saves time

Metric Manual approach RxSafe Improvement
Per-consultation interaction check manual lookup per drug pair automatic across full medication list qualitative
Cross-reactivity catch rate depends on pharmacist's memory systematic via heuristic map qualitative
Audit trail manual notes PDF + verbatim voice quotes per finding manual → automated

Key features

  • Voice consultation pipeline with Whisper Large v3.
  • OTC + supplement detector across 16 categories.
  • Allergy extractor with cross-reactivity heuristic (penicillin family, sulfa family, etc.).
  • _INTERACTION_RISK_MAP keyed by CYP enzyme pathway and active substance pair.
  • Severity bands — Contraindicated / Major / Moderate / Minor.
  • Allergy-vs-Rx contradiction detector surfaced as the top of the brief.
  • Consultation brief PDF with verbatim voice quotes per finding.
  • Active prescription coverage showing what the pharmacist mentioned vs missed.

How it works

The non-obvious decision was to key the interaction map by CYP enzyme pathway, not by drug name. Drug names change (brand vs generic, regional vs international). CYP pathways are stable: CYP3A4, CYP2C9, CYP2D6 are the same in every textbook and every label. By normalising to the enzyme pathway, the same interaction rule covers Coumadin, Warfarin, Marevan, and Jantoven. New drugs get added by tagging their CYP profile, not by adding new rules.

Architecture

flowchart LR
    Consult[Pharmacist Voice Consultation] -->|Whisper| Transcript
    Transcript --> OTC[OTC Mention Detector]
    Transcript --> Supp[Supplement Detector]
    Transcript --> Allerg[Allergy Extractor]
    Patient[(Patient Active Rx)] --> Map
    OTC --> Map[CYP Pathway Interaction Map]
    Supp --> Map
    Map --> Findings[(Findings + Severity)]
    Allerg --> CrossReact[Cross-Reactivity Resolver]
    CrossReact --> Findings
    Findings --> Brief[Consultation Brief PDF]
Loading

Screenshots

Interaction knowledge base with CYP tags

Interaction list with severity pills, CYP enzyme tags, and FDA-sourced badge.

Patient detail

Patient detail with active Rx list, allergies, recent consultations.

Alerts

Active alerts across the pharmacy patient roster.

Analytics

Analytics with interaction-finding mix and patient-coverage trend.

Dashboard

Pharmacy dashboard with KPIs and recent activity.

Stack

  • Backend: fastapi, sqlalchemy + PostgreSQL, openai SDK via DeepInfra (Whisper), reportlab (consultation brief PDF).
  • Frontend: react + vite + react-router-dom, @tanstack/react-query.
  • Infra: Docker Compose (api, worker, postgres, redis, frontend).

Quick start

git clone https://github.com/Guembri01/rxsafe-ai.git
cd rxsafe-ai
cp .env.example .env   # DEEPINFRA_API_KEY, OPENAI_API_KEY, JWT_SECRET
docker compose up -d
# API: http://localhost:8028/docs — UI: http://localhost:5028

Limitations

  • Curated interaction map, not a live drug-database subscription. Adding a new high-risk pair is a code change today.
  • English consultations only. Spanish-language counselling needs re-tuned mention regexes.
  • No pharmacy-management-system integration. Active prescriptions are loaded into RxSafe directly; no bidirectional sync yet.
  • Allergy cross-reactivity covers common families (penicillin, sulfa). Rare cross-reactivity (cephalosporin-penicillin partial) needs case-specific rules.

Roadmap

  • Spanish-language consultation support.
  • FDA Orange Book + RxNorm live subscription for the interaction map.
  • Bidirectional integration with major pharmacy management systems.
  • Pharmacist-facing mobile app for at-counter counselling.
  • CYP pathway-keyed interaction map.
  • Allergy cross-reactivity resolver.
  • Consultation brief PDF with verbatim voice quotes.

What I learned

  • CYP pathway normalisation beats drug-name string matching for clinical defensibility — every textbook agrees on the pathway.
  • Allergy contradictions deserve top-of-brief placement. They are the highest-severity finding and need to be the first thing the pharmacist reads.

License

Released under the MIT License.

Acknowledgements

Built with FastAPI, SQLAlchemy, React, Whisper via DeepInfra, and ReportLab.

About

Catches every drug-drug interaction and allergy contradiction during a pharmacist consultation in seconds.

Topics

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors