Home / Builds / Smart Clinic

Live · v1.0 · Karachi, Pakistan

Healthcare · Clinic Operations · Pakistan

CLINICS DON'T HAVE
A SLOT PROBLEM.
THEY HAVE A PROMISE PROBLEM.

Token-based OPD queue, live ETA engine, consultation records, and reporting system for private clinics. Patients only come when it is nearly their turn. The waiting room stays empty.

The problem

THE SCHEDULE COLLAPSES
BY THE SECOND HOUR.

Clinics run on 15-minute fixed slots. But a follow-up takes 4 minutes and a new diabetic patient takes 20. By mid-session the schedule is fiction — and everyone booked for the evening is waiting in the same room at the same time.

ProblemCost to the clinic
15–25 patients waiting simultaneouslyCrowded room, negative reviews, patients leaving mid-wait
Reception answering "kitni der lagegi?" all dayOne staff member fully occupied on the phone
Paper parchi / registerPrevious prescriptions lost; no history visible at consultation
Manual cash tally at end of dayRevenue leakage, no per-doctor visibility
Insurance claims filed by handWeeks of delay, frequent rejections

Root cause: the system promises a time it cannot keep. The fix is to promise a position and continuously publish an honest estimate.

The solution

PROMISE A POSITION.
PUBLISH A LIVE ETA.

Patients book a token for a session window — not a clock time. The system calculates each patient's ETA from queue position × the doctor's rolling median consultation time. Every time the doctor presses Next Patient, every ETA recalculates and every phone updates in real time.

median_consult_time = median(last 20 completed consultations for this doctor AND this session type) patients_ahead = count(appointments WHERE doctor = D AND session = S AND token < my_token AND status IN ('booked','checked_in')) eta_minutes = patients_ahead × median_consult_time × 1.10 eta_timestamp = now() + eta_minutes leave_home_at = eta_timestamp − travel_buffer (default 30 min)

Median — not mean. A single 45-minute emergency must not distort every downstream ETA.

Before55minAverage wait
After<12minAverage wait
Before80Reception calls/day
After<20Reception calls/day

What was built

FIVE INTERFACES.
ONE SHARED RECORD.

Patient · React Native / PWA

Patient App

Book token, track live queue position, see real-time ETA countdown, receive "leave now" and "arrive now" notifications, view prescription history, manage family profiles.

Doctor · React + Vite

Doctor Console

Session dashboard, current patient panel with visit history and pre-consultation form, Rx pad with drug autocomplete (Pakistani market), lab orders, ICD-10 diagnosis, Next Patient button.

Reception · React + Vite

Reception Panel

Issue walk-in tokens, check-in arrivals, collect fees (cash / card / insurance), initiate claims, reschedule, reorder queue for emergencies, end-of-day cash reconciliation.

Public · Any browser or TV

Display Board

Now-serving token and room number, next 3 tokens, silent WebSocket updates. Runs on any screen in the waiting area with no interaction required.

Owner · Admin portal

Admin & Reports

Doctor setup, session config, fee structure, staff roles, full report suite: waiting time analytics, doctor-wise revenue, insurance claims, daily financial ledger.

Backend · NestJS

Queue Engine

The heart of the system. Handles the Next Patient state machine, ETA recalculation on every queue change, BullMQ notification scheduling with live reschedule on ETA drift, Redis fan-out to all connected clients.

Tech stack

CHOSEN FOR
WHAT THE PROBLEM NEEDS.

LayerChoiceWhy
BackendNode.js 20 + NestJS + TypeScriptModules map cleanly to services; DI makes testing practical
DatabasePostgreSQL 16Token allocation must not race — transactions matter here
Cache / pub-subRedis 7Live queue state + Socket.IO adapter for multi-instance sync
Job queueBullMQDelayed jobs with cancellation — exactly what notification rescheduling needs
RealtimeSocket.IORooms per session, automatic reconnect
Patient appReact Native (Expo)One codebase, Android-first for Pakistan
Web consolesReact 18 + Vite + TailwindFast build, small team
SMSLocal gateway (Veevotech / Jazz)10–20× cheaper than Twilio for Pakistan numbers
PushFirebase Cloud MessagingFree, instant for app users
ORMPrismaType-safe queries, painless migrations
NestJSTypeScriptPostgreSQLRedisBullMQSocket.IOReact NativeExpoReact 18VitePrismaFCMDocker

Delivery

SHIPPED IN
FOUR PHASES.

Phase01

Core — 4 weeks

Auth and OTP, doctor/session setup, token booking, queue engine with live ETA, doctor console with Next Patient, prescription pad, reception check-in and fee collection, display board, FCM + SMS notifications, daily report.

Phase02

Records depth — 3 weeks

Full patient history timeline, lab and imaging orders with results, file attachments, follow-up auto-booking, prescription PDF and WhatsApp delivery, doctor-wise and financial reports.

Phase03

Insurance & scale — 3 weeks

Insurance panels, claim lifecycle and reports, multi-doctor and multi-room sessions, ICD-10 diagnosis coding, admin analytics, audit log.

Phase04

Optional expansion

Multi-branch support, pharmacy inventory, teleconsultation, Urdu UI, patient feedback and ratings.

Work with Mohsin

HAVE A PROBLEM
WORTH BUILDING FOR?

I work with founders and product teams from idea through deployed product. If you have a system problem like this one — bring the problem, not the brief.