BATH, Maine — A Camden man awaiting trial for manslaughter after shooting to death his girlfriend while he showed a handgun to a prospective buyer has been approved to enter residential treatment for opioid addiction, partially funded by the state.

Dylan Grubbs, 24, is charged with the Nov. 16, 2015, shooting death of Chelsea Jones, 22, of Thomaston, whom police said was sitting in Grubbs’ SUV in a Bath supermarket parking lot when he shot her in the head while showing a 9 mm Taurus handgun to a prospective buyer.

Police said at the time that the gun apparently discharged accidentally.

Jones remained in critical condition at Maine Medical Center until she died Nov. 19.

Grubbs was indicted by the Sagadahoc County grand jury in February on charges of manslaughter and felony possession of a firearm by a prohibited person, the latter charge because police initially believed Grubbs had been convicted in 2006 of criminal threatening with a dangerous weapon. That charge later was dismissed when attorneys discovered a clerical error, his attorney, David Paris, said.

Grubbs pleaded not guilty to the manslaughter charge, which alleges that Grubbs was recklessly or criminally negligent in causing Jones’ death.

A toxicology report filed with the court after the shooting showed Grubbs had buprenorphine, a medication used to treat opioid addiction, in his blood at the time.

In March 2016, Grubbs was arrested in Rockland and charged with operating under the influence, three counts of possession of drugs and violating conditions of release. According to court documents, Grubbs was in possession of a few Klonopin and oxycodone pills, for which he reportedly had no prescriptions, and Suboxone — also used to treat opioid addiction — for which he had an expired prescription.

Following the arrest, the Maine Department of Health and Human Services filed paperwork in Knox County Superior Court alleging that Grubbs’ two minor children “are in jeopardy to their health and welfare and in need of protective custody due to Mr. Grubbs’ serious and currently untreated substance abuse issues … volatile behavior, and unsafe decision-making which most recently resulted in the death of his children’s mother.”

Grubbs had been held without bail at Two Bridges Regional Jail since his March arrest, but on June 3, Bath attorney David Paris, who represents Grubbs, requested the court amend his bail conditions to allow Grubbs to attend a 45-day residential treatment program for substance abuse, chemical dependency and other disorders, according to court documents.

Paris wrote in his motion that the prosecution did not object to the motion and that the treatment was likely to begin July 25. On Thursday, citing confidentiality, Paris declined to say whether Grubbs was being treated at the residential center.

The Maine Department of Health and Human Services agreed to pay $495 to cover the portion of Grubbs’ room, board and treatment that would not be covered by other state funding for people who don’t have health insurance, according to a June 16 letter from Roxanne Zwaga of the Office of Child and Family Services.

A phone call to Assistant Attorney General Leanne Zainea, who is prosecuting the case with Sagadahoc County Deputy District Attorney Jonathan Liberman, was not returned Thursday.

On May 18, Paris filed a motion to dismiss based on an assertion that “the firearm has been shown to be defective in its dismantling process, according to the firearms examiner.”

Grubbs is tentatively scheduled for trial in January 2017.