The years-long legal battle over drug cases affected by the state drug lab scandal goes before Massachusetts' highest court on Wednesday.

The Supreme Judicial Court justices will consider whether to dismiss the thousands of cases involving drug tests done by former chemist Annie Dookhan, who was convicted on charges of falsifying tests.

Although Dookhan has already served her sentence for her 2013 conviction, the fight continues over what to do about the thousands of criminal cases in which she tested the drug evidence.

Matt Segal, legal director of the ACLU of Massachusetts, will argue before the high court that all of those cases should be dismissed.

"We know that the integrity of the justice system in Massachusetts is crumbling and we need the court to step in and help repair it," Segal said.

In May of this year, prosecutors put together what's considered an official list of cases affected by Dookhan's testing. That list contains 24,000 cases. Then they formally notified most of those on the list, which has resulted in about 200 people asking for new hearings. The ACLU and the state public defender's office analyzed the list and say most of the cases are for low-level drug crimes.

"We know that in 62 percent of the cases, the only drug conviction is for possession," Segal said. "Here in Massachusetts we are a state full of officials who will tell you we cannot prosecute our way out of the problem of drug abuse. The first step to not prosecuting your way out of this problem is to stop prosecuting your way out of this problem."

But prosecutors like Essex District Attorney Jonathan Blodgett say many of the cases involving so-called "Dookhan defendants" are not so simple and a blanket dismissal, or so-called "global resolution," could compromise public safety.

"We're not going forward on low-level drug cases, quite to the contrary," Blodgett said. "Those cases have been resolved. We're looking at people here who cause public safety risks to the community, and to do a global resolution frankly doesn't make sense."

Blodgett says the state and his office have effectively dealt with potentially tainted cases. He points to the two state investigations of the scandal and the special court sessions that reviewed thousands of criminal cases involving Dookhan's tests and released people from jail and dismissed cases.

"Hundreds if not thousands of cases, but hundreds of cases in this county alone have been dealt with and dismissed where appropriate," Blodgett said.

Wednesday's hearing is one of a handful the high court has held about how to deal with the cases affected by the drug lab scandal.

In a previous ruling, the SJC suggested that all Dookhan defendants are entitled to a presumption of egregious government misconduct. But in that same ruling, the court said a one-size-fits-all approach is not necessarily workable.

But this is the first SJC case to mention another tainted Massachusetts drug lab.

The court is being asked to consider the cases potentially tainted by former chemist Sonja Farak, who was arrested in 2013 for tampering with drug tests in the Amherst drug lab. She admitted to tampering with samples and personally using many of the drugs at the lab.

Defense attorney Luke Ryan, who's representing clients convicted based on Farak's tests, says the high court should take into account this second — potentially bigger — drug lab problem.

"During the time she was a drug lab chemist, she had access to about 60,000 samples," Ryan said. "We're not at a stage where we can say exactly how many defendants that translates to."

Prosecutors are expected to argue that Farak's cases are a separate issue and the high court should rule only on the cases affected by Dookhan.

A ruling from the SJC is expected within three months.