Health boards and the Scottish Government failed to heed early warning signs of problems with managing patient waiting lists, the Auditor General for Scotland has told MSPs.
Audit Scotland was asked to scrutinise NHS boards' management of waiting lists and treatment time targets following the scandal at NHS Lothian in 2011.
The health board manipulated waiting time codes, marking patients unavailable for "social reasons" such as failing to get time off work or being on holiday.
Facing extra pressure to meet shorter 18-week guarantees, managers pressured staff to find ways around the system. This included marking patients as "unavailable" if they refused to travel to Northumberland in England.
Audit Scotland's report found problems across the country in the way patient waiting times targets are approached by health boards.
It also said its work was hampered by a lack of information and because of inadequately controlled management systems.
Auditor General Caroline Gardner told Holyrood's Public Audit Committee: "We think that the focus of attention during 2011 for both the Scottish Government and NHS boards was on whether the 18-week treatment target time was being achieved, rather than how it was being achieved.
"If NHS boards and the Government had been looking at the other information which was available, such as the increasing use of social unavailability codes, that should have raised some warning signs which would have merited further investigation."
Committee convener Iain Gray asked Ms Gardner: "Is it your view that there was information available to which either the NHS boards or the Scottish Government turned a blind eye, or they failed to notice?"
She replied: "It is true that information was available ... on the increase in use of social unavailability codes during that period. That information should have rung warning bells both for the health boards and for the Scottish Government.
"It wasn't acted upon and it could have helped to avoid some of the concerns that have been raised since then."
Conservative MSP Mary Scanlon said social unavailability codes leapt from 8% in 2008 to 30% in 2011.
This appears to have been missed by internal auditors, Audit Scotland, ISD Scotland, health boards, the Scottish Government and non-executive directors of health boards, she said.
"Why was it not picked up? Why did we have to depend on a whistleblower? Why were there six separate groups of people and organisations costing the taxpayer huge amounts of money and nobody noticed?"
Ms Gardner told the committee that Audit Scotland reported on the issue in 2010, recommending greater clarity about the use of the codes.
Guidance was produced for NHS board members.
"We think had our recommendations been implemented at that time, the system would have been tighter and clearer, both for patients to understand and for the NHS and Scottish government to manage," she said.