HomeCase studiesConcurrency-Safe Healthcare Appointment and Provider Discovery Platform

Case study · Denver, United States

Concurrency-Safe Healthcare Appointment and Provider Discovery Platform

Patient Access & Provider Directory

Outpatient clinic networks lose patients before the first visit when confusing provider directories, phone-only referral routing, and slow scheduling portals end in double-booked slots. We built a healthcare appointment and provider discovery platform using Next.js, Node.js, and PostgreSQL that pairs fast specialty and insurance search with database-enforced concurrency guarantees. Short-lived Redis slot holds protect patients while completing intake forms, PostgreSQL exclusion constraints block overlapping bookings at the storage layer, and automated waitlist queues backfill last-minute cancellations.

Industry
Patient Access & Provider Directory
Solution
A web-based provider discovery, self-service appointment scheduling, and clinic waitlist orchestration platform built with Next.js, Node.js, and PostgreSQL.
Platforms
Web & API
Stack
Next.js · Node.js · PostgreSQL · TypeScript · Redis · Prisma
Location
Denver, United States · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Denver, United States. Names withheld by agreement.

Project Overview

Finding the right specialist and securing an open appointment should not require three phone transfers and a 20-minute hold queue. Across multi-site outpatient clinics in Denver, patients searching for an in-network cardiologist, physical therapist, or telehealth primary-care visit frequently hit outdated static directories that advertise availability only to reject the booking after intake forms are filled out. Meanwhile, front-desk teams manually juggle cancellation lists to keep high-demand clinic rooms utilized.

We engineered a patient access and provider discovery platform built on Next.js, Node.js, and PostgreSQL. The public directory renders sub-second specialty and insurance search pages via Next.js, while the Node.js scheduling kernel computes real-time visit-duration availability, enforces database-level overlap locks in PostgreSQL, and fills cancelled slots through an automated waitlist engine.

Scheduling & Patient Access Friction

Multi-clinic outpatient networks commonly encounter four structural problems in online booking:

  • Application-level race conditions: Simple "check availability, then insert" API code allows simultaneous clicks to double-book popular morning slots.
  • Visit-type rigidity: Fixed 15-minute calendar grids break down when diagnostic procedures require 45 minutes plus a dedicated ultrasound room or fasting prep lead time.
  • Ghost cancellations: Patients who drop appointments hours ahead leave idle exam rooms while waitlisted patients remain unaware an opening appeared.
  • Disconnected directory filters: Separate marketing websites and clinic scheduling widgets force patients to re-filter by location, insurance plan, and age limits repeatedly.

Architectural Strategy

The system follows a template-driven availability model backed by storage-layer invariants. Rather than populating millions of pre-sliced empty slot rows that go stale whenever a physician changes clinic hours, PostgreSQL stores recurring shift templates, holiday overrides, resource constraints, and booked tstzrange intervals.

When a patient searches in Next.js, Node.js evaluates eligible providers via PostgreSQL full-text and attribute indexes, subtracts booked intervals and active Redis checkout holds, and projects valid start timestamps tailored to the chosen visit reason. When a booking confirms, PostgreSQL enforces overlap exclusivity atomically inside the commit transaction.

Core Capabilities

  • Faceted Provider & Insurance Search: Filters clinicians by subspecialty, accepted payer plan, clinic radius, telehealth vs. in-person modality, spoken languages, and next-available date.
  • Visit-Reason Triage Rules: Maps patient-friendly symptom or visit categories to exact appointment durations, pre-visit prep instructions (such as fasting or prior imaging), and age restrictions.
  • Protected Checkout Slot Holds: Reserves selected slots in Redis for an 8-minute countdown while new patients complete demographics and insurance capture.
  • Automated Waitlist Backfill: Detects cancellations from either the patient portal or front-desk EHR sync and dispatches priority-ordered SMS/email claim links automatically.
  • Multi-Resource Room Coordination: Books both the clinician and specialized equipment rooms (such as infusion chairs or imaging suites) in a single atomic transaction.
  • Proxy & Family Booking: Supports parents and caregivers managing appointments for dependents under explicit household permissions.

Technical Architecture

Next.js serves SEO-friendly provider profiles and clinic landing pages using React Server Components, fetching real-time slot windows through a Node.js TypeScript scheduling API. PostgreSQL handles directory queries and transactional bookings, Redis coordinates short-lived holds and background waitlist queues, and an EHR sync adapter reconciles external clinic blocks.

Flow: Next.js Directory Search → Node.js Availability Projector (Templates − Redis Holds − Booked Ranges) → Checkout Slot Lock (Redis TTL) → Booking Commit → PostgreSQL GiST Exclusion Check → Notification & EHR Sync Queue

Separating read-heavy directory browsing from transactional slot mutation keeps search pages cacheable and responsive while preserving strict ACID guarantees at the moment of reservation.

Technology Stack

