Brian O'Hagan, 22, whose address was given as Maghaberry prison, abused members of the hospital's A&E department as they tried to treat him for head injuries.
The incident happened hours after O'Hagan was caught stealing a bottle of alcohol from a supermarket.
The judge said that his behaviour in the hospital was appalling.
A prosecution solicitor said his behaviour upset other patients in the hospital.
The judge warned that neither he nor other judges would tolerate what he called the loutish behaviour by people in the hospital.
A man who verbally abused staff at Altnagelvin Hospital in Londonderry has been jailed for 10 months.