Hi, did you find out what was wrong? I have had the same thing, the rattling in the chest followed by cough and coughing up stuff. I have really bad riht rib pain as well, nightmare as I have been to the doctors over four times and once was in so much pain I went to A and E. I'm actually up now because of the rib. The cough otherwise is annoying but doesnt hurt.
Ok weird you are the first person that has like laid out your symptoms and they are just like mine. I also find that when I wake up coughing at night, I am in a sheet dreanching night sweat. I dont have health insurance so I cannot really afford to go to the doctor for this. Mine has been going on slightly longer for about 7 months