A man who worked as a nurse pleaded guilty Wednesday to replacing opioids intended for hospice and memory care patients with lookalike allergy pills at a health care facility in Fitchburg, according to prosecutors and court records.

Andrew Milgrim, 41, of Gardner, was charged with one count of tampering with a consumer product in federal court in Worcester, according to the office of Leah B. Foley, US Attorney for Massachusetts.

Milgrim is expected to be sentenced Jan. 7, 2027, Foley’s office said in a statement.

Court records show Milgrim also worked as an LPN in California, New Hampshire, Vermont and Virginia. He was terminated from the facilities in Vermont and Virginia.

“Both dismissals involved allegations of tampering and/or diverting patients’ narcotics,” court papers state.

None of the facilities were identified.

In Fitchburg, beginning around September 2024, Milgrim took oxycodone from patients in the skilled nursing and dementia care unit of a healthcare facility in Fitchburg, the statement said.

The 5mg pills were intended to be dispensed to certain patients “as needed,” but Milgrim began taking them himself, Foley’s office said.

He would replace the medication with an allergy drug, Loratadine, which looks similar to the 5mg Oxycodone pills, prosecutors said.

He continued to take the pills until around February 2025, according to the statement.

Around January 2025, he also took 10mg oxycodone pills from an elderly patient in the memory care unit, and replaced those pills with a thyroid medication, Levothyroxine, prosecutors said.

Milgrim was charged in July.

Tampering with a consumer product can result in a sentence of up to 10 years in prison, up to three years of supervised release and may include a fine up to $250,000, according to Foley’s statement.

Madyline Swearing can be reached at madyline.swearing@globe.com.