A health board has been ordered to apologise to the family of an elderly patient with end-stage kidney failure who was released from hospital in error with the wrong medication and left in a discharge lounge "all day" in their nightwear.

An investigation found there were missed opportunities to diagnose the patient's deteriorating condition after they were admitted to hospital three times over a short period of time with severe stomach and back pain.

It was only after the third visit that the patient was diagnosed with kidney failure and discharged to their care home to receive palliative care but the diagnosis was delayed because abnormal blood results were not followed up. The patient died a short time later.

An inquiry by the Scottish Public Services Ombudsman upheld all aspects of a complaint by the patient's family against NHS Ayrshire and Arran.

READ MORE: Covid vaccine ruled out as cause of 'severe hepatitis' cases in 13 Scots children

They said an earlier diagnosis could have prolonged their relative's life expectancy as treatment could have commenced sooner.

The inquiry found the patient was left waiting in the hospital's discharge lounge in their nightwear all day after hospital staff failed to properly communicate the arrangements to the family.

They were returned to their nursing home in a taxi instead of an ambulance which the family said was "extremely distressing and undignified" and unacceptable given their age and deteriorating condition.

The Ombudsman said there were missed opportunities to diagnose the patient's kidney failure.

On the third admission, there was a delay in the clinical consideration of abnormal blood results, and in recognising the severity of their condition and the discharge was "poorly managed" given the patient's age, fragility and poor health.

READ MORE: Fewer newborns removed from parents in Scotland than England 'raises questions'

"These failings included [patient] A's lengthy wait in the discharge lounge, and A's transportation in their nightwear via taxi.

"We further noted from the board's own investigation that A had been discharged with the wrong discharge letter and medication, and that there had been a failure to communicate A's discharge arrangements to the family."

NHS Ayrshire and Arran has been ordered to apologise to the family for failing to diagnose A's kidney failure and infection, for discharging the patient from hospital when they were not clinically fit, and for the poor management of A's discharge arrangements.

The board must also take steps to ensure that abnormal blood results in a patient's clinical records are followed up appropriately and "ensure that relevant staff have appropriately reflected on the complex nature of this case."

A spokeswoman for NHS Ayrshire and Arran said: "We sincere apologise to the family of A that we did not meet the high standards of care we strive for.

"In addition to our formal apology to the family of A, I can advise that we have fully accepted all the recommendations in the Scottish Public Services Ombudsman (SPSO) report.

"We have addressed the issues highlighted and made the appropriate changes, to ensure test results in a patient's clinical records are followed up appropriately and discharge arrangements are carefully assessed.

"In order to ensure learning across the organisation, we will share the findings from the report with staff, in particular with those responsible for the operational delivery of the service and with our clinical governance teams."