Design Appointment Scheduling Data Model and APIs
You are tasked with extending an existing healthcare system to include appointment scheduling functionality. The system already manages User and Patient entities. Doctors and Staff are considered Users, while Patients are separate entities managed by existing Patient APIs.
The new appointment scheduling capability needs to facilitate interactions between Doctors and Patients at Hospitals.
Implementation Context: Django (data model design + REST API design).
Definitions & Business Rules
- Hospital Operating Hours: Each hospital has defined operating hours (e.g., 09:00–19:00). The UI should only display these open hours.
- Doctor Availability: This represents a time range when a Doctor is available to see patients at a specific Hospital. Doctor Availabilities must fall within the hospital's operating hours. Staff can create these.
- Appointment: An Appointment is a scheduled time for a Patient to see a Doctor at a Hospital. Appointments are exactly 1 hour long and must start on the hour (e.g., 10:00, 11:00). An Appointment can only be scheduled during an existing Doctor Availability. Staff can create these.
UX-Driven Behavior
- Clicking an empty time slot should prompt the user to schedule a Doctor's Availability.
- Clicking an existing Doctor's Availability should prompt the user to schedule an Appointment.
Required API Capabilities
- View Availabilities and Appointments, filterable by date, doctor(s), and hospital.
- Create a Doctor's Availability for a specific date and hospital.
- Create an Appointment within an existing Doctor's Availability.
Your Task
Design:
- A Django-friendly data model (entities, key fields, relationships, constraints).
- The REST APIs (endpoints, request/response shapes, validation rules, error cases).
- The core logic to enforce constraints (operating hours, valid times, appointment-within-availability, conflict handling).
AI interview prep
Core dilemma
Balancing the complexity of time-based scheduling constraints (operating hours, doctor availability, fixed appointment durations) with the need for efficient data retrieval and conflict-free appointment creation.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design Appointment Scheduling Data Model and APIs
You are tasked with extending an existing healthcare system to include appointment scheduling functionality. The system already manages User and Patient entities. Doctors and Staff are considered Users, while Patients are separate entities managed by existing Patient APIs.
The new appointment scheduling capability needs to facilitate interactions between Doctors and Patients at Hospitals.
Implementation Context: Django (data model design + REST API design).
Definitions & Business Rules
- Hospital Operating Hours: Each hospital has defined operating hours (e.g., 09:00–19:00). The UI should only display these open hours.
- Doctor Availability: This represents a time range when a Doctor is available to see patients at a specific Hospital. Doctor Availabilities must fall within the hospital's operating hours. Staff can create these.
- Appointment: An Appointment is a scheduled time for a Patient to see a Doctor at a Hospital. Appointments are exactly 1 hour long and must start on the hour (e.g., 10:00, 11:00). An Appointment can only be scheduled during an existing Doctor Availability. Staff can create these.
UX-Driven Behavior
- Clicking an empty time slot should prompt the user to schedule a Doctor's Availability.
- Clicking an existing Doctor's Availability should prompt the user to schedule an Appointment.
Required API Capabilities
- View Availabilities and Appointments, filterable by date, doctor(s), and hospital.
- Create a Doctor's Availability for a specific date and hospital.
- Create an Appointment within an existing Doctor's Availability.
Your Task
Design:
- A Django-friendly data model (entities, key fields, relationships, constraints).
- The REST APIs (endpoints, request/response shapes, validation rules, error cases).
- The core logic to enforce constraints (operating hours, valid times, appointment-within-availability, conflict handling).