- Design Document → architecture.md
- Cost Analysis → cost_calculation_and_routing.md
- GPT-4o Limitations → gpt_restrictions.md
eFiche AI is a production-grade clinical transcription system designed for real-world healthcare environments. It enables nurses to capture consultations, transcribe multilingual speech (Kinyarwanda, French, English), and extract structured clinical data safely and efficiently.
The system is built to prioritize clinical safety, reliability, and cost-efficiency, ensuring it can scale across hundreds of facilities without compromising patient care.
The system is fully containerized using Docker Compose.
- Framework: FastAPI (Python 3.11)
- Task Queue: Celery (asynchronous processing)
- Database: PostgreSQL (SQLAlchemy ORM)
- Cache/Broker: Redis
- AI Models:
- Whisper (ASR)
- GPT-4o (clinical extraction)
- GPT-4o-mini (lightweight validation)
- Framework: Next.js (App Router)
- Language: TypeScript
- UI: Responsive dashboard with real-time feedback
- Features:
- Audio recording & upload
- Live (non-clinical) transcription preview
- Review and correction interface
- pgAdmin (database management)
- RedisInsight (queue monitoring)
The system implements a production-grade CI/CD Pipeline via GitHub Actions to ensure stability, safety, and performance.
- Backend Pipeline:
- Automated unit and integration testing via Pytest.
- Verification of the Clinical Quality Gate logic and database models.
- Asynchronous task processing validation.
- Frontend Pipeline:
- Strict ESLint enforcement for React best practices.
- TypeScript type-safety verification across all data structures.
- Next.js Production Build validation on every push to prevent runtime regressions.
- Environmental Consistency: Docker-based build verification ensures that the system runs identically across local development and the CI runner.
This system is designed as a clinical tool, not a demo.
Core principles:
- Clinical safety over convenience
- Human-in-the-loop validation
- Explicit uncertainty handling
- Cost-aware scaling
- Multi-model redundancy
Avoided patterns:
- Blind reliance on a single LLM
- Treating valid JSON as correct output
- Using WER/CER as sole quality metrics
The system is organized into four layers:
-
Ingestion Layer
- Accepts audio uploads via API
- Enqueues processing jobs
-
Processing Layer (Async)
- Multi-provider ASR (local + cloud)
- Transcript fusion
- PII redaction
- Clinical data extraction
-
Decision Layer (Quality Gate)
- Validates completeness and correctness
- Detects clinical risks
- Assigns processing status
-
Serving Layer
- API responses
- Dashboard for review and correction
- Audio is uploaded via FastAPI (
POST /consultations/{id}/process) - Celery processes the job asynchronously
- Audio is transcribed using local ASR and/or Whisper
- Transcripts are merged using a fusion strategy
- PII is removed using local NER (e.g., Presidio)
- De-identified text is sent to GPT-4o for structured extraction
- Results pass through a Quality Gate
- Output is stored and displayed in the dashboard
- Real-time transcription (Web Speech API) is used only for UI feedback.
- Clinical-grade transcription is performed asynchronously via backend ASR for reliability and accuracy.
All outputs are validated before reaching clinicians.
The Quality Gate checks:
- Completeness of required fields
- Consistency between transcript and extracted data
- Clinical safety (e.g., invalid dosages, unknown medications)
complete— safe and usablepartial— incomplete but usable with cautionneeds_review— requires human validationdangerous— unsafe, must be corrected
To ensure scalability, the system dynamically routes consultations:
-
Local models (low cost) are used when:
- Short, simple consultations
- High transcription confidence
- Single-language input
-
GPT-4o (higher accuracy) is used when:
- Complex or long consultations
- Mixed-language input
- Low transcription confidence
This keeps the average cost low while maintaining clinical reliability.
- Docker Desktop installed
cp .env.example .envAdd your OpenAI API key if available.
docker compose up -d --build| Service | URL |
|---|---|
| Frontend | http://localhost:3000 |
| Backend API | http://localhost:8000 |
| API Docs | http://localhost:8000/docs |
| pgAdmin | http://localhost:5050 |
| RedisInsight | http://localhost:5540 |
Run databases only:
docker compose up -d db rediscd backend
uvicorn app.main:app --reloadcd frontend
npm install
npm run dev- System automatically uses mock ASR and extraction
- Enables full UI and pipeline testing
Example input:
"The patient has a fever. Prescribe 500 kilograms of paracetamol."
Expected Result:
- Status:
needs_review - Flag: dangerous dosage detected
- UI highlights issue and requires correction
To run the same checks performed by the GitHub Actions pipeline locally:
cd backend
PYTHONPATH=. python -m pytest tests/ -vcd frontend
npm run lint
npm run buildPipeline:
- FastAPI → Celery → ASR → Fusion → PII Redaction → LLM → Quality Gate → DB → Dashboard
- Large audio files require chunking (not fully implemented)
- Code-switching (Kinyarwanda/French) impacts local ASR accuracy
- Polling used instead of WebSockets (planned for V2)
- Audio stored temporarily in container (not persistent)
backend/
app/
api/
core/
db/
services/
tasks/
models/
frontend/
src/
app/
components/
docker-compose.yml
.env.example
README.md
eFiche AI is designed as a safe, scalable, and cost-aware clinical AI system. It combines multi-ASR transcription, structured extraction, and strict validation to ensure that AI outputs support clinicians without introducing risk.
The system emphasizes:
- Safety through validation and human review
- Efficiency through asynchronous processing
- Scalability through cost-aware routing