Five-Layer Clinical Architecture

Purpose-built for South Africa's regulatory environment, disease burden, and infrastructure realities — from POPIA data residency to USSD-based intake on any mobile phone.

Every Layer Designed for SA

Aafiya is not a generic telemedicine platform adapted for South Africa. It is designed from the ground up around SA's regulatory constraints, disease patterns, languages, and infrastructure.

1

Compliant Data Core

FHIR R4 · POPIA · SA-resident cloud · consent ledger

2

SA Clinical AI Engine

7B–13B LLM · pre-consultation triage · HIV/TB corpus · deterministic rules · EML · TB CXR AI

3

Physician Workflow

Queue dashboard · HPCSA verify · immutable audit trail

4

SA Infrastructure

PWA + USSD · 11 languages · offline · wearables · multimodal intake · 2G audio mode

5

Revenue & Integration APIs

Healthbridge · pharmacy e-Rx · WhatsApp API · PathCare / Ampath labs · NHI-readiness API

🔒

Layer 1 — Compliant Data Core

SA-resident cloud infrastructure. FHIR R4 patient records. Granular consent ledger. SA ID as canonical patient identifier. Full POPIA compliance.

🤖

Layer 2 — SA Clinical AI Engine

Fine-tuned 7B–13B parameter LLM on SA corpus. Two-stage pre-consultation triage (<500ms). Deterministic rules engine for EML, ICD-10, and STG compliance. TB CXR AI screening. Continuous learning pipeline.

👔

Layer 3 — Physician Workflow

Queue-based review dashboard. Immutable audit trail. HPCSA real-time verification. Structured case summaries. Approve / modify / escalate / reject workflow.

🌐

Layer 4 — SA Infrastructure

Progressive Web App + USSD gateway. Wearable integration (HealthKit, Health Connect). Image upload for multimodal intake. Offline capability. Audio mode. 11 languages. Works on 2G.

📉

Layer 5 — Revenue & Integration APIs

Healthbridge medical aid claims. Pharmacy e-prescription network. WhatsApp Business API. PathCare + Ampath lab integration (HL7 FHIR). NHI-readiness API. FHIR-native data submission.

Tech Stack Summary

Spring Boot 4 React 19+ Python / PyTorch PostgreSQL 16 Redis RabbitMQ HAPI FHIR Kubernetes Terraform WhatsApp Business API HL7 FHIR Lab Apple HealthKit Android Health Connect TB CXR AI WebRTC Ozow / PayFast Dexcom / FreeStyle Libre CGM GoodX / Elixir EHR DHA NPR

Compliant Data Core

All patient data lives on SA-resident infrastructure — a POPIA requirement for health information. No cross-border transfers, no exceptions.

  • Cloud: AWS Cape Town (af-south-1) or Azure SA North
  • HL7 FHIR R4 as the standard data format
  • SA ID number as canonical patient identifier (aligns with HPRS)
  • Granular, purpose-specific consent architecture (4 categories)
  • Immutable audit log for every clinical action
  • PostgreSQL 16+ with FHIR R4 via JSONB
  • Redis for session management and USSD state

Consent Architecture: Four independent categories — clinical care, physician review, record aggregation, and anonymised AI training. Patients can grant or revoke each independently, meeting POPIA's purpose-specific consent requirement.

FHIR R4 — Why It Matters

HL7 FHIR R4 is the data standard mandated by the NHI digital health system. By implementing FHIR from day one, Aafiya's patient records are natively interoperable with future NHI Fund systems — without costly data migration.

Backend Modules

  • 1
    platform-api — API gateway, patient-facing REST
  • 2
    clinical-ai — AI orchestration, triage engine, rules engine
  • 3
    physician-service — Queue workflow, HPCSA verify, video consult
  • 4
    cdm-service — Chronic care plans, recalls, wearable sync
  • 5
    integration-service — Healthbridge, pharmacy, WhatsApp, labs, self-pay, EHR, DHA NPR, NHI
  • 6
    common — FHIR models, consent ledger, audit

SA Clinical AI Engine

Pre-consultation Triage Pipeline

Two-stage safety screen before clinical intake begins. Total latency under 500ms.

  • Stage 1: 13 regex pattern groups — EMERGENCY detection in <50ms. Deterministic, no LLM involved.
  • Stage 2: LLM classifier with structured JSON output — category, confidence, reasoning, red flags. 450ms hard timeout; fallback to ROUTINE.
  • Every triage record stored: model version, latency, outcome, timestamp — SAHPRA evidence file auto-generated.
  • Patient skip always available; override audited.
🧠

Foundation LLM

Fine-tuned 7B–13B parameter medical language model. Base models under evaluation: Med-PaLM 2, BioMedLM, Llama/Mistral medical variants. Trained exclusively on SA clinical corpus.

SA Training Corpus: SA STGs, EML, NIMART HIV protocols, SA TB/MDR-TB guidelines, TIER.Net, and HSRC survey data.

Deterministic Rules Engine

Validates every AI output before physician review:

  • EML drug cross-checking (100% compliance required)
  • ICD-10 mapping for all diagnoses
  • STG protocol alignment verification
  • Drug interaction and contraindication checks
  • Red-flag escalation triggers (13 symptom groups)
  • Explainable reasoning chains (SAHPRA requirement)