Category Technology detail
Web Frontend Next.js App Router with SSR provider directory pages and accessible booking flows
Scheduling API Node.js TypeScript service managing visit-type rules, clinic templates, and EHR sync
Primary Database PostgreSQL enforcing GiST time-range exclusion constraints and full-text provider search
Data Access Prisma ORM for domain models paired with raw SQL range queries for slot generation
Slot Hold & Queues Redis powering ephemeral 8-minute booking reservations and waitlist job queues
Styling System Tailwind CSS component library tuned for WCAG AA contrast and mobile-first triage
Notifications Transactional SMS and email pipelines for confirmations, prep instructions, and waitlist offers
EHR Bridge Webhook and polling adapters reconciling external clinic schedule blocks and cancellations

Engineering Trade-offs & Solutions

Engineering Challenge Solution & Trade-off
Concurrent bookings during high-demand flu-shot or specialist openings cause overlaps Added PostgreSQL EXCLUDE USING gist (provider_id WITH =, during WITH &&) constraints over tstzrange columns plus Redis checkout locks; requires handling 23P01 exclusion errors cleanly in Node.js to suggest the next nearest open slot.
Computing availability dynamically across 50+ providers per search page adds latency Cached compiled shift templates briefly in Redis and computed 14-day windows using bitmask/interval subtraction in Node.js; trades slight template-edit propagation lag (seconds) for fast search pagination.
External clinic EHR schedules change asynchronously outside the web portal Built an idempotent EHR reconciliation worker ingesting schedule block webhooks and periodic deltas, prioritizing clinical EHR blocks over unconfirmed web holds; prevents clinic-floor collisions when walk-ins occur.
Patients abandon forms partway through, stranding inventory in locked state Tied Redis hold keys to explicit 8-minute TTLs surfaced via a visible countdown timer and explicit release on step-back navigation, balancing checkout calm with rapid inventory recovery.

Security & PHI Isolation

Public provider discovery pages carry zero protected health information; physician profiles, clinic addresses, and anonymous open slot timestamps are strictly separated from patient records. As soon as a patient enters contact details, insurance policy numbers, or clinical intake notes, payloads route exclusively over TLS into authenticated Node.js endpoints with encrypted-at-rest PostgreSQL storage.

Audit logs record every booking creation, reschedule, cancellation, and front-desk override alongside actor identity and timestamp. Rate limiting and bot mitigation on availability endpoints prevent automated scraping of physician schedules while keeping human browsing effortless.

Search Performance & Scheduling Scale

Outpatient networks experience sharp Monday-morning search surges and bursty traffic whenever seasonal vaccine clinics or specialist schedules open. Next.js edge caching absorbs static provider bio rendering, while PostgreSQL GIN indexes accelerate multi-attribute filtering across insurance plans, specialties, and geographic coordinates.

Waitlist notifications and reminder dispatches run asynchronously through Redis-backed worker queues rather than blocking checkout HTTP responses. Even if an SMS gateway experiences transient latency, confirmed bookings commit instantaneously and reminder jobs retry cleanly with exponential backoff.

Operational Outcomes

Unifying provider discovery, concurrency-safe booking, and automated waitlist recovery on Next.js, Node.js, and PostgreSQL modernized patient access across the clinic network:

  • Eliminated double-bookings: Storage-layer exclusion constraints and clinic EHR reconciliation stop overlapping slot assignments before they reach the waiting room.
  • Self-service scheduling confidence: Patients match directly with in-network specialists suited to their visit reason and see genuine open times without phone tag.
  • Recovered clinical capacity: Automated waitlist claim links fill late cancellations smoothly without adding manual outbound calling work for front-desk staff.
  • Prepared clinic arrivals: Tailored visit-type prep reminders and insurance capture ahead of arrival streamline check-in at busy outpatient desks.

01 — Questions

asked about this kind of project

How do you guarantee two patients cannot book the exact same physician time slot concurrently?

Checking availability in application memory is never sufficient under concurrent traffic. We store confirmed appointments using PostgreSQL `tstzrange` intervals protected by a `EXCLUDE USING gist` constraint per provider and resource room, making overlapping double-bookings physically impossible at the database level.

Why pair Redis slot holds with PostgreSQL constraints during checkout?

Patients need a few minutes to confirm insurance details and reason-for-visit questionnaires without losing their selected appointment mid-form. An 8-minute Redis lock hides the pending slot from other shoppers immediately, while the PostgreSQL constraint acts as the final atomic gate when the form submits.

How does the scheduling engine model complex clinic rules like 45-minute new-patient consults versus 15-minute follow-ups?

Rather than pre-generating static 15-minute rows for an entire year, Node.js computes available start times dynamically from provider shift templates, existing booked ranges, buffer blocks, and visit-type durations. Changing a clinic's lunch block or telehealth hours updates search results immediately.

How does automated waitlist backfill avoid spamming dozens of patients for one cancelled slot?

Waitlist dispatchers score eligible patients by clinical priority, distance, and requested time window, then issue time-boxed private claim links in small sequential waves. The first patient to accept locks the slot cleanly and automatically closes remaining offers.

How do you protect patient health details while still offering fast, SEO-indexed Next.js provider directory pages?

Public Next.js server-rendered pages expose only non-PHI directory metadata—physician bios, subspecialties, clinic locations, accepted insurance plans, and anonymized open slot timestamps. Patient demographics, insurance member IDs, and intake notes enter strictly after authenticated or tokenized booking handoff over encrypted APIs.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.