The Scottish Government needs to urgently improve workforce planning for the NHS if the health service is to have sufficient staff to meet future demands, public spending watchdogs have warned.
Audit Scotland said that despite increasing numbers of staff - the NHS employed the equivalent of 139,431 full-time workers at the end of March 2017 - there are still "major issues to be addressed".
Opposition politicians and organisations representing doctors and nurses have repeatedly highlighted pressures many health workers can face.
Audit Scotland has now warned there may not be enough staff to meet future demand.
Its report said: " Processes for determining training numbers risk not training enough doctors, nurses and midwives with the right skills for the future.
"Medical recruitment numbers are based on replacing current numbers rather than looking at the impact of changing demand."
Tory health spokesman Miles Briggs branded the research " deeply concerning".
Labour's Anas Sarwar added: "This is an absolutely damning report from Audit Scotland.
"It reinforces our warnings that the SNP has presided over a workforce crisis in our NHS, leaving staff over-worked, under-valued and under-resourced."
Spending on NHS staff amounted to £6.5 billion in 2016-17, accounting for 57% of day-to-day running costs.
In the period between 2011-12 and 2016-17, the cost of bringing in agency staff increased by 107%, going from £82.8 million to £171.4 million.
Audit Scotland said: "There are urgent workforce challenges facing the NHS caused by factors including an ageing population, an ageing workforce and recruitment difficulties."
One in three staff in NHS Scotland are aged 50 or above, the report said, adding "upcoming retirements may increase vacancy levels in parts of the NHS where the age profile of the staff is older".
Audit Scotland said: " The Scottish Government has not fully considered the risk that retirement from the NHS in coming years may lead to increased vacancies.
"Certain consultant specialties and certain areas in Scotland are relying on an ageing consultant workforce who may retire in the next five years.
"Similarly, over a third of the nursing and midwifery workforce is over 50 and the number of newly-qualified nurses in Scotland available to enter the workforce to replace them fell by 15% between 2013-14 and 2014-15, and a further 7% in the following year."
While the number of staff in the NHS is at a record high, the watchdog said the Scottish Government and health boards "have not planned their NHS workforce effectively for the long-term".
Major reforms are taking place to allow more people to be cared for at home or in their local community but Audit Scotland said funding for this "does not clearly identify associated workforce costs".
The report continued: "The Scottish Government expects demand for health and social care to rise but it has not yet adequately projected how this will impact on the skills and workforce numbers needed to meet this demand.
"It has not looked at long-term scenarios for future patient demand when considering recruitment decisions and future workforce costs."
Caroline Gardner, Auditor General for Scotland, said: "Thousands of people work hard in Scotland's NHS to deliver vital public services every day but there are signs that the health service is under stress and that staff face increasing workload pressures.
"The Scottish Government and NHS boards recognise the challenges but urgently need to improve their understanding of future demand, staff projections and associated costs, and set out in detail how they plan to create a workforce that can meet the long-term health needs of the population."
Theresa Fyffe, director of the Royal College of Nursing Scotland (RCN), said: " The RCN has warned for some time that the Scottish Government has failed to future-proof NHS Scotland's workforce.
"Today's report echoes that sentiment and impresses upon the Scottish Government, NHS boards and integration authorities the urgency with which workforce planning now needs to be addressed.
"Audit Scotland has hit the nail on the head - for too long plans have been restricted by what is affordable and achievable with the staff available - rather than focusing on strategic, long-term planning to meet demand.
"The result is that Scotland has too few nursing staff in post and too few nurses being trained.
Mr Briggs said: " Time and again we have seen warnings about long-term workforce planning and these figures show the situation is only getting worse.
"Agency costs are soaring and the percentage of vacancies in consultancy and nursing posts have more than doubled.
"More worryingly, we are not seeing enough new nurses being trained to keep up with an increasingly elderly workforce.
" The growing strain within NHS departments is clear and it is the SNP's totally shambolic approach to workforce planning over the last decade that is to blame."
Mr Sarwar added: " Staff morale is at rock bottom in the health service, with staff reporting there simply aren't enough of them to do the job properly.
"As Audit Scotland confirms, this is part of the legacy left by Nicola Sturgeon, who as health secretary slashed the number of training places for nurses and midwives.
"We now have a Health Secretary, Shona Robison, who is out of her depth and out of ideas.
"That is why our health service is in desperate need for a meaningful workforce plan."
Scottish Labour has launched its own NHS workforce commission, which is headed by Dr Miles Mack, chairman of the Royal College of General Practitioners.
Liberal Democrat MSP Alex Cole-Hamilton said: "This report highlights the dangers of our NHS running on a skeleton crew and how little forward planning has been done to avoid it.
"It takes ten years to train a consultant but the Scottish Government appears to have little to no idea how many of these staff, or any other, it will need in the years ahead.
"This damning audit rightly takes a dim view of Nicola Sturgeon and her health secretary's attempts to avert this crisis.
"The Scottish Government ignored warning after warning that staffing isn't keeping up with demand."
Dr Peter Bennie, chair of the British Medical Association (BMA) Scotland, said: " This latest report from Audit Scotland highlights what we have been saying for some time - there are serious workforce challenges facing the health service in Scotland which must be tackled by the Scottish Government as a matter of urgency.
"Rising vacancy levels, a lack of effective workforce planning and an ageing staff profile is putting a significant burden on the existing workforce already dealing with the stress of a rising workload which is not being adequately resourced.
"Ongoing uncertainties for NHS Scotland staff from EU countries over Brexit compound the problems.
"The report recognises long-term workforce planning has not been effective.
"It also highlights responsibility for NHS workforce planning is confused by multiple programmes and levels of response which makes it more difficult to ensure that the right mix of staff will be able to respond to the needs of a changing service where the impetus is to deliver a shift towards more community-based care."
Health Secretary Shona Robison said: " As this report acknowledges, NHS Scotland's staffing levels are at a record high, with spending on staff having increased by 11% since 2011-12.
"We're committed to not only having the right number of staff, but also to ensure that we have the mix of skills in the right places.
"The first part of our National Health and Social Care Workforce Plan, published last month, sets out how we will recruit, develop and retain the flexible, multidisciplinary workforce we need.
"It shows how we'll improve national, regional and local workforce planning. We are also committed to enshrining safe and effective staffing for our NHS in law.
"Ensuring effective workforce planning not only has to account for changes in the nature of the demands being placed on our health and care services, but also for the challenges that are presented by external factors like the impact of Brexit on Scotland's ability to attract and retain workers from across Europe.
"NHS boards are already working with partners to develop regional delivery plans setting out how they will deliver services over the next 15 to 20 years."
Copyright (c) Press Association Ltd. 2017, All Rights Reserved. Picture (c) Peter Byrne / PA Wire.