Inspiration
I live near a government hospital. I've seen patients standing in long queues with no idea when they'll be called. One day an elderly man waited over 2 hours while people who came later got attended first — simply because no one was tracking the order properly.
That stuck with me. This isn't a hard problem. It just needed someone to actually build something practical for a government hospital setup — where internet cuts out constantly, budgets are tight, and staff aren't technical.
🔧 What It Does
Smart Queue manages patient tokens and queues at government hospital OPD counters.
- 🎫 Token Registration — patients get registered from any browser, no special device needed
- 🚨 Priority Queue — emergencies and senior citizens automatically go ahead in the queue
- 🔮 Wait Time Prediction — tells each patient roughly how long they'll wait
- 📡 Live Updates — every screen in the OPD updates the moment someone is called
- 🗄️ Works Offline — internet goes down? System keeps running, nothing is lost
- ☁️ Auto Sync — when connection comes back, data syncs to cloud on its own
- 🔌 No Hardware Required — built Arduino/RFID support too, but the system runs fine without it
How we built it
Single Node.js + Express server. Kept it simple intentionally — government hospital staff shouldn't need IT support to run this.
The core is a dual-database setup. Every registration writes to SQLite first — a local file that works regardless of internet. A background job runs every 30 seconds and pushes unsynced records to MySQL when connection is available. INSERT IGNORE ensures no duplicates even if the job runs twice on the same record.
Priority works through numeric weights — Emergency=3, Senior Citizen=2, Normal=1. The queue query sorts by weight first, then registration time. Emergencies always go first, automatically.
Wait time prediction starts with sensible defaults and improves over time. Every time a patient is marked served, the actual service duration gets logged. Future predictions use the real average from that history — so the system gets more accurate the more it's used.
Socket.IO handles live updates. When anything changes, the server pushes an event to every connected screen instantly — no polling, no manual refresh needed.
Challenges we ran into
The trickiest part was preventing duplicate records during sync. If the server restarted mid-sync, the same records would try to insert into MySQL again. INSERT IGNORE solved that cleanly without complex conflict handling.
Making Arduino optional was another challenge. SerialPort throws an error immediately if no device is connected, which crashed the entire server. Wrapping it in try-catch and letting the system continue in software-only mode was the right fix — the system should never depend on hardware being present.
The first version also assumed stable internet and completely broke when tested offline. Rebuilding the architecture to be offline-first changed a lot of the core design decisions.
Accomplishments that we're proud of
Getting the offline-first dual sync to work reliably was the biggest win. The system can run for hours without internet, then reconnect and sync everything cleanly with zero data loss.
Also proud of the wait time prediction — it starts working from day one using defaults, then silently improves as real data comes in. Staff don't have to configure anything.
What we learned
The biggest lesson — don't assume infrastructure. Designing for the worst case (no internet, no hardware, basic devices) made the system genuinely deployable in a real government hospital.
Also learned the real difference between polling and event-driven updates. The polling version hit the server every 2 seconds from every screen. Socket.IO replaced all of that with a single persistent connection per client — faster updates, much less server load.
What's next for Smart Queue — Priority Token System for Govt Hospitals
- SMS notification to patients when their token is about to be called
- Multi-counter support so different OPD departments manage separate queues
- Doctor-side dashboard to mark patients as served directly
- Weekly analytics — average wait times, busiest hours, peak patient days
- Mobile-friendly UI so patients can check their position from their phone
Built With
- arduino
- arduino-(optional)
- css
- express.js
- html
- javascript
- mysql
- node.js
- serialport
- socket.io
- sqlite
Log in or sign up for Devpost to join the conversation.