Two in five patients have experienced delays when leaving hospital, with almost half of them waiting for up to two hours, according to a new survey.

More than 17,000 people took part in the fifth national inpatient experience survey, which found overall satisfaction with Scotland's health service has risen to record levels.

A total of 90% of patients rated their care and treatment as good or excellent, the highest rating since the survey began in 2010.

READ MORE: Design for new Edinburgh children's hospital is 'seriously flawed', claims architect

Improvements were also noted in A&E care, ward cleanliness and the general hospital environment while satisfaction with hospital staff remained high at 91%.

However, the lowest rated area was departure from hospital, with 78% of patients having a positive experience.

The report said: "One potential explanation for the low relative rating may come from the finding that delays appear to be a problem for people: two in five (40%) felt that they were delayed on the day that they left hospital, with 47% experiencing delays of up to two hours."

READ MORE: Design for new Edinburgh children's hospital is 'seriously flawed', claims architect

The most common reason for delay was getting medication (56%).

One in six (17%) said they stayed in hospital longer than expected waiting for care and support to be organised, up 3%.

The survey also found one in five people (20%) felt that they had experienced harm or injury such as infections, bed sores, reactions to medications or falls.

READ MORE: Design for new Edinburgh children's hospital is 'seriously flawed', claims architect

Health Secretary Shona Robison said: "It is encouraging to see that satisfaction in Scotland's hospitals continues to rise against a backdrop of increasing patient numbers.

"It's especially pleasing to see even more people rating their overall care as good or excellent, including in areas like accident and emergency.

"These increasing levels of satisfaction show that our decisions to put the patient at the heart of everything we do in our NHS, and to increase workforce numbers to their current record levels, are delivering good results.

"We are determined to continue to push up standards. This is why we are providing financial support to all health and social care partnerships in the form of £90 million over three years, specifically to reduce delays in patients leaving hospital, plus an additional £250 million for investment in social care in 2016/17."