(Reuters) – A lawsuit on behalf of Arizona inmates that accuses the state of neglecting their health needs and misusing solitary confinement can proceed as a class-action case, potentially affecting conditions for all the state’s 30,000 prisoners, a federal appeals court ruled on Thursday.

The 3-0 decision by a panel of the San Francisco-based 9th U.S. Circuit Court of Appeals upheld an order by a federal district judge who granted class-action status last year to all Arizona prisoners in the case.

The lawsuit filed in 2012 by the American Civil Liberties Union and the California-based Prison Law Office accuses the state of violating the Eighth Amendment to the U.S. Constitution prohibiting cruel and unusual punishment in the way it treats prisoners.

The groups are seeking an increase in health services for inmates and a reform of solitary confinement to allow for improved nutrition and regular outdoor exercise.

Attorneys for the state argued before the appeals court that allegations of inadequate care were specific to the cases of individual inmates, not to all inmates.

Judge Stephen Reinhardt wrote in the 63-page opinion that attorneys for the prisoners presented credible allegations the state failed to hire enough medical staff, would not provide dental care except for tooth extraction, deprived suicidal inmates access to basic mental healthcare and failed inmates in other ways.

Since the suit was filed, 23 inmates had died whose lives could have been spared with adequate medical care, said Don Specter, director of the Prison Law Office.

Arizona also differs from most other states by not screening out mentally ill prisoners from solitary confinement, which often aggravates their conditions, he said.

“It’s a very punitive system,” Specter said. “The criminal justice system of the state as a whole is very punitive and in that sense it is part of the culture, and the conditions in the prisons are stark to say the least.”

The Arizona Department of Corrections said in a statement its officials disagreed with the decision and that the ruling did not constitute a judgment on the veracity of the accusations brought by the ACLU and the Prison Law Office.

“The allegations are not accurate, and the Department of Corrections looks forward to vigorously challenging them and presenting our case at trial,” the statement said.

The ruling came a day after a federal lawsuit was allowed to move forward that contends California’s practice of keeping prisoners in near-solitary confinement for years was unconstitutional.

(The story is corrected to show lawsuit brought by ACLU and the Prison Law Office, fixes Specter’s affiliation)

(Reporting by Alex Dobuzinskis in Los Angeles; Editing by Peter Cooney)