Amos Bunde

Home / Projects / Case study

Afya Gemma: clinical decision support in production, 2023 to 2026

Taking a MedGemma-based assistant from prototype to daily use by resident and intern doctors at Aga Khan University Hospital — grounded in Kenyan Ministry of Health guidelines, and recognized with the Google GenAI Accelerator Award.

Google GenAI Accelerator Award Aga Khan University Hospital 2023 — 2026 Role: architecture & delivery lead

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

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.

Clinician residents & interns Stage 1 · Gemini 2.5 Flash intent + scope classifier rejects out-of-scope queries Retrieval · ChromaDB MoH guideline embeddings RBAC-filtered Stage 2 · MedGemma grounded generation answer + guideline context MoH guidelines curated + embedded corpus Audit log every query & response response returned to clinician GKE · VERTEX AI · TERRAFORM · MONITORING

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

Dailyuse
Used by resident and intern doctors at AKU Hospital
<300ms p95
Retrieval-path response times after query and caching optimization
99.9%+
Uptime, held to the same SLA as other critical hospital systems

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.

Related open-source work: Afya-Sahihi on GitHub →