NEW YORK (AP) — A mentally ill man who randomly attacked three people with a hammer and was later shot after he struck a New York City police officer with the tool in midtown Manhattan was charged Wednesday with assault and criminal possession of a weapon, authorities said.

David Baril, was arraigned from his hospital bed via video link and did not enter a plea. He answered "yes" when asked if he understood the charges. His attorney, present at the hospital where Baril remained in serious condition, requested a psychiatric evaluation. Police have said he has a history of paranoia and schizophrenia.

His attorney said in an earlier statement that at times Baril had been able to live a stable life, pursuing a college degree.

"Hopefully, this tragedy will highlight the failure of the system to provide the services that Mr. Baril so obviously needed and ensure that more resources are dedicated to helping people with mental health needs," said his attorney, Colby Dillon.

Prosecutors said Baril, 30, is charged "in three separate and distinct unprovoked attacks" on May 11. A 34-year-old woman was bashed in the head with a hammer in a park. A few hours later, a 28-year-old woman in Union Square noticed a man looking at her, and he then pulled a hammer out of a bag and hit her in the head, authorities said. Another attack happened about 10 minutes later when a 33-year-old was struck from behind.

A 20-year-old was also attacked with a hammer in a different part of the city earlier in the day. Police said Baril was responsible but prosecutors have not charged him in that attack.

Detectives tracked the suspect to a subway station where he used his metro card. Officers obtained an image of him and, using facial recognition technology, matched a photo with one on file at the department. His photo was circulated among officers heading out on patrol.

Last Wednesday, two officers were responding to an unrelated assault blocks from Madison Square Garden in midtown Manhattan when they noticed Baril on the street, wearing a hood and a mask, police said. They approached him and he started swinging. Surveillance video captured the man hitting Officer Lauren O'Rourke about three times before her partner, Geraldo Casaigne, fires four shots. Both O'Rourke and Baril fall to the ground. Authorities said it was the same hammer used in the other attacks.

Baril's next court date is June 25.