KatInterview

Design a Medication Approval Tracking Platform with Worklists and Digests

System DesignModel answer
HardModel answerSystem Designevent-drivenasync-workflowsdistributed-systems

Last updated

Design backend services for managing async insurance approval workflows, including real-time status tracking, a concurrent pharmacist task queue, and scheduled digest emails.

Background

A healthcare platform helps pharmacy teams manage medication approval requests submitted to insurance companies. Because insurers respond on their own schedules — sometimes within hours, sometimes over weeks — the platform must handle incoming status updates asynchronously and surface the right work to the right person at the right time.

You are designing the core backend for this platform. The three capabilities it must deliver are:

  1. Status tracking — ingest approval status updates from insurers and let clinics query the current status and full history of any request.
  2. Pharmacist worklist — maintain a prioritized, filterable queue of open cases that pharmacists can pick up, work on, and close, without two people stepping on the same case simultaneously.
  3. Daily email digests — send each clinic staff member and pharmacist a personalized morning summary of overnight changes, pending actions, and approaching deadlines.

Scale and Constraints

  • 100,000 active approval requests at any point in time
  • 500,000 inbound status events per day (with burst spikes of 10–20×)
  • 25,000 digest recipients spread across multiple time zones
  • Worklist queries and status lookups must respond within 200 ms at p95
  • Status transitions must be strictly ordered, durable, and auditable; duplicate inbound events must be handled safely
  • Digest delivery must follow at-least-once semantics without sending the same digest twice on retry

What to Cover

  • Architecture overview — the major services, how events flow from inbound update through to the pharmacist UI and email delivery
  • Data model — tables or collections for request state, audit history, worklist entries with locking, and digest tracking
  • Worklist engine — how you index, prioritize, and safely assign cases to concurrent users
  • Digest pipeline — how you schedule, personalize, batch, and recover from failures across time zones

Explain your key design decisions and the trade-offs you considered at each step.

Hints

Hint 1

Before picking any technology, estimate actual throughput. 500,000 events per day is only ~6 per second on average — that changes which tools make sense compared to a system processing millions per second.

Hint 2

A transactional outbox pattern lets you update request state, append to the audit log, update the worklist, and queue a downstream notification all in one atomic database transaction, eliminating dual-write inconsistencies.

Hint 3

For the digest pipeline, idempotency lives in a delivery tracking table with a unique key on (recipient, date). Insert with ON CONFLICT DO NOTHING before sending — that prevents a retry from generating a duplicate email regardless of what happened to the previous attempt.