The frontal chest x-ray shows a thick-walled cavity in the left upper lobe with surrounding consolidation, which turned out to be due to a fungal infection.
A useful mnemonic for causes of lung cavity is CAVITY (reference: radiopaedia)
C: cancer
A: autoimmune (e.g. Wegener’s granulomatosis, rheumatoid nodule)
V: vascular (e.g. pulmonary embolism)
I: infection (i.e. bacterial/fungal)
T: trauma (e.g. pneumotocele)
Y: youth associated (e.g. pulmonary sequestration)