Case Study

AI Medical Consultation Pipeline

A grounded, auditable medical AI system that combines three knowledge sources, evidence retrieval with citations, clinical safety rules, and structured output — ensuring every AI summary is traceable and verifiable.

Google Gemini BM25 Retrieval Rank Fusion (RRF) Clinical Rules Engine Firebase / Firestore TypeScript Next.js
Problem Knowledge Retrieval Evidence Output Impact
Before The Problem with AI in Healthcare

Traditional AI summaries in healthcare are inconsistent, unverifiable, miss risk signals, and lack clinical guardrails.

Inconsistent Output
Same input produces different summaries each time. No reproducibility.
🔍
Hard to Verify
No citations, no sources. Clinicians can't trace claims back to evidence.
⚠️
Missing Risk Signals
Red flags like drug interactions or escalation triggers go undetected.
🚫
No Clinical Guardrails
No rules for missing data, required follow-ups, or mandatory escalations.
Result: AI output that clinicians can't trust, can't audit, and can't safely act on.
Foundation Three Knowledge Sources

Every consultation is grounded in three curated, authoritative knowledge layers — not raw internet data.

🔒
System Dictionary
Authoritative, read-only medical concepts organised by specialty. The canonical source of truth.
👨‍⚕️
Doctor Dictionary
Clinician-contributed improvements and refinements. Peer-reviewed additions to the knowledge base.
🧠
Consultation Memory
Company-scoped learnings from prior consultations. Institutional knowledge that improves over time.
↓ all three feed into the retrieval pipeline ↓
Retrieval Evidence Retrieval Pipeline

After the consultation ends, the transcript enters a multi-stage retrieval pipeline that finds the most relevant evidence.

1
Audio Transcription
Consultation audio is transcribed into structured text
2
BM25 Retrieval
Term-frequency search across all three knowledge sources
3
Query Expansion (3 variants)
Generates synonym and context-aware query reformulations
4
Reciprocal Rank Fusion
Merges results from all query variants into a unified ranking
5
Gemini Reranking
AI reranks final candidates by clinical relevance to the transcript
Safety Evidence Pack & Clinical Rules

The pipeline produces a structured evidence pack with citations, red flags, and confidence scores — then clinical rules check for safety.

📋 Evidence Pack
Citation 1System Dict → Musculoskeletal Assessment Protocol SD-042
Citation 2Doctor Dict → Shoulder Impingement Criteria DD-118
Red FlagsNerve compression indicators detected
Confidence
Coverage
⚠️ Clinical Rule: Missing neurological assessment data — required for this presentation
🔴 Escalation Warning: Red flag symptoms may require urgent specialist referral
📋 Follow-Up Required: MRI recommended within 14 days per protocol SD-042
Output Structured, Cited Summary

The final output is a structured summary where every key finding is backed by a citation. Consistent, traceable, auditable.

🛡️Verified AI Summary — All Claims Cited
Summary
Patient presents with right shoulder pain consistent with impingement syndrome. SD-042
Findings
Positive Neer and Hawkins tests. Limited range of motion in abduction. DD-118 Nerve compression indicators noted. SD-042
Recommendations
MRI within 14 days. Specialist referral if neurological symptoms persist. SD-042 DD-118
Risks
Red flag: potential nerve compression requires urgent follow-up. SD-042
Results Architecture & Impact

A grounded medical AI pipeline that clinicians can trust, audit, and act on safely.

3 Knowledge Sources
System, Doctor, and Consultation dictionaries
BM25 + RRF
Multi-query retrieval with rank fusion
Gemini Reranking
AI-powered relevance scoring
Clinical Rules Engine
Deterministic safety checks and escalation alerts
Citation System
Every claim traced to a source document
Audit Logs
Full transcript, evidence, and rule logs visible to admins
100%
Claims backed by citations
3
Knowledge sources per consultation
5-Stage
Retrieval pipeline with reranking
0
Unverified claims in output

Grounded Medical AI You Can Audit

Every summary is evidence-based, every claim is cited, every risk is flagged — no hallucination, no guessing.