The president of the High Court has warned the Child and Family Agency it must find a place within 48 hours for a teenage boy with autism, ADHD and conduct disorder.
The 14 year old boy has been in a hospital paediatric unit since last August.
Despite a psychiatric report warning the boy's violent behaviour posed a risk to children and others in the unit, this information "astonishingly" did not lead to the CFA doing anything about finding an alternative placement until very recently, Mr Justice Peter Kelly said.
The situation should have been addressed months ago and the CFA's endeavours now appear to have been triggered by an emergency court application by the hospital last Friday, court orders to address the hospital's concerns and publicity surrounding those, he said.
An alternative place has yet to be sourced but must be found by this Friday, the judge warned.
He would not permit any further detention of the boy in the hospital beyond Friday because it was "doing him no good" and involved "substantial risk".
It was only with the "greatest reluctance" he was permitting the boy's detention in the unit in the interim as the alternative was the streets.
The paediatric unit agreed last August to take the boy who was sent there on an emergency basis by the Child and Adolescent Mental Health Services over suicidal ideation and alcohol and substance misuse.
He could not go home because he had regularly assaulted his parents and siblings who were in such fear of him they regularly barricaded themselves into locked rooms of their home.
A psychiatric report in August described the boy at significant risk of violent behaviour, "up to and including homicidal acts", if returned home or to the community.
The paediatric unit was unsuitable for him, it was inevitable he would become increasingly frustrated there and other children and staff would be at risk from him, it also stated.
Today Mr Justice Kelly was told by a witness for the CFA she had not seen that report until this week.
She said the CFA had not identified any child protection concerns in relation to the parents care of the boy but continued providing family supports from last July.
A social worker has now been allocated to the boy, she added.
She agreed the paediatric unit is totally inappropriate for the boy and said efforts are underway to find an appropriate placement.
She was "hopeful" one could be found but could not say in what timeframe.
The hospital's escalating concerns about the boy's behaviour there, including his going onto the hospital roof last week, led to it obtaining emergency court orders last Friday permitting it to detain him.
The detention orders were sought against a background of the boy leaving the hospital and returning there under the influence of drinks and drugs.
His parents were in court when the matter returned before the judge on Wednesday and his mother said she had told the CFA last August about "having to lock ourselves away from him".
She also believed the psychiatric report was provided to the CFA in August.
She and her husband love their son "more than words can say", have struggled for some time "to get him the help he so desperately needs" and are very grateful to those who had sought to help, she said.
Their concern was, unless he gets the appropriate help, something will happen to him or someone else.
Her son lacked the ability to understand what is going on in his head and "can get violent quickly without noticeable warning".
Patricia Hill, for the HSE and hospital, said the court orders appeared to have lead to improved behaviour on the boy's part and he was also benefitting from being taken by a day care service on outings, including walks and the cinema.
David Leahy, for the boy's court appointed guardian, said the boy was polite and well-behaved when the guardian met him and had asked for more hours with the day service. He will now get eight instead of six hours.