On the morning of April 28, a 52-year-old homeless man named Darryl Warthen was found beaten to death inside his cell at the Philadelphia Industrial Correctional Center (PICC). His cellmate, who had arrived the day before to await trial for aggravated assault, was charged with his murder.

With their defendant now deceased, prosecutors dropped their charges of burglary and trespassing against Warthen. And his murder was promptly written off as one more violent act in a system plagued by them. Except that Warthen had been declared mentally unfit to stand trial five times since his 2012 arrest, and on the day he was murdered he was supposed to be 20 miles away from PICC receiving state-mandated psychiatric treatment. He had been waiting for a transfer there since September 2014.

The final listing on his docket sheet, dated six days before his death, states unequivocally: “Defendant is incompetent but in need of treatment.”

According to the American Civil Liberties Union, hundreds of inmates in the same predicament continue to languish in deplorable conditions in jails across the state. In October the ACLU filed a class action suit on behalf of 11 of them who say that the state is trampling their civil rights by denying them the psychiatric treatment they've been mandated.

The plaintiffs—who are all in pretrial detention in jails across the state—have been deemed mentally unfit to stand trial for their crimes and ordered by a court to undergo “competency restoration treatment” in a medical facility. But Pennsylvania doesn’t have enough beds for them in its network of state hospitals so many are forced to wait months or even years for a transfer.

The ACLU say this violates their Fourteenth Amendment right to due process, as well as the Americans With Disabilities and Rehabilitation Acts.

The 66-page complaint paints a bleak picture of mental health care across Pennsylvania’s roughly 70 local jails, where on any given day approximately 10,000 inmates with psychiatric problems are being held in conditions tailor-bound to make them even sicker. The inmates named in the suit are unique in that they have yet to be found guilty of a crime, but they are too ill to stand trial and too poor to secure bail.

The lead plaintiff in the case—a homeless man identified by the pseudonym J.H.—is a schizophrenic who has been locked up for nearly a year for stealing candy from a Dollar Store. He’s being held at the Philadelphia Detention Center, the only one of Philadelphia’s six jails with a dedicated unit for inpatient-level psychiatric care.

However, treatment there is limited to medication management, which mental health experts with experience in the system told The Daily Beast is frequently deployed more to control disruptive behavior than to treat a set of symptoms. Not surprisingly J.H. has deteriorated considerably during his confinement. His attorneys say that over 11 months he has gone from a genial and cooperative inmate to “visibly agitated, hostile and unwilling or unable to engage in conversation.”

A second plaintiff, a woman in her 20s with a history of severe mental illness, was declared incompetent in November 2014 and referred to a state hospital. Over the 12 months she’s been waiting for a bed she has stopped talking to her lawyers and is now reportedly borderline catatonic. According to the complaint, she sat through one June interview “sucking her thumb, refusing to make contact and staring blankly.”

Defendants include Theodore Dallas, secretary of the Pennsylvania Department of Human Services, and the state’s two designated Regional Forensic Psychiatric Units approved to accept jail inmates. One of these is in Norristown—just outside Philadelphia—and the other, Torrance State Hospital, is nearly 300 miles away in western Pennsylvania.

Dallas previously served as Maryland’s secretary of Human Resources under Martin O’Malley, where he oversaw a review of the state's foster care system following the deaths of two children under its supervision. He took over the leadership of DHS in January as a member of incoming governor Tom Wolf’s newly appointed cabinet.

A spokesperson for DHS said that since that time the department has been working with the courts and other stakeholders to rectify the “longstanding issues regarding forensic services.” She did not offer any details on the specifics of those efforts, and would not comment on the litigation.

The ACLU’s legal director for Pennsylvania, Witold Walczak, has his own take on the agency’s progress to date.

“The solutions being advanced by DHS are like pissing in the ocean; they ain’t gonna raise the water level,” he told The Daily Beast. “We’re not quite sure how the problem got so out of control, but out of control it is now.”

For what it’s worth, Dallas and his staff are being called to the carpet for a problem they had no hand in creating. As in most states, Pennsylvania’s jails are facing an epidemic of untreated mental illness.

Some experts blame the epidemic of untreated mental illness in America’s jails on the widespread closure of state mental hospitals since the 1970s. At the start of 2015, just 1,503 psychiatric patients were under state care—a decline of 50 percent from 2000.

The commonwealth has closed 11 state hospitals since 1980, transitioning thousands of patients with severe mental illness from often bleak institutional settings back into the community.

Even before the lights were turned off in these facilities leading mental health officials were already questioning the long-term viability of deinstitutionalization. And most criminal justice experts now draw a link between hospital closures and prison growth.

Jeff Deeney, a Philadelphia social worker who worked with dual diagnosis clients during more than six years at Philadelphia’s Drug Court, says that among other things states failed to establish adequate community care services for newly released patients.

But while advocates are willing to acknowledge the negative consequences of deinstitutionalization, few if any would consider going back to the old way of doing things.

“I support efforts to move people with severe mental illnesses out of jails and into more appropriate settings as fast as possible,” said Deeney. “But institutional settings for people with severe mental health disorders have a poor track record in terms of human-rights abuses. I’m not confident a newly erected institutional system would fare any better.”

The state operates six state mental hospitals. Until 2010, three of them were approved for the treatment of patients in criminal detention. That year, then-Gov. Ed Rendell ordered the closure of the RFPU at Warren State Hospital in northwest Pennsylvania and consolidated it with Torrance. Officials said the closure would save the state $2.3 million in annual costs.

The hospital’s board of trustees and several state lawmakers objected to the plan, citing prison overcrowding and rising mental illness in the correctional system.

State Rep. Kathy Rapp—a Republican whose district includes the hospital—accused the Rendell administration of “refusing to fulfill one of its most essential functions of protecting individuals who cannot take care of themselves,” and warned that the proposal would only succeed in “shifting costs” from the mental health system to an already overburdened criminal justice system.

The RFPU at Warren State housed fewer than 30 inmates when it was closed, and some additional beds were added to Torrance to account for the consolidation. Even so, Pennsylvania's two forensic units have the capacity to treat just 236 patients.

This includes not only inmates awaiting trial, but several dozen who have been convicted of their crimes. According to Walczak it also includes inmates who are considered too sick to ever stand trial but have yet to be transferred to a community-based treatment setting as the law requires.

According to the ACLU, about 200 jail inmates deemed unfit to stand trial are waiting for one of these beds to open up.

Pennsylvania is not alone in this regard. On Wednesday advocates in Colorado filed suit accusing state health officials of violating a 2012 settlement with the federal government requiring transfer to inpatient competency treatment within 28 days of a court order.

But the commonwealth is by far the worst offender, with average wait times of several months. In Philadelphia—which has the longest delays in the country—inmates regularly wait more than a year for a bed to open up.

One of these inmates is Rudolph Keitt, whose case I reported on this year for The Daily Beast.

Keitt was shot by police in May after allegedly driving his vehicle into four police officers. Witnesses say he was suffering a seizure at the time, and Keitt reportedly has a history of both physical and mental illness. Keitt was charged with attempted murder and is being held on $2 million bail.

His attorney, Brian Mildenberg, says Keitt has been declared unfit to stand trial at three competency hearings since his arrest. An order has been issued for his transfer to Norristown State Hospital, but Mildenberg says he was told it could be up to two years before a bed opens up.

In the meantime Keitt remains housed with the general population at Curran-Fromhold Correctional Facility in Philadelphia, which lacks the resources to provide inpatient levels of psychiatric care.