📈

Continuous Learning Pipeline

Aafiya's most durable competitive moat. Every physician override is premium training data.

  • Physician override rate as primary drift signal
  • Auto-triggers retraining if override rate >15% per category
  • Monthly bias audits: province, language, age, HIV status
  • MLflow for experiment tracking and versioning
  • vLLM/TGI for efficient LLM serving
🔍

TB CXR AI & GeneXpert Integration

TB-specific triage pathway targeting SA's world-high TB burden.

  • Chest X-ray AI screening model for TB detection
  • GeneXpert molecular test result integration
  • MDR-TB flag triggers specialist escalation
  • NIMART and SA TB/MDR-TB guideline alignment
  • Results delivered to patient record via FHIR R4

Why non-SA AI models fail: Global medical AI is trained on US and European populations. It systematically underperforms on SA's HIV/TB syndemic, unique pharmacogenomic profiles, and locally prevalent co-morbidities. SA-specific training is a clinical necessity, not just a differentiator.

Physician Workflow

  • RabbitMQ case queue — Spring AMQP
  • Structured summary with AI confidence score
  • One-click approve / modify / escalate / reject
  • Immutable audit entry for every action
  • Real-time HPCSA registration monitoring
  • Auto-offboard on disciplinary notice
  • Physician quality scoring and CPD tracking

SA Infrastructure

  • React 19+ PWA — offline-first via Workbox
  • Africa's Talking USSD gateway
  • Audio mode — full intake on 2G
  • Image upload — multimodal intake (skin, wounds, eye)
  • 11 SA official languages (clinical-grade, speech-to-text)
  • Apple HealthKit (iOS) — BP, glucose, HR, steps, sleep
  • Android Health Connect — Samsung, Garmin, Fitbit, Xiaomi
  • Dexcom / FreeStyle Libre CGM — continuous glucose monitoring for diabetes CDM
  • Bluetooth home monitoring — BP cuff, SpO2, smart scale (post-discharge & CDM)
  • Kubernetes (EKS/AKS) auto-scaling
  • Terraform + GitHub Actions CI/CD
  • Zero-rating: MTN, Vodacom (active), Cell C, Telkom (in progress)

Revenue & Integration APIs

🏦

Healthbridge Integration

Direct integration with SA's dominant medical scheme claims network. Automated R380/consultation billing, claim adjudication tracking, and reconciliation.

💊

Pharmacy E-Prescription

Signed e-prescriptions route to Dis-Chem, Clicks, and independent pharmacies via MediFin/ScriptWise. Patients collect medication with a digital code — no paper script needed.

💬

WhatsApp Business API

Consultation results, signed notes, and e-prescriptions delivered via WhatsApp in 4 languages. SMS fallback via Africa's Talking for low-bandwidth and feature phones. Appointment reminders at 24h and 1h.

📋

Lab Integration — PathCare & Ampath

HL7 FHIR result delivery from PathCare and Ampath directly into patient records. Lab results appear in the physician case view alongside AI assessment — no manual re-entry or fax.

🌅

Self-Pay — Ozow / PayFast / SnapScan

Tiered self-pay payments for patients outside medical aid coverage. Eliminates the 84% of South Africans previously excluded by the medical aid billing model. Expands the addressable market from 9M to 60M+ patients.

Medical Aid Real-Time Eligibility

Pre-consultation eligibility check against the patient's medical aid scheme before intake begins. Prevents claim denials at submission and automatically falls back to self-pay when scheme coverage is inactive or unavailable.

📄

EHR Integration — GoodX / Elixir

Bidirectional integration with SA's dominant GP practice management systems (GoodX and Elixir). Receives overflow referrals from private practices, returns structured FHIR clinical notes and e-prescription confirmations. Extends Aafiya's reach through existing GP networks.

🏭

DHA National Population Register

SA ID verification against the Department of Home Affairs National Population Register. Eliminates fraudulent billing by confirming patient identity at registration. Enables SASSA grant verification pathway and aligns with HPRS patient identification requirements.

🏢

NHI Readiness API

FHIR-native data submission aligned with anticipated NHI Fund requirements. Quality metrics, ICD-10 distribution, and STG adherence instrumented from launch — ready for NHI accreditation.

Enterprise-Grade Security for Clinical Data

Data residency on SA soil, ISO 13485 QMS, immutable audit trails — every design choice protects patient information and meets regulatory requirements.

Secure server infrastructure and data center
AWS Cape Town / Azure SA North — all patient data stays in South Africa.
🔒

Data Residency

All patient data on AWS Cape Town or Azure SA North. No cross-border transfers. Meets POPIA's special personal information requirements.

🔓

Authentication & Access

Spring Security with JWT. Role-based access control separating patient, physician, admin, and system roles. MFA enforced for physicians and admins.

📋

Audit & Compliance

Immutable audit log for every clinical action, data access, and configuration change. Complete timestamped trails required by SAHPRA for AI clinical decision support.

Explore the Market Opportunity

Understand the total addressable market, competitive landscape, and Aafiya's path from medical aid billing to NHI capitation.

View Market Analysis Regulatory Framework