The problem

Preventable medication errors send 1.3 million people to the ER every year. The evidence to stop most of them already exists in FDA drug labels — but no clinician can read every label, and today's alerts are ignored over 90% of the time because they never explain their reasoning for the specific patient.

What it does

MedGuard is a multi-agent digital clinical pharmacist. Submit a patient's history and proposed medications; every drug comes back ✅ Approved, ⚠️ Approved with Caution, or ❌ Contraindicated — with the FDA label text quoted verbatim as evidence and safe alternatives suggested. Example: for a stage 4 CKD patient, ibuprofen is flagged contraindicated with the label's exact renal warning. Full pipeline: ~25 seconds.

How Elastic powers it

Elasticsearch is the intelligence layer. The agent has zero hardcoded drug knowledge — everything comes from the fda_drug_labels index (the complete FDA label dataset) at runtime.

The ClinicalPharmacistAgent connects through Elastic's MCP server and writes its own ES|QL queries on the fly for each drug:

FROM fda_drug_labels
| WHERE generic_name LIKE "*ibuprofen*"
| KEEP brand_name, contraindications, warnings_and_cautions

Because the agent composes ES|QL itself, it handles brand names, generics, and partial matches with no query templates — Elastic's search precision paired with Gemini's clinical reasoning makes every verdict traceable to an official source.

Architecture

Four Gemini agents in sequence (Google ADK): propose prescriptions → query Elastic & evaluate → structure as JSON → render the clinical report. A Bun server streams the live agent timeline to the browser via SSE. Ships as a Docker Compose stack (Elasticsearch + MCP + app), fully local.

What's next

Drug–drug interaction analysis, dose adjustments for renal/hepatic function, and EHR integration at the point of prescribing.

Built With

Share this project:

Updates