A 9-agent clinical decision-support pipeline that gathers evidence, prescribes intelligently, and catches safety issues before any medicine reaches a patient.
GATHER
Agents 1, 2, 3, 4, 5
Collect patient data, transcript, similar cases, medical evidence, allergy context
PRESCRIBE
Agents 6
Generate a complete prescription from all gathered data
VERIFY
Agents 7, 8
Check drug interactions + allergy safety. Loop back if issues found
DETECT
Agents 9
Find new lifelong meds + allergies, propose to patient
Patient Profile
54yo Male, Type 2 Diabetes, Hypertension. Allergy: Penicillin (confirmed severe). Current meds: Metformin 500mg, Amlodipine 5mg.
Booking Symptoms
"Fever, body ache, sore throat" — Duration: 3 days — Severity: Moderate
Agent 3 finds
5 similar URTI cases — dominant treatment: Azithromycin + Paracetamol. NSAIDs consistently avoided in diabetic patients.
Agent 4 retrieves
MedlinePlus: "During infection, diabetic patients may have elevated blood sugar." Red flag: Avoid NSAIDs, avoid penicillin class.
Agent 5 expands
Penicillin → HARD BLOCK: Amoxicillin, Ampicillin, Piperacillin... Cross-reactivity: 1st-gen Cephalosporins.
Agent 6 prescribes
Azithromycin chosen over Amoxicillin (penicillin allergy). Paracetamol chosen over Ibuprofen (diabetes + hypertension).
Agent 7 — PASS
0 interactions found. All dosages within approved range.
Agent 8 — PASS
No allergy violations. Azithromycin is NOT in the penicillin class.
Agent 6 prescribes Amoxicillin (a penicillin) for a patient with penicillin allergy.
Agent 7 catches it: "Amoxicillin is a Penicillin-class drug. HARD BLOCK."
Pipeline loops back to Agent 6: "Replace Amoxicillin with a non-penicillin alternative."
Agent 6 revises: Azithromycin 500mg (macrolide, safe for penicillin allergy).
Doctor sees: Amoxicillin red-marked with the reason, Azithromycin in the clean prescription. Only clean drugs reach the patient.
Triggered: Profile save
Reads the patient's profile data — age, conditions, allergies, medications — and generates a clinical summary using Gemini. Also builds a running summary from all past consultations, giving the doctor instant context before each visit.
Data Sources
Output
Profile Summary + Running Clinical Summary
Triggered: Call ends
Takes the raw Agora call transcript and structures it: extracts who said what, identifies symptoms, duration, severity, and every medication mentioned. Each drug name is normalized through RxNorm — so 'Paracetamol' becomes 'acetaminophen' (the universal medical name), and misspellings like 'amoxacillin' get corrected to 'amoxicillin'.
Data Sources
Output
Structured transcript + RxNorm-normalized drugs
Triggered: Lock button
Searches through 100+ past patient cases using hybrid search: semantic vector search (finds cases with similar meaning) combined with keyword matching (exact symptom terms). Boosts cases from patients with matching conditions (e.g., diabetic patients rank higher for a diabetic patient). Then Gemini reranks the top 20 down to the 10 most relevant.
Data Sources
Output
Top 10 similar cases + pattern summary
Triggered: Lock button
Resolves each of the patient's known conditions to an ICD-10 code (first checking a local lookup table of 2,132 conditions, then falling back to the NIH Clinical Tables API). Uses each code to fetch the official MedlinePlus page, then condenses it with Gemini. Also builds 5 targeted search queries and runs them against a knowledge library of 3,347 embedded medical chunks (MedlinePlus conditions + openFDA drug data) to produce an evidence summary.
Data Sources
Output
Condition summaries + Evidence summary (findings, diagnoses, red flags)
Triggered: Lock button
Expands each of the patient's allergies into a full drug-class avoid list. 'Penicillin allergy' expands to the entire penicillin family — Amoxicillin, Ampicillin, Piperacillin — plus cross-reactivity warnings (1st-gen cephalosporins). Uses a severity/status system: confirmed+severe = absolute block, suspected+mild = monitor. Also queries the knowledge library for safe alternatives.
Data Sources
Output
Expanded allergy blocks + cross-reactivity flags + safe alternatives
Triggered: After Agent 2
The prescriber. Takes ALL gathered data — patient summary, transcript, similar cases, medical evidence, allergy context — and generates a complete prescription: diagnosis, medicines (with dosage, timing, frequency, duration, SOS conditions, purpose), 5 advice points, a drug safety note explaining why specific drugs were chosen or avoided, and a history insight.
Data Sources
Output
Complete prescription draft
Triggered: After Agent 6
First safety gate. Checks every prescribed drug: (1) Is the drug indicated for the diagnosis? — verified against openFDA labels. (2) Is the dosage within approved range? — verified against openFDA dosing data. (3) Drug interactions — every pair of {prescribed drugs + existing medications} is checked against 175,000+ interaction pairs in the DDInter database. Flagged drugs get red-marked; the LLM suggests replacements in one batch call.
Data Sources
Output
Per-drug verdicts + interaction flags + replacement suggestions
Triggered: After Agent 7
Final safety gate — the most life-critical check. Deterministic, not LLM — pure set-membership lookup. Takes each prescribed drug, resolves its RxCUI via RxNorm, then checks if that RxCUI exists in any of the patient's expanded allergy class sets (from Agent 5). The LLM never decides allergy safety — it only writes the replacement prescription if a violation is found.
Data Sources
Output
Allergy verdicts (PASS / HARD_BLOCK / STRONG_CAUTION) + revised prescription
Triggered: After prescription sent
The loop closer. Scans the completed consultation for two things: (1) New lifelong medications — drugs prescribed as 'ongoing' or 'daily' that aren't in the patient's record yet. (2) New allergies — drug reactions mentioned in the transcript or drug safety note. Findings are posted to a 'System Detected' box on the patient's profile page. The patient accepts or rejects; on accept, the field updates and Agent 1 refreshes the summary.
Data Sources
Output
Pending findings → patient confirmation → profile update
NIH (National Library of Medicine)
Drug name normalization — maps brand names, misspellings, and regional names to canonical identifiers. Free API, no key needed.
Used by: Agent 2 (drug name correction), Agent 5 & 8 (RxCUI lookup)
NIH (National Library of Medicine)
Drug class hierarchy — given a drug, returns its therapeutic class and all sibling drugs. 'Amoxicillin' → 'Penicillins' → [Ampicillin, Piperacillin, ...]
Used by: Agent 5 (allergy expansion), Agent 8 (class-membership check)
U.S. Food and Drug Administration
Drug labels — indications, dosage, contraindications, warnings, interactions. 194 common drugs embedded with 3072-dim vectors for semantic search.
Used by: Agent 4 (knowledge library), Agent 7 (indication/dose verification)
NIH (National Library of Medicine)
Health condition encyclopedia — 1,016 conditions with symptoms, causes, treatments. Embedded with 3072-dim vectors. Long entries split at question headers.
Used by: Agent 4 (knowledge library), Agent 4 (MedlinePlus Connect for ICD-10 → page)
Drug-Drug Interaction Database
175,201 known drug-drug interaction pairs with severity levels (Major, Moderate, Minor). Loaded into MongoDB with compound indexes for sub-millisecond pair lookups.
Used by: Agent 7 (Phase 1 — instant interaction check)
NIH Clinical Tables + Custom Seed
2,132 condition-to-ICD-10-code mappings. Normalized for exact-match lookup with word-sorted keys. NIH API fallback for misses with safety gate.
Used by: Agent 4 (condition code resolution → MedlinePlus Connect)
Seeded + Real Consultations
100 seeded realistic patient cases + every real consultation creates a new case. Each embedded with 3072-dim symptom-only vectors for unbiased retrieval.
Used by: Agent 3 (hybrid vector + keyword search)