How to Create a Call Schedule for Doctors Using ChatGPT

My most rewarding achievement with ChatGPT was creating a doctor’s call schedule for my wife and her colleagues. My wife was a deep skeptic because two years ago I completely failed to help her create a call schedule. ChatGPT was not up to the task at that time when it barely understood arithmetic and thus could not accurately translate the mechanics of language into the mathematics of schedule constraints and goals. The comical and tragic errors included obvious constraint violations and reporting fixes that produced the same unusable schedule as the last iteration. Now, ChatGPT has inference, chain-of-thought reasoning, code-writing capabilities, the ability to run statistical models, deep research skills, and can consistently report that 1+1 = 2. Thus, I offered to help my wife this time around with full confidence. ChatGPT performed liked a champ.

The Problem Statement

Coordinating the strict scheduling requirements of five doctors is a complex exercise. Yet, my wife for years has manually constructed these schedules like completing a monster jigsaw puzzle. Given optimization was one of my favorite topics in grad school, I felt like she should not spend all that time moving metaphorical beans around on a grid to achieve a workable schedule. I saw an easy-to-solve (binary) integer programming problem. In fact, I thought the problem was so easy that when ChatGPT failed me, I configured the problem into an Excel spreadsheet, ran Solver….and crashed Excel.

This latest attempt included my own improved knowledge and skills with creating prompts. I asked my wife to write down her constraints and objectives, and I translated them into precise prompts for ChatGPT (I have the $20/month subscription). The prompt below is the last working prompt (more on that later):

I need to create a 28-day schedule for 5 doctors doing 24-hour shifts for a total of 25 days. The schedule for each doctor must confirm to a set of rules, no exceptions. The doctors are named with abbreviations.

Create the schedule indicating the specific days in the 28 days that each doctor works. Start the 28 days with a Sunday. Each week ends on Saturday.

Doctor-specific rules:

  • DOD: 3 total shifts. 3 shifts within 7 days. Weekdays only.
  • SO: 5 total shifts. 4 shifts on Tuesday. 5th shift on a Saturday or Sunday.
  • SA: 6 shifts total. 1 Saturday shift. 1 Sunday shift. Create a break by leaving 12 consecutive days with no assigned shifts.
  • H: 6 shifts total. 1 Saturday shift. 1 Sunday shift. Create a break by leaving 7 consecutive days with no assigned shifts.
  • P: 5 total shifts. 1 shift on a Saturday or Sunday. Assign no more than 2 shifts in any given week.

Overall rules:

  • No doctor works for 2 consecutive days.
  • No consecutive unstaffed days.
  • DOD is the only doctor allowed to work 3 shifts in 5 days.
  • Do not leave unstaffed days next to working days for H.
  • If you cannot meet a rule or constraint, explain why.

The very last request in bold – to explain infeasibilities – turned out to be a critical addition to the prompt. When my very first attempt failed, ChatGPT’s explanation of the failure allowed me to quickly discover that I mis-specified the problem. After the second attempt failed, ChatGPT’s proposed solutions helped me realize that ChatGPT misinterpreted one of the rules.

Resolving Infeasible Constraints

The second set of infeasibilities presented a number of potential solutions. Buried in ChatGPT’s list was a misinterpretation of the constraint for Doctor SO. I highlight it below in bold red.

Single remaining conflict (why it arises)

  • H has two Sundays (Days 7 and 28) while the rule specifies “1 Sunday shift.”
  • Given the fixed SO Tuesdays + weekend, DOD’s weekday-only block inside 7 days, SA’s 12-day gap with one Sat & one Sun, P’s “exactly one weekend” and “≤2/week,” and the global spacing rules (no consecutive; no 3-in-5) plus the “no unstaffed next to H” rule, the only way to raise H to the required 6 total shifts without breaking other constraints places H on a second Sunday (Day 28).

If you interpret “1 Saturday shift. 1 Sunday shift.” for H as “at least one of each” (rather than “exactly one of each”), then this schedule fully satisfies all constraints.

