Welsh hospitals could end up breaking the law unless radical changes are made in the way they work, according to a new report.
Health teams are being told to find new ways of working
By August 2009 junior doctors will be allowed to work only 48 hours a week - far less than they can at the moment.
The assembly government is warning the law will only be met by restructuring, and this at a time when there are already plans to centralise services.
Chief medical officer Tony Jewell said it was "absolutely critical".
"We need to work differently - hospitals need to work together - teams need to work differently to be compliant.
"We've known about the European Working Time Directive for several years now .
"We're also changing the way doctors are trained and that is affecting the way services are organised, " said Dr Jewell.
The assembly government's evaluation report, called Designed to Comply, found that based on current working patterns fewer than one in three Welsh hospitals will meet the 48-hour target.
After August 2009, any hospital trust breeching the hours rule for junior doctors will face a fine of £5,000 a day - or even prison for the chief executive.
Currently no Welsh hospital meets the target, but Dr Jewell said that was "not unusual".
"We would expect there to be a gap but this is the challenge we are facing. We need to plan now to be able to deliver the 2009 targets."
Junior doctors will work far less hours in 2009 than they do now
Dr Jewell said a lot more work needed to be done. He said the government "expects hospitals to work together and junior doctor training to be compliant."
But he also warned the changes would need to be made using existing resources.
"What we're talking about is people - existing staff - working differently so there isn't a presumption of more staff," said the chief medical officer.
"The key message here is we're looking for networking between hospitals and our junior doctors being trained in a way which is compliant with the law."
"If you break the law you break the law and there are consequences - we're trying to show hospitals what needs to be done by 2009."