Stephen Malcolm MacPhee was sentenced in provincial court Monday. (CBC)

A judge has ruled that a hospital, not a jail cell, is the best place for a man who broke into a Charlottetown woman's home and crawled into bed with her.

Stephen Malcolm MacPhee, 43, was found not criminally responsible in court Monday.

In the middle of the night on July 13, he went into the home of a 72-year-old woman who had hired him to paint the outside of her house. He got into bed with the sleeping woman and began kissing her.

She woke up, ordered him out and called police. MacPhee was arrested a few weeks later.

Judge John Douglas based his ruling on a psychiatric report that was presented during the trial. It said MacPhee has symptoms of schizophrenia and is a heavy drinker. It also said he hears voices and suffers delusions.

Crown Prosecutor Valerie Moore said a long hospital stay is the best solution for both MacPhee and the community. She said he needs to be monitored and treated.

MacPhee was living in a tent under the West River bridge at the time of his arrest.

It's now up to P.E.I.'s criminal review board, which includes a panel of judges and doctors – to decide his treatment. They will also determine how long MacPhee will stay in custody.