The health secretary, John Reid, must have known trouble was brewing when he took the decision last month to send in the "evil weasels".
The departmental hit squad - more politely known as the recovery and support unit of the NHS modernisation agency - earned the nickname during previous forays to sort out hospitals that were struggling to cope with sudden surges in winter admissions. This time the threat was altogether more predictable.
In May 2000 the EU adopted a directive to limit the working hours of junior doctors - house officers and registrars progressing up the training ladder, but not yet qualified to operate without supervision, as consultants.
By 2009 their maximum working week must be cut to 48 hours, in line with other employees. As a first step, a limit of 58 hours has to be introduced and the deadline for doing so is Sunday.
The "evil weasels" were mobilised after the employers' body, the NHS Confederation, sounded an alarm that too many hospitals were ill prepared for the change.
After a confidential survey in May, it said 16% of chief executives did not expect to comply with the directive in time. It warned ministers: "In some hospitals and specialties the figures simply do not add up. Some trusts will not be able to continue to provide safe clinical care in certain specialties if they seek to introduce compliant rotas. These organisations would be put into the unacceptable position of having to choose between compromising patient care or failing to comply with the directive."
The confederation was not against the legislation from Brussels and saw huge benefits for patients being treated by less exhausted staff. But it knew the huge extent of the organisational change needed to comply.
The traditional model for running a hospital used an A-team of consultants and juniors during the day and a B-team of juniors at night. The juniors worked on rotas that mixed day and night work. They used to work about 100 hours a week, although 80 has been more common in recent years.
If the hospital was quiet at night, they might snatch a few hours sleep on hospital premises, ready to be summoned by bleep if their services were needed.
It was an 11-year endurance test that had to be passed to achieve consultant status, a rite of passage that put the convenience of administrators ahead of patient welfare. There were also financial benefits because long hours could put the juniors into a higher pay band.
Health ministers knew the system provided a poor service for patients and started shortening the working week before Brussels intervened. They set guidelines for a 56-hour maximum week that were supposed to be met last year.
At first sight this UK initiative might look more ambitious than the EU's 58-hour limit coming in on Sunday. In reality, the European directive is much more challenging.
First, it is a legal obligation, whereas the British measure was a target that most trusts failed to meet.
Second, it requires the juniors to take rest breaks during a shift and sets a maximum of eight hours' work in every 24 hours for night workers.
Third, it was toughened unexpectedly by two recent judgments from the European court redefining the meaning of rest. The SiMAP judgment - named after the Spanish doctors' trade union that brought the case - said doctors who are on call on hospital premises must be deemed to be working, even if they are asleep.
The Jaeger judgment ruled that compensatory rest - a period off duty to make up for lost rest time - has to be taken immediately, before the next duty period begins. Even the British Medical Association thought that one unduly generous to doctors and preposterously difficult for NHS trusts to deliver.
With the employers warning about a threat to patient safety in some areas if the directive was imposed and the BMA threatening legal action if it was not, the Guardian decided to establish the extent of the problem.
We contacted all the acute and specialist hospital trusts in England and put eight questions to gauge their preparedness. Seventy-five of the 173 trusts replied over the course of the past week, providing more comprehensive information than the BMA or government have at their disposal. Several trusts said they could not answer because the key people were on holiday, which may have been rash in the final week before the directive applied.
How many are in difficulty?
We asked each trust whether it was ready to fully implement the directive by the Sunday deadline. Nine said they were not and another four said they were almost ready or working towards implementation. Taking those to be not fully complying in time, this immediately put 13 hospitals in the danger zone of illegality. This was 17.3%, similar to the confederation's result.
The nine outright non-compliers were: Barking, Havering and Redbridge; Brighton and Sussex; Great Ormond Street; Guy's and St Thomas'; Milton Keynes General; Scarborough; Sheffield Children's; Whittington, north London; and Trafford Healthcare.
Looking more closely at the results, it emerged that many of those saying they would comply could not be sure of doing so. Among the 40 anticipating difficulties (53.3%), some had not yet recruited enough staff.
For example, Gloucestershire hospital said: "We should achieve full compliance, but it is fragile in some specialties. There are two main problem areas: paediatrics because the service is on two sites and has a heavy emergency load; and orthopaedics because it is also on two sites, one of which was due to close before August, but this has been delayed until December and so temporary extra staff are needed."
Worcestershire acute hospitals said its difficulty was recruiting juniors in obstetrics and paediatrics because of "a national shortage of doctors". The most common areas of recruitment difficulty were in paediatrics (nine), anaesthetics (six), obstetrics and gynaecology (three) and ear, nose and throat (two).
Extra staff
Some trusts have taken on more staff to get ready for the change. The Royal Free in north London said it took on 92 junior doctors, but that included preparation for the earlier UK guidelines as well as the Brussels directive. This would add £4.8m to costs, about 20% of the medical payroll.
Maidstone and Tunbridge Wells took on 70 juniors over the past two years and North Staffordshire solved the problem by recruiting 15 doctors and 22 nurses.
Benefit for patients
Most of the trusts were enthusiastic about the benefits of complying. Airedale said: "Junior doctors are no longer working excessive hours. This must be beneficial for patient care." Royal Liverpool said: "Response times to night calls are quicker... The initiative has raised morale not only among doctors but also nursing staff."
Compensatory rest
There was much confusion among managers about the implications of the SiMAP and Jaeger judgments. Winchester and Eastleigh said it would meet its obligations under the directive, but added: "We will not be able to comply with Jaeger; it is impossible." Compliance with the directive requires compliance with Jaeger.
Many trusts are relying on legal opinions that have been commissioned from learned counsel. West Middlesex hospital said: "We will be abiding by the London Shrine guidance on compensatory rest." This was a reference to a network of NHS human resources chiefs in the capital whose lawyers say there is a get-out from the obligation to take compensatory rest before the start of the next shift.
