AI School · Level 4 · Practical case · The pharmacy's numbers

A staff rota that meets the 1,785-hour limit

Léelo en español →

Reading time: about 10 minutes

The situation. Every year the rota gets drawn on a sheet of paper, by eye, dragged over from last year. And every year somebody ends up with too many hours and somebody with too few, and it comes out in November.

Here the AI does the boring part — distributing shifts and adding hours — and you do what it cannot: check the result against the collective agreement. It is the most delicate case in this block because a bad rota is a claim waiting to happen, so the weight here is on the checking, not on the generating.

What you need to hand: How many people and their contracts (full time or the part-time percentage), your opening hours, and the figure that rules: the Spanish national agreement’s 1,785-hour annual maximum. If you are under a provincial agreement, check yours first — they do not all match.

Step by step

  1. Give it the hard rules before the problem

    A rota is a constraint problem, and a model respects the constraints you write down and no others. If you do not mention weekly rest, it will happily produce seven-day weeks.

    The non-negotiables, all of which go in the prompt: the annual cap, rest between shifts, weekly rest, each person’s holidays, and hours already worked or committed.

    And do not give it names. "Person 1, person 2" works exactly the same and saves you sending a third party who works in your pharmacy and when. You add the names at the end, on your own sheet.

    Help me build the annual rota for a pharmacy in Spain.
    
    STAFF (no names):
    - Person 1: full time
    - Person 2: full time
    - Person 3: 60% part time
    - Person 4: 50% part time, afternoons only
    
    OPENING: Mon-Fri 9:00-14:00 and 17:00-20:30; Sat 9:30-14:00
    Closed Sundays and 12 public holidays.
    
    RULES THAT CANNOT BE BROKEN:
    - Maximum 1,785 hours a year for a full-time contract. Part-timers,
      pro rata.
    - Minimum 12 hours’ rest between the end of one shift and the start of
      the next.
    - One and a half consecutive days of weekly rest.
    - 30 calendar days of holiday per person.
    - There must ALWAYS be at least one pharmacist on during opening
      hours.
    
    Give me:
    1. The typical weekly distribution, as a table.
    2. The ANNUAL HOUR TOTAL each person ends up with under that pattern.
    3. The gap between that total and their maximum, in hours.
    4. Any week where one of the rules above is broken.
    
    Show me how you calculated the annual hours. If a constraint is
    impossible to meet with this staff, SAY SO instead of inventing a rota
    that looks like it adds up.

← All practical cases Back to the school →