MediTriage — AI-Powered Pre-Consultation Triage System
Team
- E/22/044, D.M.N.N. Bandara, e22044@eng.pdn.ac.lk
- E/22/102, A.K. Gamage, e22102@eng.pdn.ac.lk
- E/22/010, A.A.D.I. Adikari, e22010@eng.pdn.ac.lk
- E/22/211, H.M. Liyanage, e22211@eng.pdn.ac.lk
Table of Contents
Introduction
Outpatient Departments (OPD) and Wards face significant bottlenecks because doctors spend the initial 5–10 minutes of every consultation gathering basic patient history. This reduces the time available for actual diagnosis and treatment, increases patient waiting times, and places unnecessary cognitive load on clinical staff.
MediTriage is an AI-powered, staff-assisted pre-consultation tool designed to streamline the clinical intake process in hospital settings. It empowers hospital staff (e.g., nurses) to conduct structured patient interviews efficiently using an AI-guided conversational interface. The system allows the nurse to capture and verify patient responses before the conversation is automatically converted into a draft SOAP Note (Subjective, Objective, Assessment, Plan) — a structured medical summary ready for the attending doctor.
Key Capabilities
- 🤖 Conversational AI Triage — A LangChain-powered interview engine guides the nurse through a clinically structured question flow, adapting dynamically to patient responses.
- 🔒 Privacy-First Architecture — Patient Identifiable Information (PII) is scrubbed locally using a lightweight Llama 3.2 model (via Ollama) before any data is sent to a cloud AI provider, ensuring patient data never leaves the facility unprotected.
- 📝 Automated SOAP Note Generation — Cloud AI synthesises the scrubbed conversation into a structured clinical note for doctor review.
- 👥 Role-Based Access Control — Dedicated portals and permissions for Nurses, Doctors, and Administrators.
Solution Architecture
The system follows a layered architecture separating human interaction, frontend presentation, backend processing, and data/AI services.

Figure 1 — MediTriage System Architecture
Layer Overview
| Layer | Components | Description |
|---|---|---|
| Human Layer | Patient, Doctor, Nurse | End-users who interact with the system. The nurse conducts the AI-guided interview; the doctor reviews the generated SOAP note. |
| Frontend (React) | Doctor Portal, Nurse App | Role-specific React (Vite) single-page applications. The Nurse App drives the triage interview; the Doctor Portal provides review and annotation capabilities. |
| Backend (FastAPI) | API Gateway, LangChain Core | A Python FastAPI service exposes a RESTful API. The LangChain Core orchestrates the multi-step triage pipeline — routing queries to AI services and coordinating PII sanitisation. |
| External Services | Cloud AI | Cloud AI applications are used for high-quality clinical reasoning and SOAP note generation. |
| Local Scrubber | Llama 3.2 (Ollama) | A locally-hosted LLM that strips PII from the patient conversation before any data reaches cloud services. |
| Data Layer | PostgreSQL | Persistent storage for patients, users, triage sessions, encounters, and clinical notes managed via SQLAlchemy and Alembic migrations. |
Data Flow
- The Nurse admits a patient and begins an AI-guided interview in the Nurse App.
- Text or voice input is sent to the FastAPI Backend via the API Gateway.
- The LangChain Core passes the conversation to the Local Scrubber (Llama 3.2) to sanitise PII.
- The sanitised content is forwarded to Cloud AI for clinical reasoning.
- The AI response is returned to the nurse for verification and stored in PostgreSQL.
- On completion, a draft SOAP Note is generated and surfaced in the Doctor Portal for review and annotation.
Software Designs
Technology Stack
Backend (meditriage-be)
| Category | Technology |
|---|---|
| Framework | FastAPI 0.104+ |
| Language | Python 3.10+ |
| Database | PostgreSQL 14+ with SQLAlchemy ORM |
| Migrations | Alembic |
| AI / LLM Orchestration | LangChain |
| Local LLM (PII Scrubbing) | Ollama + Llama 3.2 1B |
| Cloud LLM (Reasoning) | OpenAI API or DeepSeek API |
| Authentication | JWT (python-jose) + bcrypt |
| Validation | Pydantic v2 |
| Server | Uvicorn (ASGI) |
Frontend (meditriage-fe)
| Category | Technology |
|---|---|
| Framework | React 19 |
| Build Tool | Vite 7 |
| Language | TypeScript / JavaScript (ES6+) |
| State Management | Zustand |
| HTTP Client | Axios |
| Linting | ESLint 9 |
Backend Project Structure
meditriage-be/
├── app/
│ ├── api/v1/
│ │ ├── controllers/ # Route handlers (auth, patients, triage, users)
│ │ └── dependencies.py # RBAC & JWT injection
│ ├── core/ # Config, security, logging
│ ├── db/ # SQLAlchemy session
│ ├── models/ # ORM models (Patient, User, Encounter, …)
│ ├── repositories/ # Data access layer
│ ├── schemas/ # Pydantic request/response schemas
│ ├── services/
│ │ ├── llm/ # LangChain chains, prompts, parser
│ │ ├── triage_engine.py # Core triage orchestration
│ │ └── … # Auth, patient, encounter services
│ └── main.py
├── alembic/ # Database migrations
├── tests/ # Pytest test suite
└── requirements.txt
API Endpoints Summary
| Category | Endpoint | Method | Role |
|---|---|---|---|
| Auth | /api/v1/auth/register |
POST | Public |
/api/v1/auth/login |
POST | Public | |
/api/v1/auth/me |
GET / PATCH | All | |
| Patients | /api/v1/patients |
POST | Nurse, Admin |
/api/v1/patients/search |
GET | Nurse, Doctor | |
/api/v1/patients/{id} |
GET / PUT / DELETE | Nurse, Doctor, Admin | |
/api/v1/patients/{id}/history |
GET | Nurse, Doctor | |
| Triage | /api/v1/triage/start |
POST | Nurse |
/api/v1/triage/chat |
POST | Nurse | |
/api/v1/triage/{id}/messages |
GET | Nurse, Doctor | |
/api/v1/triage/{id}/note |
GET / PUT | Nurse, Doctor | |
| Users | /api/v1/users |
GET / DELETE | Admin |
Testing
The project uses Pytest for backend testing, with the test suite located in meditriage-be/tests/.
Test Layers
| Layer | Scope | Tools |
|---|---|---|
| Unit Tests | Individual service functions, LLM prompt logic, RBAC rules | pytest, unittest.mock |
| Integration Tests | API endpoint request/response cycles against a test database | pytest, TestClient (FastAPI) |
| Manual / Postman | End-to-end workflow validation (register → admit → triage → SOAP note) | Postman collection (postman/) |
Conclusion
MediTriage demonstrates how AI-assisted clinical workflows can meaningfully reduce the administrative burden on healthcare professionals. By automating the initial patient history-gathering process through a conversational AI interface — while keeping patient privacy at the forefront through local PII scrubbing — the system frees doctors to focus on diagnosis and treatment rather than data collection.
Key outcomes of the project:
- A fully functional triage pipeline from patient admission to SOAP note delivery, validated end-to-end.
- A privacy-preserving AI architecture where sensitive data is sanitised before any cloud interaction.
- A role-aware web application that adapts its interface and permissions to the specific needs of Nurses, Doctors, and Administrators.
- A modular, maintainable codebase built on industry-standard frameworks (FastAPI, React, LangChain, PostgreSQL) that can be extended to support additional clinical workflows.
Future work could include integration with hospital information systems (HIS/EMR), support for multilingual patient interaction, and deployment within a containerised (Docker/Kubernetes) hospital infrastructure.