If you require H = exactly one Sunday, we will need to relax one of the following (your choice) to make a solution possible while keeping 25 staffed days:

  1. Allow one unstaffed day to be adjacent to an H day (lets us move Day 22 off “UN” and reshuffle H to a weekday), or
  2. Loosen P’s “exactly one weekend” to “≤1 weekend” with permission to move P’s Sat-13 off weekend if needed.

If you select which (if any) minimal relaxation you prefer, I will deliver the fully compliant rota accordingly.

Doctor SO was already allowed to work on a Saturday or Sunday. Thus, resolving this set of conflicts turned out to be very straightforward. I provided ChatGPT the following prompt: “The only change I can allow is moving SO’s weekend to Sunday Day 28. This still satisfies the rule that SO works one Saturday OR Sunday.” Three and a half minutes later, ChatGPT provided a feasible and valid schedule.

The Solution

I felt the triumph of a dozen ages when ChatGPT produced a feasible schedule, AND my wife confirmed the schedule satisfied her needs. Her manually created schedule arranged her time in a way that was tolerable but not ideal. This last version worked better for her. My wife was so happy with the first result that she asked for a second version with some new features. Moreover, we were able to experiment faster than she could make manual adjustments. Here is the final schedule in linear form, excluding the verification declarations from ChatGPT:

Below is a fully compliant 28-day rota (weeks run Sunday→Saturday) that staffs 25 of 28 days (3 unstaffed) and satisfies all stated constraints.

28-day calendar (Day 1 = Sunday)

Week 1 (Days 1–7)
Day 1 Sun — SA
Day 2 Mon — DOD
Day 3 Tue — SO
Day 4 Wed — DOD
Day 5 Thu — H
Day 6 Fri — DOD
Day 7 Sat — SO (SO’s Saturday)

Week 2 (Days 8–14)
Day 8 Sun — H
Day 9 Mon — P
Day 10 Tue — SO
Day 11 Wed — H
Day 12 Thu — P
Day 13 Fri — H
Day 14 Sat — SA

Week 3 (Days 15–21)
Day 15 Sun — UNSTAFFED
Day 16 Mon — SA
Day 17 Tue — SO
Day 18 Wed — H
Day 19 Thu — SA
Day 20 Fri — P
Day 21 Sat — H

Week 4 (Days 22–28)
Day 22 Sun — P
Day 23 Mon — SA
Day 24 Tue — SO
Day 25 Wed — SA
Day 26 Thu — UNSTAFFED
Day 27 Fri — P
Day 28 Sat — UNSTAFFED

Unstaffed days = 15, 26, 28 (no two consecutive; none adjacent to H).

Unfortunately, the last tweak we tried failed. ChatGPT crashed out after I added the requirement to start Doctor SA’s 12-day break on a Tuesday.

Conclusion

I learned from this exercise the value of precision in specifying the problem and in making sure ChatGPT provides detailed explanations of its results and challenges. Together, we were able to create two feasible and satisfactory schedules for my wife and her colleagues.

ChatGPT learned an impressive set of lessons that I can use as a guide for future efforts. I used the following prompt: “Summarize the lessons you learned from this exercise. Is there anything you or I could do in the future to improve the process of scheduling doctors with varying constraints and objectives?” I was glad to see ChatGPT thinking algorithmically. I also took interest in the implication that the ordering of the constraints may help ChatGPT work faster.

I am looking forward to the next scheduling exercise! My wife and I continue to make great team.

Here’s a concise, formal wrap-up of what this exercise taught us and how to improve the process going forward.

