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.