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.
| Problem | Cost to the clinic |
|---|---|
| 15–25 patients waiting simultaneously | Crowded room, negative reviews, patients leaving mid-wait |
| Reception answering "kitni der lagegi?" all day | One staff member fully occupied on the phone |
| Paper parchi / register | Previous prescriptions lost; no history visible at consultation |
| Manual cash tally at end of day | Revenue leakage, no per-doctor visibility |
| Insurance claims filed by hand | Weeks 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 — not mean. A single 45-minute emergency must not distort every downstream ETA.
What was built
FIVE INTERFACES.
ONE SHARED RECORD.
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 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 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.
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.
Admin & Reports
Doctor setup, session config, fee structure, staff roles, full report suite: waiting time analytics, doctor-wise revenue, insurance claims, daily financial ledger.
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.
| Layer | Choice | Why |
|---|---|---|
| Backend | Node.js 20 + NestJS + TypeScript | Modules map cleanly to services; DI makes testing practical |
| Database | PostgreSQL 16 | Token allocation must not race — transactions matter here |
| Cache / pub-sub | Redis 7 | Live queue state + Socket.IO adapter for multi-instance sync |
| Job queue | BullMQ | Delayed jobs with cancellation — exactly what notification rescheduling needs |
| Realtime | Socket.IO | Rooms per session, automatic reconnect |
| Patient app | React Native (Expo) | One codebase, Android-first for Pakistan |
| Web consoles | React 18 + Vite + Tailwind | Fast build, small team |
| SMS | Local gateway (Veevotech / Jazz) | 10–20× cheaper than Twilio for Pakistan numbers |
| Push | Firebase Cloud Messaging | Free, instant for app users |
| ORM | Prisma | Type-safe queries, painless migrations |
Delivery
SHIPPED IN
FOUR PHASES.
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.
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.
Insurance & scale — 3 weeks
Insurance panels, claim lifecycle and reports, multi-doctor and multi-room sessions, ICD-10 diagnosis coding, admin analytics, audit log.
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.