Article Text
Abstract
In the UK, the introduction of the New Deal on junior doctors’ hours has placed constraints on permissible senior house officer (SHO) rosters. This makes it difficult to construct a rota that satisfies SHOs’ annual leave and study leave requirements, yet remains compliant with the New Deal. A solution is the use of a computer. A computer program is described that generates compliant, full shift, SHO rosters in accordance with annual leave requests. This has been in routine use at the Oxford Radcliffe Hospitals Trust emergency department for the past 18 months. The program lends itself to, but is not specific to A&E applications; it can be used to generate compliant full shift rosters for other specialties. A copy of the program can be downloaded free of charge from a web site.
- New Deal
- computer program
- rota
Statistics from Altmetric.com
The New Deal on junior doctors’ hours was introduced in the UK to ease and control the workload placed on doctors in training.1 With respect to “full shifts”, such as those worked by senior house officers (SHOs) in an accident and emergency (A&E) department, the New Deal stipulates the following.
-
The maximum average duty per week should not exceed 56 hours.
-
The maximum continuous duty period must not exceed 14 hours.
-
The minimum period off duty between duty periods is 8 hours.
-
The maximum consecutive duty is 13 days.
-
The minimum continuous periods off duty are 62 hours and 48 hours in 28 days.
-
Annual leave must not be regarded as “off duty” for these purposes.
These restrictions make rostering difficult, particularly when periods of annual leave are to be included. Often the only practical solution is to use a rotating fixed pattern of shifts incorporating periods of annual leave at regular intervals,2 although this does place undue constraints on SHOs’ freedom to choose their annual leave. Before the implementation of the New Deal, this was the method used within the Oxford Radcliffe Hospitals NHS Trust, where A&E SHOs rotate between two emergency departments, one at the Horton Hospital and the other at the John Radcliffe Hospital, spending two months at the Horton site and spending a total of four months at the John Radcliffe. Fixed shift patterns were used at the two sites. SHOs would be offered fixed blocks of annual leave and these would be allocated on a “first come first served” basis. It was also necessary to ensure cover while each SHO went on an ATLS course. The introduction of the New Deal, however, and a simultaneous increase in the total number of SHOs from 12 to 15, made this scheme unworkable. A further complicating factor was the need to ensure that each SHO’s entire sequence of shifts during the six months was New Deal compliant despite a significant difference in the shift structures at the two sites. The task was so fraught with difficulty that errors and omissions were often discovered, necessitating changes to the roster in mid-stream and the employment of locum doctors to maintain cover.
Two years ago we started to tackle the problem by developing a computer program to generate New Deal compliant rosters automatically, taking into account SHOs’ expressed wishes for annual leave and other off duty requests for attending courses, sitting examinations, and other personal commitments. In the rest of this document we describe the program and show examples of the rosters that it generates. The program has now been in routine use within our trust for the past 18 months. The use of locums has been minimised and restricted to only the most essential—the provision of cover during the first “induction” day, and whenever attendance at ATLS courses depletes the departments of sufficient SHOs to fill all shifts in the two departments. The current version of the program is freely available for other NHS departments to use and can be downloaded from our web site. The program is particularly suited to A&E use but it is also applicable to the task of configuring full shift rosters in any specialty.
THE COMPUTER PROGRAM
The Rota-Maker Program* generates a rota according to the user’s specification for a team of doctors working full shifts. Every rota generated is fully compliant with the New Deal on junior doctors’ hours. The capacity of the program is large; each rota may be as long as 366 days, may contain as many as 100 different types of shift, and may involve as many as 100 doctors. The program handles complex shift patterns in which particular types of shift occur on only certain days of the week, or for only part of the period of the rota. Rosters across multiple split sites are readily handled.
Each roster is stored on computer as an RMP file. There are two components to each RMP file:
-
A “definition” that specifies the scope and desired properties of the roster.
-
A roster that meets the specification.
The definition comprises the title of the rota, the first and last day of the rota, the names of the participating doctors, details of the shift structure, logical constraints imposed by the New Deal, and requests for annual leave and other absences; the roster is generated automatically. The program maintains the invariant that every rota accords with its definition. This means that if the definition is changed, the rota is automatically truncated so that whatever remains still meets the specification.
Specifying the shift structure
The types of shift are automatically numbered 0, 1, 2, etc, for later reference. Each shift has a specified begin time and end time, which are expressed in 24 hour format, where 00:00 hours refers to midnight at the start of a day. If the end time is equal to or earlier than the begin time, then the shift is taken to end after midnight on the following day. Thus, in principle, shifts of up to 24 hours can be specified.
Some rotas have complex shift patterns in which some shifts exist on only certain days of the week, or for only part of the duration of the rota. To allow for this, the program associates three further parameters with each shift; a start date, a stop date, and a set of days of the week on which the shift occurs. Also associated with each shift is an optional label. This is a string of up to five characters. It is displayed on the rota and can be used to convey any information about the shift. For example, if there is more than one shift with the same start and stop times, it is helpful to distinguish the shifts by their labels. If an A&E department has split sites between which doctors rotate according to an integrated rota, the label can be used to indicate at which site the shift occurs.
For example, table 1 shows the list of shifts for one of our actual A&E rotas. Notice that there are 10 shifts altogether, seven at the John Radcliffe Hospital (JR2) and three at the Horton Hospital (HGH). The first day (05/02/2003) is an induction day, so only the shifts starting after 16:00 hours take place on that day, the others starting on the following day. One exception is shift number 4. This is an extra shift from 12:00 to 20:00 hours that takes place on the Saturday and Sunday of the first weekend only, a time when the department is under considerable pressure and the SHOs are still inexperienced. All other shifts occur on every day of the week, and continue through to 09:00 hours on the last day of the rota (06/08/2003), which is the induction day for the next cohort of SHOs who start a new rota.
Specifying the constraints
The numerical constraints imposed on the rota are by default those of the New Deal (see box). The actual values can be changed as necessary to comply with local policies. For example, we prefer there to be a minimum of nine hours off between shifts and a maximum of 10 consecutive duty days. When the Working Time Directive comes into force in August 2004, we expect that it will be necessary to increase the minimum number of hours off between shifts from 8 to 11.
Requests for annual leave and other absences impose additional logical constraints on the rota. These are encoded in the program as “assignments”. Each assignment applies to a given set of doctors; it restricts them to working only shifts from a given set between specified dates, or to being on annual leave between those dates. For example, suppose that doctor AA wishes to take annual leave from 10/02/2003 to 23/02/2003. This is expressed by the following assignment.
Default settings of the numerical constraints. Each of the seven numbers can be varied
-
Maximum average hours worked per week = 56
-
Maximum length in hours of any shift = 14
-
Minimum hours off between any shifts = 8
-
Maximum number of consecutive duty days = 13
-
Every 28 days include a 62 hour break and a 48 hour break.
Doctors = {AA}
Shifts = annual leave
From = 10/02/2003
To = 23/02/2003
Of course it would be unreasonable to expect the doctor to work after midnight before going away on annual leave next morning. With reference to table 1 we express this by the following assignment; doctor AA is unavailable for shift 5, shift 6, or shift 9 on the day before going on annual leave.
Doctors = {AA}
Shifts = {0,1,2,3,4,7,8}
From = 09/02/2003
To = 09/02/2003
A similar assignment prevents doctor AA being rostered for a shift before 08:00 hours on the day he returns from annual leave.
Doctors = {AA}
Shifts = {1,2,3,4,5,6,7,8,9}
From = 24/02/2003
To = 24/02/2003
If doctor AA would like the weekend of 17 and 18 May off to attend a private function, but does not want to use up annual leave, this is expressed by the following assignment, making AA unavailable for any shift on those days.
Doctors = {AA}
Shifts = {}
From = 17/05/2003
To = 18/05/2003
Rotation between split sites can also be handled by means of assignments. For example, shifts 0 to 6 occur at the John Radcliffe Hospital and shifts 7, 8, and 9 occur at the Horton Hospital. Suppose that the five doctors ‘AA’, ‘BB’, ‘CC’, ‘DD’, and ‘EE’ work only at the Horton Hospital for the first two months of the rota. This is expressed by the following assignment.
Doctors = {AA,BB,CC,DD,EE}
Shifts = {7,8,9}
From = 05/02/2003
To = 04/04/2003
A corresponding assignment is needed to restrict the other doctors to the John Radcliffe shifts during this same period. Thus by making a series of assignments in this way, rotation of cohorts of doctors between sites can be achieved. The advantage of creating an integrated rota like this, rather than independent rotas for each site, is that seamless rotation consistent with the New Deal is guaranteed.
Generation of a rota
Once the rota is defined, an actual rota satisfying the specification can be generated automatically. The program interprets the numerical constraints in accordance with a formal mathematical specification of the New Deal that can be found elsewhere.3 The program constructs the rota in linear day order (from the first day through to the last day) by a backtracking best first search. For each shift in turn, all doctors are identified whose availability is compatible with the numerical constraints and the specified assignments. Scores are then calculated for the available doctors. The scores are based on the hours worked by each doctor up to the current day, ignoring any annual leave. The scores also reflect whether working the shift helps to create a run of consecutive identical shifts for the particular doctor; regularity of a rota is desirable because it is less disruptive to each doctor’s daily routine. The program then constructs up to five alternative mappings from the available doctors to the shifts to be filled during the current day. A stochastic algorithm (in other words, one using random numbers) is used to construct the mappings such that the total score tends to be high. If no mapping can be constructed the program backtracks to the previous day, otherwise the first mapping is selected and the program proceeds to the next day. If the program backtracks to a particular day, the next mapping on the list is selected otherwise if none is left the program continues to backtrack to the previous day.
The user can interrupt and abort rota generation at any time, but if there are fewer doctors than there are shifts to be filled on a particular day, the program hits an impassable bottleneck and will eventually backtrack all the way to the first day and terminate. When rota generation terminates or is aborted, the program reports the furthest day it reached during generation. This identifies the bottleneck day in which insufficient staff are available. The allocation of leave around this date must then be readjusted to increase the number of available staff before attempting once more to generate a rota. If it is necessary to employ a locum to cover one or more shifts (say because so many doctors are necessarily away at a particular time that it leaves fewer doctors than the number of shifts to work) then one or more locum doctors can be added to the list of doctors. Assignments are then used to restrict the availability of each locum doctor to just the shifts that need to be filled.
In our experience, once bottlenecks have been eliminated, it takes anything from one second to thirty minutes to generate a rota on a standard PC. Once a rota has been generated it can be improved by an optimisation facility in the program. This entails repeatedly making substitutions of doctors that are consistent with the constraints, but that improve the overall score based on equitability and regularity of the rota. In particular, the optimisation facility has been designed to ensure that there is an equitable allocation of night shifts. Table 2 shows part of one of our rotas (the actual initials have been substituted to preserve anonymity); notice that a locum is employed on three consecutive days (19/02/03 to 21/02/03) because group attendance at an ATLS course leaves fewer doctors than the number of shifts each day (table 2 is available on line http://www.emjonline.com/supplemental). Table 3 shows the overall statistics of hours worked over the 24 hour period, for the entire six month rota.
Regeneration from a specified day
A special feature of the Rota-Maker Program is the ability to mark a day, change the definition (in a way that is compatible with the rota up to the marked day), and then partially regenerate the rota from the marked day on. This means that changes, say, to annual leave requirements can be incorporated during the period of the rota and the rota updated. In principle this allows the rota to be distributed a month at a time, incorporating the latest requests for annual leave, etc. Whenever the generator or optimiser is invoked, processing starts only at the marked day leaving the rota up to that day unchanged.
System requirements
The program runs under MSDOS on a standard PC without any special hardware requirements. As a minimum specification, a PC with a 286 microprocessor, a 256 Kb EGA video card and colour monitor, a standard mouse, and 4 Mb spare storage on the hard disk are required.
DISCUSSION
Various programs already exist that can be used to generate rotas for doctors and nurses, (Tangier Emergency Physician Scheduler (http://www.peakesoftware.com/peake/why/why.htm); Rota Master, IQUS, (http://www.iq.uk.com/RotaMaster.htm); GYMNASTE: a nurse planning package in CHIP, (http://www.cosytec.com/english/homepag2.htm); Duty Manager (http://www.onedimension.com/Duty%20Manager/); Excel spreadsheets for scheduling (http://www.shiftschedules.com/Products.htm); Internet-based physician scheduling software (http://www.docs2000.net); Cheng et al,4 and at least one other program, New Deal 2000 ((London Region and South East Regional Action Teams, 40 Eastbourne Terrace, Paddington, London W2 3QR, UK) exists that checks compliance of a given rota with the New Deal. However, as far as this author is aware, the Rota-Maker Program is the first to generate New Deal compliant rotas. Furthermore, the program is based on a precise mathematical formalisation3 of the complicated constraints of the New Deal. It is vitally important that programs that purport to generate compliant rotas or check the compliance of given rotas are based on a common mathematical specification of the New Deal; otherwise a “compliant” rota generated by one program may be rejected by another program that tests compliance!
Although the New Deal restricts the workload of junior doctors, it makes no reference to the sociability of the shifts or the number of weekends and bank holidays worked. Nor is there any reference to additional time off duty after a sequence of night shifts. Earlier versions of our program therefore ignored all these requirements and concentrated simply on trying to equalise the total number of hours worked by each doctor over the period of the rota. However, we found that the total number of night shifts varied considerably, and this was understandably a source of disquiet among the SHOs. It also caused undesirable variation in exposure to case mix, supervision, and teaching. Later versions of the program try in addition to balance the hours worked across the 24 hour period; table 3 shows that reasonable parity is obtained and our SHOs are happy with this. (Future versions of the program will also balance the number of weekends and bank holidays.) We have not had to specify any special recovery time after night shifts because the New Deal constraint of a minimum of eight hours off duty between shifts means that, at both the John Radcliffe Hospital and the Horton Hospital, a night shift may be followed by no other shift than another night shift; a day off duty therefore necessarily follows a sequence of night shifts. We did though increase the minimum time off from eight hours to nine hours. This was to avoid the possibility that at the change over between the two sites, a doctor who has just finished a night shift at the Horton Hospital at 08:00 hours is rostered to work a late shift at the John Radcliffe Hospital starting at 16:00 hours.
Use of our computer program has enormously simplified the task of rostering the SHOs while simultaneously guaranteeing New Deal compliance. Furthermore, SHOs now enjoy maximum freedom to take annual leave and other periods of absence at times to suit themselves. For example, with respect to the rota referred to in table 3, a total of 36 separate periods of annual leave were requested by the 15 SHOs. It was possible to grant 31 (86%) of these and move each of the other five by no more than one week each. A further 14 short periods of protected off duty were also requested; all of these were granted. Not only this, but we have at the same time made a very considerable saving on locums by optimising our allocation of resources. A copy of the program can be downloaded free of charge from the Oxford Radcliffe Hospitals NHS Trust web site (http://www.oxfordradcliffe.nhs.uk/rota).†
Acknowledgments
I thank Rick Pullinger and John Black for their support and encouragement in this work. Thanks to Grizelda George, Gill Rowe, Jan Todd, and the two referees for their helpful and constructive comments on earlier drafts of this paper.
Supplementary materials
Web-only Table
Files in this Data Supplement:
- [View PDF] - Table 3 Initial part of the Oxford Radcliffe Hospitals Emergency Departments SHO Rota (05/02/2003 - 06/08/2003). The initials have been changed to protect privacy
Linked Articles
- Primary Survey