Barry Kirsopp pleaded guilty to a total of four offences including spitting at a nurse at Borders General Hospital during the corona virus pandemic.
The offences all happened at a house in Abbey Road, Coldstream, in a police van en-route to hospital and at Borders General Hospital on Christmas Day.
Kirsopp pleaded guilty to a breach of the peace at as house in Abbey Road by refusing to exit the property when requested to do so by armed officers and uniformed police officers,
throwing a television through a smashed window, waving an imitation firearm and hammer and running at police officers with a metal pole . He also struck his head against the inside of a police van while making derogatory comments towards police officers.
At Borders General Hospital, Kirsopp pleaded guilty to punching a female police constable on the body, kicking a male constable on the body and spitting on the male nurse.
Depute fiscal Miriam Clark explained that at around 7p.m. on December 25, Police Scotland received intelligence that the accused was in possession of a gun at the property in
She said specialist officers attended the incident along with two fire engines, two ambulance, two British Gas engineers and four police negotiators.
The fiscal said a kitchen light was on in the property and armed police shouted for Barry Kirsopp to come to the front door but this was to no avail and lasted 25 minutes.
The court heard that Kirsopp started making threats to officers saying he was going to get a knife and stab them and their dogs.
As the incident escalated he smashed a window and threw out a television and a cooking pot onto the path below.
At 8.13p.m. Kirsopp appeared at a window and appeared to be holding a black hand gun which later turned out to be a disguised plastic water pistol. he was also threatening to turn the gas on and cut himself.
Kirsopp later appeared outside the property after asking for a cigarette and after charging police officers with a metal pole was eventually tasered by officers.
He was taken to Borders General Hospital to get the taser removed where he continued to be aggressive towards police officers and carried out the three assaults.
Defence lawyer Mat Patrick said his client had been on a drug programme at the time of the incident but on the morning of the offence he found out his methadone had been stolen.
He added:"He took valium and with the alcohol he had been drinking that combination had some effect on him.
"What he can remember about it was that he had an overwhelming desire to kill himself.
"He put himself at great risk and was very lucky to have got out of this.
"It was appalling behaviour towards the police officers and medical staff member. He had a meltdown."
Mr Patrick said his client was already serving a 750 day prison sentence for another matter and his earlier release date is September 15 this year.
Sheriff Peter Paterson said he would have imposed a jail sentence of 28 months which he reduced to 21 months due to the guilty plea.
He noted Kirsopp had already served the equivalent of 10 months jail while on remand.
Sheriff Paterson said the 11 months prison sentence would start in September at the end of Kirsopp's current jail term.