A psychiatric nurse at a Pembroke Dock hospital found himself confronted by a patient armed with a handgun and wearing a bullet belt, a high court judge heard on Wednesday.
Richard Appleyard pointed the gun at the head of nurse Frank Caddy and pulled the trigger.
But the safety catch was still on and the gun failed to fire.
The incident at the Haven Way day hospital led to commendations from the judge for three members of staff who acted "over and above the call of duty".
Appleyard, aged 37, admitted possessing a firearm intending to cause fear of violence. He was ordered to be detained indefinitely under the Mental Health Act.
Creighton Harvey, prosecuting, told Swansea crown court Appleyard called at the centre on January 4th and spoke to Paula Tynon, a community health support worker.
Later Miss Tynon found Appleyard going through a filing cabinet in a bid to gain access to his notes, saying he did not agree with his diagnosis.
Miss Tynon noticed he was wearing a bullet belt and agreed to call in Mr Caddy, who had dealt with Appleyard for ten years.
Appleyard suddenly pulled out a handgun, which turned out to be an air pistol but in the shape of .45 handgun.
He told Mr Caddy "I am sick of this" and pointed the gun at his head. Mr Caddy heard a clicking noise as Appleyard pulled the trigger.
But although there was a pellet ready to be fired the safety catch had not been released.
Mr Caddy ran from the room and called police.
But he then returned to ask Appleyard to put down the gun in case he was shot by armed officers.
Appleyard put the weapon on a table.
Community nurse Mrs Elaine Jones entered the room and took the gun away.
Police raided Appleyard's home in Devon Drive and found a suicide note under his pillow.
His barrister, Frank Phillips, said Appleyard had no real intention of hurting anyone, least of all Mr Caddy.
Psychiatrist Dr Roger Thomas said he suffered from a paranoid psychosis.
The Judge, Mr Justice Nigel Davis, sent Appleyard to a semi secure mental unit for a period to be determined with his "best wishes" for recovery.
"This was a crime of the gravest seriousness.
The victim must have thought he would die.
"But I think it would be wholly wrong to send you to prison. You need help," he added.
Comments: Our rules
We want our comments to be a lively and valuable part of our community - a place where readers can debate and engage with the most important local issues. The ability to comment on our stories is a privilege, not a right, however, and that privilege may be withdrawn if it is abused or misused.
Please report any comments that break our rules.
Read the rules hereComments are closed on this article