CHICAGO — Citing the state’s failure to comply with an agreement to improve conditions for thousands of prisoners, a federal judge on Wednesday ruled that the constitutional rights of mentally ill inmates have been violated by the Illinois Department of Corrections.

In an oral decision delivered during a telephone conference with lawyers for the state and mentally ill inmates, U.S. District Court Judge Michael Mihm ruled IDOC violated five major areas of a 2016 settlement agreement reached in a lawsuit filed on behalf of about 11,000 mentally ill inmates.

The judge said a written ruling calling for a preliminary injunction will be filed before a May 22 hearing to consider remedies to the state’s violations.

The five areas of deficiency are treatment planning, segregation, crisis care, psychotropic medication and general quality of mental health care.

A court-appointed monitor testified in December that a critical shortage of psychiatrists has created huge backlogs of psychiatric appointments for inmates.