Just a thought, could this pain actually be coming from the spine? I was thinking maybe if you could take deep breaths while in different positions maybe this could tell you something? (for example I get middle back pain that is worsened by taking a deep breath, and I had an MRI of my thoracic spine that showed a herniated disc
The pain may be pleurisy and the green phlegm suggests that you have acute bacterial bronchitis. You should have a culture of the phlegm and may well need another antibiotic, shown to be effective against the bacterium causing your bronchitis. The green phlegm could also be a sign of cystic fibrosis (CF) with or without a disease called bronchiectasis.
If the green phlegm persists despite yet another course of an antibiotic, you should definitely see a lung specialist.