Marcell,
IMO that was not a worm. It was phlegm from your bronchial tubes and that looks exactly like a worm. Your lungs are congested and phlegm from your bronchial tubes comes out looking exactly like little worms. I've been there and done that with severe lung congestion from Asthma.
You must inspect it to see if it tries to move around. If it doesn't move around, then it is simply phlegm from your bronchial tubes.