U.S. District Judge Jon Levy ruled that the Maine Department of Health and Human Services waived its right to challenge the June 2013 decision because it didn’t file a timely appeal of an inspection that found a number of problems at the state-run psychiatric hospital, including overcrowding and the use of correctional officers to oversee patients.

“The state had ample opportunity to challenge the … decision but failed to do so,” Levy wrote. “The consequences flowing from that failure may be harsh, but they are not, in the end, surprising given the regulatory scheme set out in the regulations.”

The loss of certification was expected to cost the state about $20 million.

Maine has continued drawing down federal funds as it challenged the decision.

Maine Department of Health and Human Services Commissioner Mary Mayhew said the decision was extremely disappointing and criticized the federal government for imposing “arcane regulations” on the hospital.

“This kind of ‘regulatory scheme,’ as Judge Levy called it, is the reason people are so frustrated with government. It’s time for the feds to stop letting arcane regulations get between mentally ill Mainers and the resources they need, and start acting as a partner with the LePage Administration in maintaining access to these critical hospital services,” she said in a statement.

The inspections found problems including the use of stun guns and handcuffs. Later inspections found more problems including medication errors and paperwork problems.