A city prison inmate awaiting trial for three unrelated murders attacked a correctional officer and a nurse at Albert Einstein Medical Center, where he'd been taken for a medical procedure, in a botched escape attempt yesterday.

The inmate, Justin Mackie, 20, was tackled by hospital security officers and remains under guard at Einstein for unspecified reasons.

The correctional officer remains hospitalized with head injuries. The nurse was treated and released, Einstein spokesman Damien Woods said.

Prisons spokeswoman Shawn Hawes said Mackie, who was jailed at the Curran-Fromhold Correctional Facility, w

Mackie, who was jailed at the Curran-Fromhold Correctional Facility, now is charged with aggravated assault, escape, terroristic threats, disarming a law enforcement officer and related offenses in the attack. A judge set his bail at $1 million today.

The incident began when Mackie, who had been in a hospital bed with hands and feet shackled, asked to use the bathroom, said Lorenzo North, president of Local 159, the union representing the city's 1,800 correctional officers.

Mackie somehow had secured a handcuff key, emerged from the commode unrestrained and headbutted and beat a correctional officer, North and Hawes said. He then attacked a nurse as he tried to escape, North said. A second correctional officer who had escorted Mackie to the hospital was away on a lunch break, he added.

Hawes said inmates typically must be accompanied by two guards at all times when off prison grounds. And correctional officers usually stand guard outside a bathroom door left ajar when inmates need the toilet, she added.

Investigators will probe whether procedures were followed and how Mackie nabbed the handcuff key, Hawes said.

North fumed that the violence could have been avoided if prisons officials ensured Mackie's escorts were more veteran officers. The injured officer, Thomas Doman, had worked in the prisons for just a year, Hawes confirmed. The other officer had just a few years under his belt, North added.

"If he went out with two veteran officers, he would have never gone to the bathroom in the first place. He would have had to use the bedpan," said North, a 24-year prisons veteran.

But Hawes disagreed Mackie's hospital trip required veteran officers.

"All of our officers are trained in all duties, and escorting inmates off-grounds is part of the duties that they're trained in," Hawes said.

Mackie has been behind bars since July 2013, when he and his stepbrother Tevin Hammond, 21, got in a shootout with Philadelphia police and FBI agents in East Mount Airy.

Authorities had swarmed the house after learning the brothers, who were wanted for several homicides, shootings and armed robberies, were inside. Hammond died in the shootout; Mackie was shot five times but survived.

Mackie is accused of three homicides:

* Gunning down Carlos Barnes, 51, on July 9, 2013, after going to Barnes' home to buy a gun. He allegedly instead shot Barnes in the face and chest and stole the firearm.

* Shooting Tyrone Hayes, 20, to death July 15, 2013, in the courtyard of the Norman Blumberg Apartments, at 23rd and Jefferson streets in North Philly.

* Shooting his friend Otif Wright, 20, to death on July 18, 2013, because he believed Wright had set his brother up for a robbery.

He's also accused of robbing and shooting cabdriver and jazz singer William Carney III in June 2013. Carney survived the shooting after he drove himself to the hospital.