A state appellate court lamented the treatment of a child with severe developmental disabilities who was left for more than five weeks in a hospital emergency room with nowhere else to go, but said in a decision Thursday that only state lawmakers or an agency can prevent the same thing from happening in the future.

The Appellate Division, Third Department wrote in the decision that there were no grounds on which it could change how the state handles those cases, but didn’t excuse what happened.