A number of so-called "bed blockers" are patients who lack the capacity to make decisions about their own care. Those involved admit there is an urgent need for legal clarification as their rights may be being breached if they are effectively held against their will.
The issue of delayed discharge –the term for what happens when patients no longer need hospital care, but cannot return home – has long been one of concern to the NHS.
Popularly known as bed blocking, it often happens because of problems in arranging suitable support in the community, or adaptations in a person's home to enable them to live independently.
The problem means beds in Scottish hospitals are occupied for around 200,000 days a year by patients who do not need to be there.
This can cause knock-on problems for other departments, including accident and emergency units, because they are unable to admit patients to beds which have not been vacated.
It also puts the health of vulnerable older patients at risk because of the risk of hospital-acquired infections – and the danger that they lose the skills that would allow them to live independently.
However some of the patients involved are those affected by dementia or other conditions which mean they are unable to express their wishes. In these cases, there is increasing concern that many are being effectively deprived of liberty while legal issues such as guardianship and power of attorney are determined.
According to old age psychiatry consultant Dr Stuart Ritchie, of Leverndale Hospital, only a small proportion of delayed discharge cases are caused by this problem. But they are an ever-increasing problem for the NHS and social workers because of the length of delays involved.
Speaking at a conference in Glasgow on the topic, Dr Ritchie said that 150 people had been delayed in the city's hospitals last year under so-called "code 9" delays. This covers situations governed by the adults with incapacity act.
Usually, they are waiting for someone to be granted power of attorney or legal guardianship, to enable a decision to be taken about where they are best to live or be cared for when they leave hospital.
Those numbers are small, but the bureaucracy involved means they have a major impact in terms of bed days, Dr Ritchie said. "The average delay last year was 167 days – that's more than five and a half months."
But that figure is an average. In the worst cases patients have been blocked in hospital for more than a year, Dr Ritchie pointed out: "Of those discharged under code 9 last year, the 20 longest delays spanned from 289 days to 554 days."
He added: "When an adult, often because of a disease such as dementia, becomes unable to understand what is happening and lacks the capacity to make choices, there is a legal process to protect the adult and make sure any decision made is in the best interests of the adult.
"However this can mean that when an adult in hospital is ready for discharge, there is a waiting period – which can stretch to many months – whilst legal processes are completed."
The delays alone are not the only problem. The issue is also causing major human rights concerns, which is why Glasgow City Council, NHS Greater Glasgow and Clyde and TC Young Solicitors held Why Am I Here? a joint summit conference on the topic.
If a patient is in hospital for no good medical reason, perhaps against their will, there are real legal issues raised about whether anyone can or should keep them there, even for their own safety.
"This is a deprivation of liberty for the adult. They have no-one appointed to speak on their behalf and there is no legal framework in place to help them," Dr Ritchie explains.
"There is no medical need for them to be in hospital and it is really not the best place for them.
"It is not to anyone's benefit to have patients awaiting guardianship delay their discharge from hospital and it is often to their disadvantage as they are exposed to infection and can become de-skilled."
The same can apply to people living in care homes and other residential care settings where decisions are delayed while the legal situation is established.
"Overall, there are thousands of patients and residents being potentially deprived of their liberty in this way," Dr Ritchie said.
Although there is no legal framework in place, attention has been drawn to the issue by cases south of the Border, particularly a case in which an autistic man who could not speak was detained against his will in a Surrey hospital because it was deemed in his best interests. Ultimately the European Court of Human Rights ruled in 2004 that his rights had been breached, and that "necessity" was not a good enough reason for medical staff to refuse to let him go home. The case led to the Deprivation of Liberty Safeguards (DoLS).
Dr Ritchie added: "In England the DoLS aims to protect people in care and in hospitals from being inappropriately deprived of their liberty. Scotland has no such procedure and patients can find themselves in hospital for long periods with no right of appeal while a guardianship order is being sought."
At the conference Dr Donald Lyons, chief executive of the Mental Welfare Commission, highlighted cases from the commission's files, including that of Bob, a patient with brain damage caused by alcohol abuse, who was admitted to hospital when a fire left him with burns and having suffered smoke inhalation.
Although he improved after several weeks, when he wanted to go home, staff persuaded him to stay while he was being assessed.
Initially this was valid, but then, because a decision was made that he could not go home, staff continued to tell him the white lie that he was still being assessed.
"Our view would be that this is de facto detention," Dr Lyons said. "While it remains true that he is being assessed, telling him he needs to stay is acceptable, but it is not acceptable to continue to rely on that to keep him in hospital."
Addressing such problems will not be easy. If every incapable patient in a hospital or nursing home is made subject to an official procedure, this could place a huge burden on social work and medical staff.
The Scottish Law Commission is currently reviewing the relevant legislation in Scotland.
Concerted action has cut the problem in Glasgow, but it is not going to go away. Quite the reverse, as Glasgow's assistant director of social care services Susanne Millar pointed out: "The number of people with dementia is expected to rise significantly in the years ahead," she said. "So it is essential we begin to address this issue now."