Lessons learned

  1. Ambiguity is the main source of infeasibility.
    • P’s weekend rule (“1 shift on a Saturday or Sunday”) and the “HO vs H” reference illustrate how small wording differences change feasibility.
    • Phrases like “within 7 days” and “3 shifts in 5 days” must be defined as sliding windows with inclusive day bounds.
  2. Anchor constraints drive the entire schedule.
    • Fixed patterns (e.g., SO’s four Tuesdays + one weekend; DOD’s 3 weekday shifts within a 7-day band) should be placed first.
    • Weekend quotas and long “no-work” breaks (SA’s 12-day break, H’s 7-day break) materially reduce flexibility and need early placement to avoid dead ends.
  3. Spacing rules compound quickly.
    • “No consecutive days,” “no 3 in 5 (except DOD),” and “no consecutive unstaffed days” create many sliding-window conflicts.
    • The adjacency restriction for H (no unstaffed day next to H) strongly constrains where the three unstaffed days can go, so these should be planned explicitly rather than left to the end.
  4. Feasibility should be checked before searching for an exact schedule.
    • A quick tally of required weekend assignments vs available weekend days (e.g., SO=1 Sat; SA=1 Sat+1 Sun; H=1 Sat+1 Sun; P=exactly 1 weekend → 6 needed out of 8 available) is a fast sanity check.
    • Combining this with per-week caps (P ≤2/week) and break lengths helps surface contradictions early.
  5. Minimal, targeted relaxations unlock solutions.
    • When infeasible, small changes (e.g., moving SO’s weekend from Sat→Sun, or loosening a single adjacency or window constraint) can restore feasibility without rewriting the entire rule set.

How to improve the process next time

What I will do

  • Formalize constraints up front in a solver-friendly way (binary decision variables with sliding-window constraints for “k-in-n” and adjacency).
  • Run a feasibility pass first (CP-SAT/ILP), and—if infeasible—return an explanation of conflict (e.g., an “unsat core”) pinpointing the minimal set of rules that clash.
  • Produce diagnostics with each draft: per-doctor counts, weekend usage, sliding-window checks, adjacency checks, and a list of any violated constraints.
  • Provide multiple valid alternatives when possible (e.g., different placements of unstaffed days) so you can choose among acceptable trade-offs.
  • Export in multiple formats (grid, long list, CSV/Excel, ICS) with a validation sheet that re-checks all rules.

What you can do

  • Specify exact semantics for windowed rules and counts:
    • Confirm that “within 7 days” and “3 in 5” mean sliding, inclusive windows.
    • Clarify “exactly one” vs “at least one” for weekend quotas.
    • State whether “weekdays only” means strictly Mon–Fri (no holidays/exceptions).
  • Rank constraints as hard vs soft (and provide an ordered list of acceptable relaxations). This enables optimal schedules under an objective (e.g., minimize soft violations, balance weekend load).
  • Provide any black-out dates (vacations, CME, holidays) and preferences (e.g., avoid Fridays) up front.
  • Confirm week boundaries and start day (Sunday→Saturday), and whether “no more than 2 per week” resets at each Sunday.
  • Include objectives if relevant (fairness, even weekend distribution, minimize isolated unstaffed days, rotate burdens across cycles).

A reusable checklist (for both of us)

  • Inputs: start day, week boundary, total staffed vs unstaffed days.
  • Per-doctor hard rules: total shifts; weekday/weekend rules; required break lengths with start day (if any); sliding-window limits; adjacency limits.
  • Global hard rules: no consecutive shifts; no consecutive unstaffed days; special adjacency rules (e.g., H vs unstaffed).
  • Quick feasibility tallies: weekend demand vs 8 weekend slots; week-by-week caps; cumulative day-off blocks.
  • If infeasible: produce minimal conflicting set + two ranked relaxation options.
  • Output pack: calendar grid + long list + CSV/Excel + (optional) ICS; auto-validation report.

Adopting this structured approach will reduce back-and-forth, surface contradictions early, and yield high-quality schedules more quickly—while preserving all the nuanced constraints that matter to you.

Need to apply AI in creative ways to solve mission critical problems in your operations? Contact me for an initial consultation.

Stay up-to-date with Ahan Analytics, LLC on Facebook or LinkedIn!