AI Healthcare Chatbot
Design a Patient Assistant for a Health System
Design a patient chat assistant for a health system that books visits, routes symptoms to the right level of care and escalates emergencies, while keeping patient data inside HIPAA's rules.
Overview
A health system (hospitals and clinics under one organization) wants a chat assistant in its patient app. Patients ask it to book a visit, ask whether a symptom needs urgent care, ask how to take a medicine, request a refill or say they are not feeling like themselves. Some of those messages are routine; a few are emergencies.
Two things make this harder than a shopping or banking bot. Safety: a wrong answer can hurt someone, and a language model (LLM) can state wrong medical facts fluently. Law: in the US, patient data is protected health information (PHI) under HIPAA, so every system and vendor that touches it must be inside a contract and a set of safeguards. There is also a regulatory line: software that analyzes a patient's symptoms to tell them what condition they have or what treatment to take can be a medical device under FDA rules. This design stays on the safe side of that line: it routes people to the right level of care and to clinicians, and it does not diagnose.
Questions to ask first
These questions set how far the assistant may go, each with the answer this design assumes.
- Who uses it? Patients of one health system, signed in to its app.
- Does it diagnose? No. It routes to a level of care and to people.
- Can it change the medical record? Only appointments. Refills become tasks for the care team.
- Which EHR interface? The EHR's (electronic health record's) FHIR R4 API, with SMART on FHIR patient scopes. Both are explained later in this chapter.
- Can the model provider see PHI? Only a provider that signs a BAA (business associate agreement), and only what the turn needs.
- How big? 5 million patients in the app, and 200,000 chat sessions a day.
The design at a glance
The signed-in patient app sends every message through a chat gateway to a safety screen, which hands red flags and crises straight to the nurse line or a crisis handoff. Everything else reaches the orchestrator, which routes and checks, reads approved drug info, and calls a model endpoint that sits under a BAA. The EHR is reached only through a tool service holding a patient-scoped token: it calls the EHR's FHIR R4 API, adds a row to the append-only PHI access log for every read or write, and puts refills and clinical questions on the care team task queue. The Visual Explanation below draws this design step by step.
What you will be able to do
- Explain why emergencies are caught by fixed rules before the model, and what the assistant says then.
- Draw the HIPAA boundary: which vendors need a BAA, what 'minimum necessary' means for a prompt, what goes in the access log.
- Book an appointment slot so two patients cannot get the same one, using FHIR and SQL.
- Separate routing to a level of care from diagnosis, and say why that matters for FDA rules.
- Size the service and plan for the model being wrong or down.
Key concepts
- Red-flag screening before the model
- Care level, not diagnosis
- Business associate agreement (BAA)
- Minimum necessary
- FHIR R4 and SMART scopes
- Conditional slot booking
- PHI access log
- PHQ-2
- Human in the loop
Functional requirements
- Book, move and cancel appointments from the EHR's open slots
- Screen every message for emergency and crisis signs before anything else runs
- Route symptom questions to a level of care (emergency, same day, routine, self-care information) using clinician-approved protocols
- Answer medication questions from approved drug information, citing the source
- Turn refill and clinical questions into tasks for the care team
- Offer the PHQ-2 depression screen and route positive screens to behavioral health
- Log every read or write of patient data
Non-functional requirements
- Emergency and crisis replies are fixed text, shown within 1 second (a target we chose), with no model call
- Patient data reaches only systems and vendors under a BAA, and only the minimum a turn needs
- No appointment slot is ever booked twice
- The model never states a diagnosis, a dose change or a treatment decision
- Scheduling and escalation keep working when the model is down
Interview questions
- How do you make sure an emergency is never handled by the model?
- Where is the line between routing and diagnosing, and why does it matter?
- Can you send patient data to an LLM provider?
- How do you stop two patients from booking the same slot?
- How does the assistant answer medication questions safely?
- What does the PHQ-2 do, and what happens after a positive screen?
- How do you size the system?
Sign up free to read the full topic
More System Design topics
- AI Data Quality and Monitoring System
- AI Delivery ETA Prediction System
- AI Driver-Rider Matching System
- AI Dynamic Pricing Engine
- AI E-commerce Search Ranking System
- AI Flashcard System
- AI Image Generation Service
- AI Job Matching System
- AI Product Recommendation System
- AI Resume Screening System
- AI Smart Pricing for Short-Term Rentals
- AI Social Media Bot Detection System
Start free on Cariara · Coding problems · System design studio