Inspiration

One day I was sick and had to wait for hours in a hospital queue in Thailand. Not because there were too many patients, but because of how the queue was managed. One counter was overloaded while another sat idle, nobody knew how long they would wait, and older patients sat alone staring at a call screen.

This is a global problem. Studies report average outpatient visits of 122.6 minutes in a Nigerian public hospital (source), 56.4% of patients waiting 2+ hours in a Ghanaian teaching hospital (source), and longer waits for vulnerable groups in Vietnam (source). A hospital in China cut consultation and pharmacy waits through management changes alone (source). Better management works, but hospitals have no safe way to test a change before trying it on real patients.

What it does

QueueTwin AI is a live 3D digital twin of a hospital's outpatient flow (Registration → Exam Beds → Pharmacy).

For hospital staff

  • Live 3D view. Every patient is a figure in the clinic. Crowded zones turn red, and anyone waiting over 60 minutes gets a ⚠ badge. A cinematic view shows each bed with a live tag.
  • Fast registration with contact details for the patient and their family or caregivers.
  • Same-staff optimiser. It moves the existing staff between stations and cut the average wait by 35% with zero extra staff-hours on our default demo day (simulation result).
  • AI wait predictor that estimates each patient's wait when they arrive.
  • "Best time to visit" advisor and a fairness check for seniors, wheelchair users and children.
  • Thai and English, large text, shift handover and a replay of the day.

For patients and families

  • QR tracking page on any phone, with live position and estimated wait.
  • Read aloud, a Request Help button, and a phone ring when it is their turn.
  • Privacy by design. Public data masks the surname and hides clinical details.

Sponsor integrations (real API calls)

  • Agentboxd sends queue emails from [email protected] to patients and caregivers, creates pharmacy restock drafts that a human approves, and reads inbound replies. Calls go through our serverless proxy, so the API key never reaches the browser.
  • MojoAuth gives passwordless sign-in with OpenID Connect and PKCE, so no secret is stored in the browser.
  • SSOJet is planned but not connected in this build. The staff-role button is a labelled demo switch.

How we built it

  • Three.js for the 3D clinic and plain JavaScript for the app, deployed on Vercel.
  • A discrete-event queue simulation replays a full clinic day on three random seeds. Every chart and number in the app comes from it, not from fixed formulas.
  • AI wait predictor: a gradient-boosting model trained on 254,081 simulated visits and tested on 400 unseen days. Its error is 10.2 minutes against 23.9 minutes for the standard queue formula.
  • Real-data check: on 220 real emergency-room visits (MIMIC-IV-ED Demo) the model was only 2% better than guessing, because time in an ER depends on illness, tests and beds, not on the queue. We show both numbers in the app.
  • Firebase Realtime Database for phone tracking, and a Vercel serverless function as the Agentboxd proxy.

Challenges we ran into

  • Making the numbers honest. Early versions showed improvements from fixed formulas. I rebuilt the charts so every number comes from the simulation, with the staff-hour cost shown next to each saving.
  • There is no open dataset of outpatient queue logs. The only open real data is from an emergency room, and it gave a small but honest result.
  • Keeping API keys out of the browser, which meant writing a small server proxy with input checks and a rate limit.

Accomplishments that we're proud of

  • The sponsor integrations are real: the Agentboxd email arrives and the MojoAuth sign-in works.
  • A 35% lower average wait with the same staff, reproducible with one button in the app.
  • The app labels what is simulated, what is real data, and what is not connected yet.

What we learned

  • Long waits are often a flow problem, not a capacity problem.
  • A simulation is only useful when its results are reported honestly, including the ones that look bad.
  • Real hospital data is hard to get, so the product must let a hospital train on its own logs.

What's next for QueueTwin: 3D Hospital Queue Digital Twin

  • A pilot with one clinic's real queue log, and retraining the AI on it.
  • Staff sign-in with SSOJet.
  • SMS and LINE alerts for families.

Prototype with simulated patients. Not medical advice. QueueTwin has not yet been tested in a real hospital.

Built With

Share this project:

Updates

Submission history