Police restrained a man at Coleraine’s Causeway Hospital who had been reported as “kicking off” in an ambulance, the town’s Magistrates Court was told.
Heroin was then discovered on John Monroe (36), of Lever Park in Portstewart, during the incident last August.
Earlier, a member of the public had reported that a person – Monroe – was lying unconscious in the Castlerock Road area of Coleraine.
It was established he was a known drug user and paramedics tried to help him but he was “kicking off” in the ambulance and when police restrained him they found heroin.
The defendant had to be admitted to an Intensive Care Unit.
He was charged with possessing Class A drugs.
The court was told of another incident in February last year when Monroe stole a pair of sunglasses worth £100 from an optician.
The optician gave chase and challenged the defendant who threw the glasses under a car, damaging them.
Monroe denied the theft but was picked out of an identity line-up.
He was charged with theft and criminal damage.
A defence solicitor said Monroe, who appeared via video link from Maghaberry Prison, was a sentenced prisoner not due to be released until April or May this year.
For the new offences, Monroe was given a three months jail term which is to be served consecutive to his existing sentence.