Appointments table#
The appointments table is the primary output of the scheduler.
It integrates patient demographics, slot schedules, and simulated outcomes to create a realistic record of outpatient activity.
Each row corresponds to one appointment, containing demographic, temporal, and behavioral information.
For most analytical use cases (attendance rates, waiting times, utilization), this table can be used independently.
Overview#
File name:
appointments.csvGenerated by:
AppointmentScheduler.generate_appointments()Schema: One row per scheduled appointment
Linked to:
patientsviapatient_idslotsviaslot_id
Core columns#
Column |
Type |
Description |
|---|---|---|
|
string |
Unique sequential identifier for each appointment. |
|
string |
Links the appointment to a generated slot (see slots table). |
|
string |
Identifier of the assigned patient (see patients table). |
|
date |
Date when the appointment was booked (see Booking dynamics). |
|
int |
Days between scheduling and appointment date, also known as lead time (see Booking dynamics). |
|
date |
Scheduled appointment date, derived from slot configuration. |
|
time |
Scheduled start time of the appointment (see Calendar structure). |
|
string |
Outcome of the appointment ( |
|
string |
Patient’s sex, inherited from demographic data (see Patient demographics). |
|
int |
Patient age at the time of appointment, computed from |
|
string |
Age bin derived from |
|
time |
Actual arrival time for attended visits (see Appointment timing). |
|
time |
Time the consultation began (see Appointment timing). |
|
time |
Time the consultation ended (see Appointment timing). |
|
float |
Minutes between check-in and start (see Appointment timing). |
|
float |
Duration of the consultation in minutes (see Appointment timing). |
Generation logic#
The appointment generation process integrates parameters from the patient, slot, and behavioral models.
1️⃣ Slot selection#
Appointments are assigned to slots from the calendar grid:
Governed by
fill_rate,booking_horizon, andmedian_lead_time(Booking dynamics).The scheduler ensures the latest slot extends beyond
ref_date + booking_horizon(Date ranges and reference date).
2️⃣ Patient assignment#
Patients are drawn from the synthetic population:
Population structure from Patient demographics.
Visit frequency and first-attendance ratio from Patient flow.
Demographic fields (
sex,dob) are propagated into this table.ageandage_groupare computed dynamically based onappointment_date.
3️⃣ Attendance and outcomes#
Appointment results follow status_rates (Attendance behavior):
Default NHS-based proportions: 77.3% attended, 16.4% cancelled, 5.9% did not attend, 0.4% unknown.
Cancelled visits may be rebooked depending on
rebook_category(min,med,max).
4️⃣ Timing and punctuality#
Temporal details are simulated according to operational studies (Appointment timing):
check_in_time_meandefines early arrival (default -10 min).Start time accounts for operational delays and prior backlog.
Duration is drawn from a Beta(1.48, 3.6) distribution (mean ≈ 17 min).
Waiting time = start − check-in; duration = end − start.
Example#
from medscheduler import AppointmentScheduler
sched = AppointmentScheduler(seed=42)
sched.generate()
appointments = sched.appointments_df.head(5)
print(appointments)
appointment_id |
slot_id |
patient_id |
appointment_date |
appointment_time |
status |
sex |
age |
waiting_time |
appointment_duration |
|---|---|---|---|---|---|---|---|---|---|
A000001 |
S000004 |
00002 |
2024-01-01 |
08:45:00 |
attended |
Male |
62 |
6.5 |
17.4 |
A000002 |
S000010 |
00005 |
2024-01-01 |
10:15:00 |
did not attend |
Female |
58 |
NaN |
NaN |
A000003 |
S000018 |
00003 |
2024-01-01 |
12:45:00 |
attended |
Female |
49 |
9.1 |
16.3 |
A000004 |
S000024 |
00001 |
2024-01-01 |
14:45:00 |
cancelled |
Female |
37 |
NaN |
NaN |
A000005 |
S000025 |
00004 |
2024-01-01 |
15:00:00 |
attended |
Male |
72 |
7.8 |
18.2 |