The New York Court of Appeals on Thursday heard arguments on whether doctors can face state homicide charges if the drugs they prescribe are used by a patient during a fatal overdose on the medication.

Dr. Stan XuHui Li, who practiced in Queens, is seeking to have his conviction on manslaughter charges for the overdose deaths of two of his patients overturned by New York's highest court.

Raymond Belair, of Belair & Evans in Manhattan, argued before the high court that Li couldn't have known that his patients would overdose. He also said the prescriptions were nonlethal if taken as directed.

"The medications that are involved in this homicide case were prescribed within regular therapeutic range, and which, if taken as prescribed, would never have caused death, and were incapable of causing death based on what my client, Dr. Lee, knew at the time," Belair said.

Li was convicted on charges of manslaughter—as well as 196 other charges—in 2014 over the deaths of two of his patients, Joseph Haeg and Nicholas Rappold.

Prosecutors from the New York City Office of the Special Narcotics Prosecutor had alleged that Li was essentially running what's known as a "pill mill," an office where the physician prescribes a disproportionate amount of addictive medications.

Li operated a pain management clinic in Flushing, Queens, for about seven years, from 2004 to his arrest on homicide charges in 2011. Prosecutors used the nature of the clinic's business to build their case against Li.

His clinic was only open one day a week, on the weekend, and didn't require appointments to be seen. Prosecutors said he saw as many as 90 patients in a single day and charged a base fee of $100 per visit. All payments were required to be made in cash.

Investigators from the Office of the Special Narcotics Prosecutor found that, over three years alone, Li had written more than 21,000 prescriptions for controlled substances. He charged patients more than the $100 base fee if they came to him before their prescription ran out.

The Manhattan District Attorney's Office is handling the appeal on behalf of the  Office of the Special Narcotics Prosecutor.

Vincent Rivellese, who argued before the Court of Appeals on Thursday for the Manhattan District Attorney's Office, said Li was driven to write those prescriptions by the money they would generate from patients who continued to come back to him for those drugs.

"It was always about money," Rivellese said. "He even had signs in his office about how noncompliant behavior would be treated."

That incentive drove Li to either ignore, or choose not to address, signs that his patients were dependent on drugs and seeking prescriptions from his clinic to fuel their addiction, prosecutors alleged.

More than half of Li's prescriptions between 2008 until his arrest in 2011 were for the highly addictive opioid drug oxycodone. More than a quarter of his prescriptions during that time were for Xanax, which is also addictive.

When both of those drugs are taken together, they can impair an individual's breathing. Experts who testified for the Office of the Special Narcotics Prosecutor said the combination could be fatal.

Li was charged with two counts of second-degree manslaughter for the deaths of Haeg and Rappold, and was also brought up on counts of reckless endangerment, criminal sale of a prescription, fraud and others.

After his conviction on most of the charges, including manslaughter, Li was handed a combined sentence of 10 to 20 years in prison. The manslaughter charges, alone, accounted for five to 15 years of that sentence.

Li's defense counsel contested arguments by the Office of the Special Narcotics Prosecutor that the doctor didn't consider the medical history, or actual pain experienced, by his patients before he chose to prescribe them opioids.

In the case of the two patients who overdosed on his prescriptions, Haeg and Rappold, Li physically examined both and wrote them prescriptions within the guidelines of the U.S. Food and Drug Administration, he said.

"I urge you to look at these records," Belair said. "He performs a physical examination on both of these patients."

Associate Judge Eugene Fahey appeared skeptical of Belair's argument that Li was operating his clinic without any knowledge that his patients could be dealing with addiction or using his service to obtain drugs without a medical need for them.

Fahey pointed to the fact that Li only accepted cash at the clinic, for example, and that he charged patients more if they returned before their previous prescription was scheduled to run out.

"There were just a series of things in the record that seemed to establish the requisite conscious intent in this case under legal sufficiency and connect it to both Rappold and Haeg," Fahey said.

Fahey later questioned Rivellese, though, about how much discretion his office viewed prosecutors to have in bringing criminal charges related to an overdose on opioids. He asked if the same standard used against Li could be used against a pharmacist filling prescriptions for addictive drugs, or even a drug distributor or manufacturer.

"People aren't stupid, they recognize there's a pattern here," Fahey said. "Are they then eligible for criminal charges?"

Rivellese responded that each case would rely on the underlying evidence against those individuals and entities, including whether they had knowledge that those drugs could have been misused by patients.

"You're going to have to be able to convince a jury beyond a reasonable doubt that this person knew about the risks," Rivellese said.

The Court of Appeals will likely hand down a decision on the matter next month, or in December.

READ MORE: