A man was shot in the chest by a police officer after he attempted to "slash and stab" another officer on the head, a court has heard.
Noel David Quigley, of Celandine Court in Londonderry, was charged with the attempted murder of a police officer following an incident at his home.
The 42-year-old appeared before Derry Magistrates' Court via videolink.
He spoke only to confirm his name and that he could hear the court.
A police officer told the court that around 10.45pm on 17 April, the defendant called emergency services saying he was attempting to kill himself.
Police went to Quigley's home and found him in the living room, sitting on a chair with a knife in each hand.
The court was told that when police went inside his property, he attempted to cut his own throat.
Police intervened and tried to stop him by using irritant spray.
However, after that failed Quigley allegedly lunged at police officers with knives in both hands.
The accused was warned to drop the knives, however, he kept moving forward and began to lash out, slashing and stabbing about the head of a police officer, according to the PSNI.
Another officer intervened and shot Quigley in the arm.
A defence solicitor told the court that the bullet entered Quigley's chest and came out the back of his body, breaking three of his ribs.
He was rushed to the Royal Victoria Hospital in Belfast for treatment.
Quigley was arrested on 19 April while in ICU, and was released from hospital on 25 April and taken to custody.
The court heard that the police officer suffered puncture wounds to his right arm and cuts to his head.
A police officer objected to bail because of the seriousness of the offence and the risk of harm Quigley poses to himself and the public.
The court also heard that he has previously contacted police claiming he was going to kill himself.
"I believe he has told the custody sergeant he has problems with alcoholism, and looking through history these things happen when he has taken alcohol," she said.
"We are concerned if he takes alcohol if released, the likelihood he will reoffend is quite serious."
However, a defence solicitor disputed the injuries suffered by the police officer.
He said he understood the officer has suffered linear abrasions as opposed to puncture wounds.
The solicitor also said that the allegations of "slashing" were never put to his client during interview.
"I am concerned about the tenor in which this bail application is being presented," the solicitor added.
"The kitchen sink has been thrown at this man in terms of the charge and now the objections. We have grave concerns the reason for that is that a bullet went through him whenever police were called to assist him.
"He had attempted to kill himself in advance of police being called and he said that he called police so his decomposing body would not be found some time later.
"The firearm went through his arm, his chest, enters his lung and comes out the back of his body, breaking three of his ribs. He is arrested when he is in ICU and his family are not notified, but a member of the medical staff called them."
The judge adjourned the case until Wednesday and ordered a medical report about the officer's injuries.
Quigley was remanded in custody until Wednesday.
Video report by UTV correspondent Mark McFadden: