Kenya has approximately 100,000 Community Health Workers (CHWs — locally called Community Health Extension Workers, or CHEWs). They cover a population of 54 million. That's roughly one CHW per 540 people, but in rural areas the ratio reaches 3,000:1.
These workers are the first and often only medical contact for millions of Kenyans. They do triage. They decide who needs a hospital referral. They counsel on pregnancy, malnutrition, fever, diarrhoea. They work from memory and a printed protocol card.
afyanipoa (afya nzuri = good health in Swahili, "poa" = cool) is an AI clinical co-pilot for these workers.
The Research Basis
arXiv:2408.17216 — "Democratizing AI in Africa: Federated Learning for Low-Resource Edge Devices" (2024)
This paper demonstrated that federated learning can be deployed on Raspberry Pi-class devices (the computing tier of affordable Android phones) in 5 African countries simultaneously, achieving acceptable model accuracy without centralized data collection. The implication: clinical AI doesn't require cloud connectivity.
WHO Community Health Workers Reference Group (2022): The WHO documents that CHW programs are most effective when workers have access to real-time decision support — but most programs only provide printed job aids updated annually.
Kenya MOH CHEW Curriculum: The Kenya Ministry of Health publishes the official training curriculum for CHEWs. The integrated management protocols for fever, cough, diarrhoea, ANC, and malnutrition are well-defined and systematizable.
What afyanipoa Does
The app has three layers:
1. Protocol library (always available, no AI needed)
Embedded Kenya MOH protocols for 8 conditions: fever, cough, diarrhoea, malnutrition, ANC, family planning, mental health, TB screening. Danger signs, referral triggers, dosing by age/weight. Zero API calls required.
2. AI clinical guidance (when API key is configured)
A CHW describes a patient's complaint in Swahili. The AI synthesizes the relevant protocol sections with the specific presentation and returns:
- ISHARA ZA HATARI / DANGER SIGNS (check first)
- TATHMINI / ASSESSMENT (what to examine)
- MATIBABU / IMMEDIATE ACTION
- PELEKA / REFERRAL (when, where, why)
- FUATILIA / FOLLOW-UP
3. Emergency contacts (always visible)
0800 720 571 (Kenya health emergency line), county referral hospital numbers, maternal emergency contacts.
The Safety Architecture
This is safety-critical software. The design decisions reflect that:
DEMO label: visible on every screen
AI output: labeled "decision support, not diagnosis"
Danger signs: displayed FIRST, before any AI output
Referral bias: when in doubt, the prompt leans toward referral
Emergency contacts: persistent, not hidden in menus
The Gemini prompt explicitly instructs the model:
"When in doubt between management at home and referral, recommend referral. A missed referral in the field has worse consequences than an unnecessary one. This is decision SUPPORT — the CHW makes the final call."
The Endpoint Fix
One lesson from this deployment: always use the stable /v1/ endpoint, not /v1beta/.
# Wrong — returns 404 for gemini-2.0-flash
url = f"generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent"
# Right — try v1 first, fall back to v1beta
for ver in ("v1", "v1beta"):
url = f"generativelanguage.googleapis.com/{ver}/models/gemini-2.0-flash:generateContent"
try:
# ... call ...
return result
except HTTPError as e:
if ver == "v1beta": raise
continue
This pattern has since been applied to all Gemini-enabled apps in this portfolio.
Deploy It Today
# Streamlit Cloud — free tier
# Repo: github.com/gabrielmahia/afyanipoa
# Secret: GOOGLE_API_KEY = "your-gemini-key"
Get a free Gemini API key at console.cloud.google.com → Gemini API → Enable → Create key.
github.com/gabrielmahia/afyanipoa · CC BY-NC-ND 4.0
Top comments (0)