MARTINEZ — A Contra Costa Judge had harsh words — and a $17,400 bill — for the California Department of State Hospitals, saying the agency was violating the due process rights of dozens of severely mentally ill county jail inmates.

At the center of the issue is a 2016 state appellate court ruling that gave the hospital a 60-day deadline to hospitalize Contra Costa jail inmates with unresolved criminal charges who have been found mentally incompetent to stand trial.

When a Contra Costa criminal defendant is found mentally incompetent, he or she is supposed to be housed at Napa State Hospital where doctors will attempt to “restore competency,” usually through medication. But Contra Costa defense attorneys say they routinely see defendants stay in jail for weeks after the 60-day deadline has come and gone.

“The worst case I’ve ever seen was over 100 days, I think around 115,” Deputy Public Defender Stephanie Regular said.

In July, more than a year after the deadline was issued, Judge Clare Maier found the state agency was routinely violating it. As she issued $17,400 in fines — $100 for every day a group of 29 inmates has had to stay in jail past the deadline — she blasted the agency, saying its staff have been aware of the problem for three years.

“Having violated the standing order, the DSH also violated the constitutional due process right of those defendants found incompetent to stand trial by failing to provide them timely competency restoration services,” Maier wrote in her ruling.

Maier’s order only applies to Contra Costa, but the lack of available hospital beds for defendants who have been found mentally incompetent to stand trial is a statewide issue. Data released to Bay Area News Group last year showed more than 450 California jail inmates were awaiting hospital beds as of June 2016. The average inmate stayed in jail for 56 days after they’d been found incompetent.

Kenna Cook, a spokeswoman for the DSH, said the agency has been addressing the problem, adding 600 hospital beds since the 2012-13 fiscal year. Of those, around 400 are in hospitals and around 200 are in jail facilities.

“Additionally, the fiscal year 2017-18 state budget includes funding for additional beds for the treatment of (inmates who are incompetent to stand trial), including expanding DSH’s jail-based restoration of competency programs and establishing a new 60-bed Admission, Evaluation, and Stabilization center for (those) patients in the Kern County Jail,” Cook said.

But Regular — who handles cases for almost all of the county’s mentally incompetent inmates — said she hasn’t seen the situation improve over the past 12 months. She and colleagues are planning to bring before Maier another 17 mentally incompetent inmates who have stayed in jail past 60 days.

“From my point of view..I don’t think that (the fine) is enough,” Regular said. “Especially since they’re still violating the order, it seems like it’s not sending the message that it needed to send.”