One who is sick and suffering may not eat or drink on Yom Kippur unless the illness is life-threatening, as fasting on Yom Kippur is a Torah obligation, overridden only by risk to life. In this Yom Kippur differs from other fasts; the sick are exempt from fasting on Tisha Be-Av, and on minor fasts pregnant or nursing women are exempt (Peninei Halakha: Zemanim 10:2-4).
Therefore, one who has a flu or the like must fast on Yom Kippur, since these conditions are not life-threatening. It is better for a sick person to stay in bed all day and not go to the synagogue, rather than drink even a tiny amount to enable him to go, for fasting is the main mitzva of the day, through which God purifies the Jewish people of their sins. While lying in bed, one should do his best to pray. If it is difficult for him to read from the maḥzor, he should offer heartfelt personal prayers. But he must not eat or drink. Likewise, a husband whose wife is pregnant or nursing, and in her condition she cannot both take care of the children and fast, should stay home and take care of the children so that his wife can fulfill the Torah’s mitzva of fasting. Her fasting is more important than his praying with a minyan in the synagogue.
One who is sick and suffering may swallow medications in pill form, as long as it does not taste good. He should take the pill dry, and if he is unable to do so, he should either chew the pill or add a little soap to the water he swallows it with, thus ruining the taste.
If fasting causes someone terrible pain, he may swallow painkiller pills. Thus, one who is suffering from caffeine-withdrawal headaches may take a caffeine pill or a painkiller. Similarly, a migraine sufferer may take a pill to prevent the onset of a migraine.
The same applies to Yom Kippur. Though we have learned that the Sages forbade eating foul-tasting things on Yom Kippur, in this case, where the purpose of ingestion is not to eat but to take medicine or alleviate pain, the prohibition does not apply (Igrot Moshe OḤ 3:91; Minḥat Shlomo 2:58:25; SSK 39:8). One who suffers severe caffeine withdrawal and has no pills containing caffeine may swallow coffee grounds. Since their taste is extremely bitter, they have the same status as medicine.
One who is in pain and needs medicine that tastes sweet must add something bitter to it to ruin its taste and then swallow it. It is preferable to mix in the bitter substance before Yom Kippur. If only the coating of the medicine is sweet, and, medically speaking, it will not lose its effectiveness if crushed, he should crush it; the bitter taste of the medicine from the inside will ruin the flavor of the coating, and it may all be swallowed. This does not violate the prohibition of grinding, as grinding something that has already been ground is not considered toḥen (Peninei Halakha: Shabbat 12:1).
One who suffers migraines must still fast, even though fasting may trigger a miserable headache, since it entails no threat to life. It is important to realize that, in most cases, there are medications that can prevent the onset of a fasting-induced migraine. In rare cases, a migraine can trigger a stroke, which is indeed life-threatening. One is in this risk category, and thus exempt from fasting, if three conditions are met: 1) He has been diagnosed with fasting-induced migraines; 2) the migraine is preceded by an aura (symptoms that precede a migraine headache) that lasts over an hour; 3) there is no medication (like suppositories or sprays) that can prevent the migraines. Since the patients do not need to eat much at once to prevent the migraine, he should eat and drink in minimal quantities (“le-shi’urim”). (This paragraph was written with the help of Dr. Rafi Cayam and Dr. Rachel Herring.)