Image copyright Weibo Image caption Dr Li posted this picture of himself from a hospital bed on 31 January - a day before he was diagnosed with coronavirus

Dr Li Wenliang, who was hailed a hero for raising the alarm about the coronavirus in the early days of the outbreak, has died of the infection.

His death was confirmed by the Wuhan hospital where he worked and was being treated, following conflicting reports about his condition on state media.

Dr Li, 34, tried to send a message to fellow medics about the outbreak at the end of December. Three days later police paid him a visit and told him to stop. He returned to work and caught the virus from a patient. He had been in hospital for at least three weeks.

He posted his story from his hospital bed last month on social media site Weibo.

"Hello everyone, this is Li Wenliang, an ophthalmologist at Wuhan Central Hospital," the post begins.

It was a stunning insight into the botched response by local authorities in Wuhan in the early weeks of the coronavirus outbreak.

Dr Li was working at the centre of the outbreak in December when he noticed seven cases of a virus that he thought looked like Sars - the virus that led to a global epidemic in 2003. The cases were thought to come from the Huanan Seafood market in Wuhan and the patients were in quarantine in his hospital.

On 30 December he sent a message to fellow doctors in a chat group warning them about the outbreak and advising they wear protective clothing to avoid infection.

What Dr Li didn't know then was that the disease that had been discovered was an entirely new coronavirus.

Image copyright Weibo Image caption After falling sick, Dr Li said on Weibo that he wondered why authorities were still saying no medical staff had been infected

Four days later he was summoned to the Public Security Bureau where he was told to sign a letter. In the letter he was accused of "making false comments" that had "severely disturbed the social order".

"We solemnly warn you: If you keep being stubborn, with such impertinence, and continue this illegal activity, you will be brought to justice - is that understood?" Underneath in Dr Li's handwriting is written: "Yes, I do."

He was one of eight people who police said were being investigated for "spreading rumours".

At the end of January, Dr Li published a copy of the letter on Weibo and explained what had happened. In the meantime, local authorities had apologised to him but that apology came too late.

For the first few weeks of January officials in Wuhan were insisting that only those who came into contact with infected animals could catch the virus. No guidance was issued to protect doctors.

But just a week after his visit from the police, Dr Li was treating a woman with glaucoma. He didn't know that she had been infected with the new coronavirus.

Image copyright Li Wenliang Image caption "We hope you can calm down and reflect on your behaviour," the letter police told him to sign says

In his Weibo post he describes how on 10 January he started coughing, the next day he had a fever and two days later he was in hospital. His parents also fell ill and were taken to hospital.

It was 10 days later - on 20 January - that China declared the outbreak an emergency.

Dr Li says he was tested several times for coronavirus, all of them came back negative.

Image copyright Weibo Image caption Dr Li Wenliang was accused of spreading rumours

On 30 January he posted again: "Today nucleic acid testing came back with a positive result, the dust has settled, finally diagnosed."

He punctuated the short post with an emoji of a dog with its eyes rolled back, tongue hanging out.

Not surprisingly the post received thousands of comments and words of support.

"Dr Li Wenliang is a hero," one user said, worrying about what his story says about their country. "In the future, doctors will be more afraid to issue early warnings when they find signs of infectious diseases."

"A safer public health environment… requires tens of millions of Li Wenliang."