A brain-damaged homeless man is in prison when he should not be, and cannot be discharged because he would be at risk, in what the High Court President has called a staggering and truly awful situation.

The man was described as having filthy feet and a rare nail disease not seen in decades.

His bed linen in the high dependency unit of Mountjoy Prison, was appallingly filthy and had not been changed in months, the court heard.

Mr Justice Peter Kelly said it was "staggering" that the man was in the prison's high dependency unit for a year, despite persistent reports that he was of unsound mind and needed residential care.

The judge said a situation where a senior Health Service Executive official had cancelled the man's residential care plan due to "resource issues" and it was proposed to discharge him to homeless services should not exist in a civilised state.

A court-appointed medical visitor had reported that the man had "absolutely filthy" feet and hugely overgrown and curled toe nails - a rare nail disease, known as ram's horn, which has not been seen in Ireland in decades.

The man, who is in his 50s and has been homeless for some time, was otherwise doing well in the unit, but the doctor reported that his feet had never been washed during his year-long remand, his bed linen had not been changed in months and was "appallingly filthy".

The medical visitor reported that the man was under the care of consultant psychiatrists, doctors, nurses and wardens.

The doctor was told that wardens had a policy not to invade a prisoner's personal space, but he considered that policy should not be applied to vulnerable adults.

The judge said he shared the doctor's concern that there must be many more such prisoners who are deficient in their ability to maintain their personal care.

He said the situation should be addressed at the highest level and directed papers should be served on the Minister for Justice, HSE, the Irish Prison Service and the Director of Public Prosecutions.

The court heard the man's solicitor, Danica Kinane, of M.E. Hanahoe solicitors had written to the High Court as a last resort to have the man made a ward of court.

She alleged the HSE was well aware of the man's chronic medical and social history and was avoiding its duty to him.

He has a history of mental disorder but does not meet the legal criteria for admission to a psychiatric unit.

The man was arrested in November last year and charged with assaulting two security guards who approached him when sheltering in the women's toilets of a Dublin shopping centre.

He was assessed by a doctor just after his arrest as being unfit to plead.

Not in public interest to release him, court told

The court heard he defecated in a garda cell, covered himself with excrement and was charged the following day and remanded by the district court to Mountjoy's High Dependency Unit.

Ms Kinane said the HSE decided last April to have the man made a ward, but had made no application so far.

She said the man had effectively served any prison sentence that might have been imposed on him if he had been fit to plead.

She said no one, including the district court judges, believed it was in his or the public's interest to release him back onto the street.

Senior Counsel Felix McEnroy for the man said the matter was "shocking to the conscience".

He said it was so bad that Ms Kinane's very experienced firm had sought wardship for the first time in its history.

He said the DPP's office had known since March there could never be a trial, as the man was not fit to plead.

A plan by the Central Mental Hospital for the man to move to a care unit was cancelled by an administrative officer at the highest level in the HSE for resource reasons, Mr McEnroy said.

He said another doctor had prepared a report with a view to the man accessing homeless services.

He said this would be an impossibility for someone in this man's condition.

Mr McEnroy said the man was in prison when he should not be, he could not be discharged because he would be at risk and the situation was utterly unacceptable.

The matter will be back before the court next week.

In a statement this morning, the Minister for Justice Charlie Flanagan said: "When I became aware of this disturbing case I sought an urgent report from the Prison Service.

"I await that.

"I have also spoken with the Governor of Mountjoy.

"I intend to discuss the case as a matter of urgency with my cabinet colleague Simon Harris.

"I am constrained in what I can say further as the matter is subject to court proceedings."