Medical Triage Platform
Django platform for medical admission, AI-assisted triage, WhatsApp, virtual appointments, and teleconsultation with auditing and privacy.
Project Description
Medical Triage Platform is a digital health platform built with Django to manage the entire workflow of patient admission, preliminary triage, operational queues, medical scheduling, teleconsultation, and clinical records. The system models distinct roles for patients, doctors, operators, medical administrators, and superusers, featuring object-level permissions and specific validations for clinical data, medical credentials, documents, medical history, and access to video consultations.
The architecture is organized into independent Django apps: accounts, patients, doctors, scheduling, triage, whatsapp, consultations, medical_records, documents, notifications, audit, and integrations. The domain encompasses consultation requests, triage evaluations, clinical alerts, prioritized queues, virtual appointments, medical encounters, clinical notes, medical documents, medical history events, WhatsApp conversational sessions, and audit logs.
AI serves two primary roles. Functionally, the project integrates a controlled OpenAI client for preliminary triage classification with structured JSON output, prompt versioning, traceability via AIDecisionLog, PII minimization, and a secure fallback to human review. Before calling the AI provider, deterministic rules for emergencies and urgent cases are executed, avoiding external model dependencies for critical scenarios. On the engineering side, the platform was built with iterative AI assistance for architectural design, incremental implementation, hardening, testing, runbooks, operational documentation, and risk analysis.
The WhatsApp channel is equipped with a production-ready webhook for the WhatsApp Cloud API, featuring HMAC SHA-256 validation, Meta's GET challenge handling, inbound idempotency, conversational sessions, an internal simulator, outbound logs, status callbacks, a no-automatic-retry policy, metadata sanitization, and controlled purging of test evidence. The live provider can be activated in a controlled manner, keeping mocks as the secure default.
Teleconsultation integrates mock video rooms along with a live adapter for Daily, supporting room creation, distinct tokens for patients and doctors, protected internal URLs, access validation, join/leave events, rate limiting, and operational fallback in case of provider errors. Sensitive tokens and URLs are never exposed in templates or logs.
The production deployment is documented and validated on Donweb running Ubuntu, PostgreSQL, Gunicorn, Nginx, systemd, and HTTPS with a Let's Encrypt certificate. The production environment configuration utilizes environment variables, disabled DEBUG, secure cookies, security headers, intentional blocking of public media, sanitized logging, and external providers set to mock mode by default. The current status corresponds to internal validation / MVP beta: technical workflows have been tested with dummy data and simulated pilots, but it is not authorized to operate with real patients without final legal and medical validation.
Problem Solved
The project addresses the need to organize and audit the digital admission of remote medical inquiries—especially those originating from WhatsApp—reducing operational friction between patient registration, preliminary clinical prioritization, physician assignment, and teleconsultation. Instead of relying on manual messages, spreadsheets, or untraceable decisions, it centralizes the workflow into a single platform featuring roles, permissions, security rules, AI-assisted triage, a prioritized queue, protected video calls, clinical records, and auditable evidence. It also tackles technical and privacy risks inherent to digital health through data minimization, log sanitization, secure mocks, external provider validation, and controlled deployment.
Key Features
- Distinct roles for patients, doctors, operators, medical administrators, and superusers.
- Patient clinical profile and registration with data privacy and telemedicine consents.
- Document verification for doctors and authorization for virtual healthcare practices.
- Consultation requests via web, internal simulator, or WhatsApp.
- Preliminary triage utilizing deterministic rules for emergencies and urgent cases.
- Controlled OpenAI integration for structured triage classification.
- Secure AI fallback to high-urgency status with mandatory human review.
- Auditable records of AI decisions via AIDecisionLog.
- Operational clinical alerts for critical cases.
- Prioritized waiting queue based on urgency level, specialty, score, and admission timestamp.
- Medical scheduling with virtual appointments and overlap prevention.
- Initiation, tracking, and formal closure of medical consultations.
- Clinical notes including diagnosis, treatment, referrals, and follow-ups.
- Event-based simplified medical history tracking.
- Medical document upload and retrieval system.
- Mock/local teleconsultation rooms and live adapter for Daily.
- Protected internal URLs for patients and doctors within video rooms.
- Video consultation events equipped with rate limiting.
- Production-ready WhatsApp webhook with GET challenge handling and HMAC SHA-256 validation.
- Internal WhatsApp simulator for QA without relying on Meta endpoints.
- Persistence of inbound messages, contacts, and conversational sessions.
- Inbound and outbound idempotency to prevent duplicate actions.
- Outbound WhatsApp logs with privacy enforcement and masked phone numbers.
- WhatsApp status callbacks for sent, delivered, read, and failed events.
- Explicit no-automatic-retry policy on outbound WhatsApp communications.
- Append-only audit trail for sensitive actions.
- Recursive metadata sanitization to prevent PII and secret exposure.
- Management command for controlled purging of test evidence.
- Environment-based configuration (dev/prod) utilizing django-environ.
- Production deployment documented on Donweb with PostgreSQL, Gunicorn, Nginx, systemd, and HTTPS.
- Automated test suite covering domain logic, integrations, privacy, callbacks, and end-to-end mock QA.
- Operational runbooks for OpenAI, Daily, WhatsApp, backup/restore, security, and internal pilots.
Technical Details
Links
Are you interested in this solution?
I can design and develop a similar system adapted 100% to your company's operations and size.
Request Pricing