PORTLAND, Ore. (AP) — A 27-year-old man who stabbed a Portland resident 17 times after the resident asked him not to camp in the neighborhood has been sentenced to treatment at the Oregon State Hospital.

Todd Schneider could be under the supervision of state mental health officials at the state psychiatric hospital or while living in the community for up to 20 years, The Oregonian/OregonLive reported. He said he was diagnosed with paranoid schizophrenia, according to court papers.

The stabbing happened on May 27, 2018, when Kasey Lebechuck, 65, saw Schneider setting up camp in a field within blocks of Lebechuck’s home, according to a probable cause affidavit.

Schneider responded by saying he needed to grab his cellphone, the affidavit said. Instead, Schneider grabbed a hunting knife and attacked Lebechuck, stabbing him first in the forehead between the eyes, authorities said.

Police found Lebechuck lying in the doorway of a nearby home — where he stumbled for help and the people inside the home saw him through their doorbell camera. He survived the attack.

Schneider told a psychologist who interviewed him after his arrest that he thought people were following him. He acknowledged that some of his perceptions could be shaped by his schizophrenia.

On March 30, Multnomah County Circuit Judge Christopher Ramras found Schneider guilty except for insanity on the charges of attempted murder, assault and unlawful use of a weapon.