The prohibition against taking medication on Shabbat applies only to medications that cure an ailment of some sort; it does not apply to pills or foods which people ingest to enhance their health or certain bodily faculties. For example, Hacham Ovadia Yosef ruled that it is permissible to take vitamins on Shabbat, since these are taken not for healing purposes, but rather to strengthen the body. And so pregnant women may take prenatal vitamins and similar pills on Shabbat.
Likewise, Hacham Ovadia permits taking sleeping pills on Shabbat. Since these are taken not to cure an ailment, but to help one fall asleep, they are not included in the prohibition against medication on Shabbat. By the same token, it is permissible to take a caffeine pill to be more alert on Shabbat, since this pill is not taken for healing purposes. This applies as well to birth control pills (assuming, of course, that the woman received approval from a competent rabbi to use birth control); since they are not taken to cure an ailment, they may be taken on Shabbat.
Another example of this Halacha is a pill that people take after becoming inebriated. The Shulhan Aruch rules that inebriation is not treated by Halacha as an illness, and thus measures to "cure" inebriation are allowed on Shabbat. In the times of the Shulhan Aruch, people would apply oil to their hands and feet to regain sobriety, and the Shulhan Aruch rules that this is allowed on Shabbat. Nowadays, then, it would be permissible to take pills that are available that help one regain sobriety after becoming intoxicated.
Similarly, some Hazanim (cantors) swallow a raw egg to enhance their voice. This, too, is permissible, since it is not done to cure any sort of ailment.
Halacha forbids taking vomit-inducing drugs on Shabbat to cure bloating. (It should be noted that the ancient Roman practice of inducing vomiting in order to restore one’s appetite after eating, so one can eat even more, is forbidden even during the week.) Since this is done to cure an ailment – uncomfortable bloating – it is forbidden on Shabbat. One who wishes on Shabbat to alleviate bloating by inducing vomiting is permitted to insert his finger into his throat, or may drink hot water, which can also have the effect of inducing vomiting. Hacham Ovadia writes that if somebody experiences considerable discomfort due to bloating, and he wishes to induce vomiting by drinking hot water but has no hot water available, he may ask a non-Jew to heat water for him.
Summary: It is permissible on Shabbat to take pills that do not serve to cure an ailment. Examples include vitamins, sleeping pills, caffeine pills, birth control pills and pills to restore sobriety after inebriation. One may not, however, take a pill to induce vomiting as a means of relieving bloating, though other vomit-inducing methods – such as inserting one’s finger into the throat, or drinking hot water – are allowed.