Clinical questions on a hospital floor do not wait. Resident and intern doctors at Aga Khan University Hospital needed a way to check treatment guidance quickly — and the answers had to come from the guidelines Kenyan clinicians are actually accountable to, not from whatever an internet-trained model happens to believe.
A note on dates
This page describes the system as I built and ran it at Aga Khan University, up to September 2026. The team has since replaced the two-stage design described below with a single-pass pipeline, so the architecture here is a record of that period and not of what runs today.
The problem
General-purpose LLMs are fluent but unaccountable: they will answer a clinical question whether or not the answer reflects Kenyan Ministry of Health protocols, and in a hospital that gap is a safety issue, not a UX issue. At the same time, junior doctors are the heaviest users of reference material and have the least time to search for it. The goal was a system that answered only from vetted guideline content, refused gracefully outside its scope, and was fast and reliable enough to be part of the daily clinical workflow.
Constraints
- Clinical safety and grounding. Every answer had to be traceable to Kenyan Ministry of Health guidelines — retrieval-augmented generation, not open-ended generation.
- Healthcare-grade access control. Retrieval had to respect role-based access controls, with comprehensive audit logging of who asked what and what the system returned.
- Production reliability. A tool doctors consult during care has to hold the same bar as other critical hospital systems — we operated our platforms at 99.9%+ uptime.
- Resource-constrained context. The system served an East African hospital network: cost per query, latency on real hospital networks, and operational simplicity all mattered.
Architecture
The core design decision was a two-stage pipeline: a fast, cheap classifier in front of a domain-specialized generator. An incoming question first went to Gemini 2.5 Flash, which classified intent and scope — is this a clinical guideline question the system should answer, and which guideline domain does it belong to? Only then did retrieval run against a ChromaDB vector store of embedded Ministry of Health guideline content, filtered by the user's role, and the retrieved context was handed to MedGemma for grounded generation.
The two-stage design as it ran until September 2026: classify first, retrieve with access controls, generate grounded answers — audit everything. Explore the interactive diagram →
Why two stages, at the time?
Sending every query straight to a medical LLM is both wasteful and unsafe. The Flash classifier was an order of magnitude cheaper and faster than the generator, so out-of-scope questions were rejected before any expensive retrieval or generation happened — and scoping the retrieval by classified domain measurably improved the relevance of what MedGemma was grounded on.
From prototype to production
I started the early architecture and prototyping in 2023, and productionizing it became a headline deliverable of the data infrastructure, AIOps and cloud engineering function I managed. Getting from demo to daily clinical use meant the unglamorous work: RBAC-based retrieval controls, comprehensive audit logging, query and caching optimization that brought p95 response times under 300ms on the retrieval path, infrastructure as code with Terraform, and Kubernetes-based serving with the same monitoring, SLAs and incident-response discipline as the rest of the hospital platform.
A safety decision
Reviewing the code, I found a duplicated function that had silently turned a dosing safety block into a warning. I designed a fail-closed kill switch and escalated the decision to clinical governance, so the risk decision stayed with the people who own it. The evaluation pipeline ran in CI/CD with tests for leakage, fabrication and drift that blocked a release; it caught a silent failure mode that had survived four releases.
Impact, as of September 2026
The work was recognized externally with the Google GenAI Accelerator Award. More importantly, it established a reusable pattern at AKU for putting LLMs into clinical settings responsibly: ground on vetted local content, control retrieval by role, audit everything, and hold AI systems to platform-grade SLAs.