Causes, symptoms, treatment, preventive measures, and prognosis differ depending on whether the infection is bacterial, mycobacterial, viral, fungal, or parasitic; whether it is acquired in the community or hospital; whether it occurs in a patient treated with mechanical ventilation; and whether it develops in a patient who is immunocompetent or immunocompromised.