CHICAGO (Reuters) - Chicago police on Tuesday were seeking a motive for a shooting rampage outside and inside a hospital late Monday that left four people dead, including the gunman, a physician who was his former girlfriend and a police officer, officials said.

Nov 19, 2018; Chicago, IL, USA; A general view of the crime scene at Mercy Hospital and Medial Center in Chicago, Illinois. Mandatory Credit: Quinn Harris-USA TODAY Sports

The gunman, Juan Lopez, 32, was the former boyfriend of Dr. Tamara O’Neal, 38, who he shot and killed outside Mercy Hospital on Monday, Officer Jose Jara of the Chicago Police Department said.

Chicago Police Superintendent Eddie Johnson on Monday described that first killing as an act of domestic violence.

“There’s no doubt in my mind that all of those officers who responded were heroes and they saved a lot of lives because we just don’t know how much damage he (the gunman) was prepared to do,” Johnson said.

After killing O’Neal, Lopez fired at arriving police officers with a handgun then entered the hospital and exchanged gunfire for several minutes with officers who followed him, Johnson said.

Lopez also died but it was not immediately clear if he shot himself or was struck by a police officer’s bullet.

Officer Samuel Jimenez, who joined the Chicago police force last year, died during the gunfight, officials said. Jimenez, 28, was married with children and was the second city officer killed on duty this year.

O’Neal had worked as a resident and emergency room physician at Mercy Hospital for about two years and was heavily involved in her church, the Chicago Tribune reported.

The newspaper cited hospital employees as saying O’Neal was Lopez’s former girlfriend. One witness said Lopez was harassing O’Neal before the attack.

“I knew her, trained with her, saved lives with her and tonight, tried to save her life,” John Purakal a doctor at the University of Chicago Medicine medical school and health system, wrote on Twitter.

Doctors and patients fled the hospital during the attack.

Pharmacy assistant Dayna Less, 24, was shot and killed as she left an elevator, Johnson said. Another officer was spared injury when a bullet lodged itself in his gun holster.

In a separate incident on Tuesday, a Chicago police officer was shot after a traffic stop but hit in his protective vest and will make a full recovery, Johnson told a news conference. The suspected shooter was in critical condition after police returned fire, he said.

In another shooting on Monday in Denver, one person died and four were wounded.