Skip to content

AutoFlow

The Operating System for Hospital OPDs

RoleFull-Stack Engineering, Applied AI Systems & Product Design
Built byShaurya Punj
LocationIndia
Year2026
AutoFlow hero

Overview

AutoFlow is an operating system for hospital outpatient departments. It orchestrates the entire patient journey, from registration and triage through consultation, investigations, pharmacy, billing, and discharge, in real time across nine role-specific consoles driven by a single source-of-truth state machine. A Gemini-powered AI layer triages, transcribes, summarizes, and flags at every step, while a strict human-confirmation rule keeps a clinician in control of every medical decision.

The Problem

India's outpatient departments are the front door to healthcare and its worst bottleneck. Tertiary government hospitals routinely process 3,000 to 10,000 outpatients a day, where patients wait 2 to 4+ hours for a 3 to 5 minute consultation. Throughput, not clinical skill, is the binding constraint. Administrators run blind with no real-time operational visibility, documentation is manual, billing leaks revenue, and Ayushman Bharat, the world's largest government health-insurance scheme covering 500M+ people, adds claims complexity that paper-based OPDs cannot handle.

The Solution

AutoFlow models the OPD as a real-time, event-sourced state machine: every patient is a live token moving through ten well-defined states, and every role sees exactly their slice on a purpose-built console. A fairness-aware scheduler decides who is next, weighing wait time, urgency, starvation protection, and emergency override. WebSockets keep every screen and the lobby board in sync, and an AI augmentation layer removes documentation and triage load, always as a suggestion a human confirms, never an auto-commit.

Agent Architecture

01

Triage Agent

InputChief complaint + demographics
EngineGemini 2.5 Flash to JSON
OutputUrgency score (1-5) + red-flags, feeding queue priority
Speed: ~2-5s
02

Intake Conversationalist

InputPatient free-text turns (multilingual)
EngineGemini 2.5 Flash, turn-capped
OutputStructured symptom summary + red-flag escalation
Speed: ~2-4s / turn
03

Clinical Brief Agent

InputFull visit trail (vitals, history, complaint)
EngineGemini 2.5 Pro to JSON
OutputDifferential + suggested investigations (doctor accepts or overrides)
Speed: ~5-15s
04

Scribe & Dual-Summary

InputConsultation trail
EngineGemini 2.5 Pro
OutputClinician summary + a plain-language patient summary
Speed: ~10-20s
05

Lab Vision OCR

InputLab-report image
EngineGemini 2.5 Vision to JSON
OutputStructured parameters for human review, never auto-filed
Speed: ~5-15s
06

Pharmacy Safety Engine

InputPrescription + allergies / current meds
EngineDeterministic rules, not an LLM
OutputAllergy / interaction / stock / dosage flags
Speed: < 100ms

Technology Stack

client

  • React 18
  • TypeScript
  • Vite
  • TailwindCSS
  • Zustand
  • Framer Motion
  • WebSockets
  • PWA (Workbox)
  • Dexie / IndexedDB

server

  • Python
  • FastAPI
  • PostgreSQL
  • psycopg2
  • WebSockets
  • Async workers
  • Alembic
  • JWT + bcrypt

ai

  • Google Gemini 2.5 (Flash / Pro / Vision)
  • Groq (Llama 3.x)
  • Ollama (on-prem)
  • MEWS vitals triage
  • Drug-interaction engine
  • AI cost-metering + kill-switch

data

  • PostgreSQL (event-sourced, RLS audit log)
  • Docker
  • Render
  • Vercel
  • GitHub CI

Key Features

01

Nine real-time role consoles, reception, nurse, doctor, lab, pharmacy, admin, lobby display, a patient self-intake PWA, and an external lab-partner portal, all on one shared live state machine.

02

AI triage plus a multilingual intake chatbot (Hindi / Punjabi / English) that hands the doctor a structured clinical brief before the patient walks in.

03

AI clinical scribe producing a dual discharge summary (a clinician version and a plain-language patient version), lab-report vision OCR, and deterministic pharmacy safety flags, every output human-confirmed.

04

Fairness-aware queue scheduler with weighted scoring, starvation protection, emergency insertion, and a live token and display board.

05

Decimal-exact billing with automatic line-item accrual, Ayushman claims, payments, and daily revenue reconciliation, accurate to the paisa.

06

Enterprise backbone: JWT and role-based access control, per-facility data isolation, Aadhaar encryption, an append-only audit log, AI cost-metering with a kill-switch, and an offline-first PWA.

Screenshots

Overview film

The reel

Vertical cut

The whole system, start to finish.

  • One patient token moving live through all ten states, from registration to discharge.
  • The AI layer triaging, scribing, and flagging, with a clinician confirming every call.
  • Nine role consoles staying in lockstep on a single source-of-truth state machine.

System architecture

01Register
02Triage
03Queue
04Consult
05Investigations
06Pharmacy
07Billing
08Discharge
Nine live consoles
  • Reception
  • Nurse
  • Doctor
  • Lab
  • Pharmacy
  • Admin
  • Lobby board
  • Patient PWA
  • Lab partner
AI, human-confirmed
  • Triage
  • Intake chatbot
  • Clinical brief
  • Dual scribe
  • Lab vision OCR
  • Pharmacy safety
Backbone
  • Event-sourced PostgreSQL
  • WebSockets sync
  • RBAC + audit log
  • Aadhaar encryption
  • Offline-first PWA

Project Presentation

12 slides

The full AutoFlow deck: the OPD state machine, the nine role consoles, the AI augmentation layer, and the security and compliance backbone.

Download deck PDF