There is no known way to prevent atypical pneumonia. However, avoiding people who have the infection can help reduce your risk.
Infants, and persons in poor health, especially those with weakened immune systems due to HIV, organ transplants, or other conditions should avoid contact with people who have mycoplasma pneumonia.
Baum SG. Mycoplasma pneumoniae and atypical pneumonia. In: Mandell GL, Bennett JE, Dolin R, eds. Principles and Practice of Infectious Diseases. 7th ed. Philadelphia, Pa: Elsevier Churchill Livingstone; 2009:chap 184.
Mandell LA, Wunderink RG, Anzueto A, et al. Infectious Diseases Society of America/American Thoracic Society consensus guidelines on the management of community-acquired pneumonia in adults. Clin Infect Dis. 2007;44:S27-S72.