KatInterview

Licensed-Clinician Matching Queue for a Virtual Care Service

System DesignModel answer
MediumModel answerSystem Designsystem-designqueueingconcurrency

Last updated

Design a 24/7 virtual-care intake system that routes waiting patients to clinicians licensed in the patient's current state, with safe concurrent claiming, auditing and compliance.

A health insurer offers its members free, around-the-clock virtual doctor visits through a website and a mobile app. Members live across many U.S. states. The insurer employs physicians who each hold medical licenses in only some states, and a physician may treat a patient only if licensed in the state where that patient currently is.

Design the backend that lets members ask for a virtual visit and lets physicians pick up those requests promptly, safely and in compliance with regulations.

Your answer should cover:

  • Functional and non-functional requirements, plus a rough scale estimate
  • Public APIs for members and physicians
  • Data model and the lifecycle of a consultation request
  • Queueing and matching logic, including fairness when some states have few licensed physicians
  • Concurrency control (two physicians claiming at once, a patient cancelling during a claim, double clicks, client retries)
  • Scalability, reliability and failure handling
  • Security, privacy and audit needs, and operational monitoring

State your assumptions explicitly, and explain which pieces you would deliberately keep simple.

Hints

Hint 1

Start with the scale estimate. Work out requests per second before choosing technology; the answer should shape how heavy your queue infrastructure needs to be.

Hint 2

Think about which location governs licensing (where the patient is right now) and where the license check must be enforced so that a stale UI list can never cause a violation.

Hint 3

Let physicians ask the server for the next eligible patient instead of browsing. Consider a row-level locking approach that lets simultaneous claimers receive different rows without blocking, plus database constraints and idempotency keys for the remaining races.

Hint 4

Plain first-come-first-served can starve states with few licensed physicians. Consider a scarcity-aware ranking with a hard wait-time override, and think about what happens when a physician claims a patient and then disappears.