Flu Shot on Shabbos

Given the fact that vaccines are so important not just for one's own health but for the public's health as well, can a shot be administered on Shabbos? The Shulchan Aruch discusses preparing a defense against a possible enemy attack. Does this apply to vaccination?