A nurse caught having sex with the remains of a woman he'd provided care for was sentenced to two years in state prison, the Los Angeles County District Attorney's office announced on July 3.

Alejandro Razo, 62, was arrested at the Sherman Oaks Hospital in January 2013, after another nurse discovered him "with his pants down, having sexual contact with the woman's corpse," according to a statement from the DA.

DNA evidence was used to convict Razo, who's had a 20-year career in health, the DA's office said.

Razo was assigned to care for the 82-year-old woman on Jan. 20, 2013, the day she later died from natural causes. He was then tasked with preparing her body for the mortuary. He was alone when a colleague found him having sex with the deceased patient.

Superior Court Judge Thomas Rubinson ordered Razo to attend sex offender meetings and undergo weekly psychological counseling during the final 180 days of his sentence. Razo must also stay away from Sherman Oaks Hospital.