If somebody suffers from a medical condition on Shabbat that does not pose any risk to his life, it is, of course, forbidden to desecrate Shabbat to treat his condition, but it is permissible to ask a non-Jew to perform for the patient activities that are forbidden for a Jew on Shabbat. Thus, for example, if the patient needs a certain type of food, it would be forbidden for a Jew to cook this food, since the patient’s condition is not life-threatening, but it would be permissible to ask a gentile to cook the food. Although food prepared by a non-Jew is – in many situations – forbidden for a Jew to eat even during the week, this prohibition is waived for the sake of an ill patient who needs a certain kind of food prepared for him on Shabbat.
There is considerable discussion among the Halachic authorities concerning the status of this food after Shabbat. The Mishna Berura (Rav Yisrael Meir Kagan of Radin, 1839-1933), in one context (Siman 328), rules that once Shabbat ends, nobody – including the patient – is permitted to eat this food which was cooked by a gentile. After Shabbat has ended, it becomes permissible for Jews to cook food for the patient, so there is no longer any need to make an exception and allow the consumption of the food prepared by a gentile. Therefore, if some of the food which the gentile had prepared is left over, nobody may eat this food, and a Jew should prepare more food for the patient if necessary.
Earlier (in Siman 318), however, the Mishna Berura rules differently. There he writes that since this food was prepared by a gentile under circumstances which allowed its consumption by a Jew, it remains permissible after Shabbat – not only for the patient, but even for other Jews. The Mishna Berura there notes that other Jews may eat it immediately after Shabbat, and do not have to wait the amount of time it would take to prepare the food.
Later scholars propose different theories to reconcile these seemingly conflicting passages in the Mishna Berura. One theory is that the later passage (in Siman 328), where the Mishna Berura rules stringently, was actually written not by the Hafetz Haim himself, but rather by his son, and this accounts for the different rulings.
Regardless, Hacham Bension Abba Shaul (Israel, 1924-1998), in Or Le’sion (2:36), and Hacham Ovadia Yosef, following the position of the Bet Yosef (in discussing the laws of foods prepared by non-Jews), rule leniently, and permit anybody to eat this food immediately after Shabbat ends. Although the Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909) ruled stringently, Halacha follows the lenient position expressed by the Mishna Berura in the earlier of these two passages. And thus if a gentile prepared food for an ill patient on Shabbat, the food may be eaten after Shabbat by all.
However, although the food is permissible, there is some discussion among the Halachic authorities as to whether the utensils in which the food was cooked require Hag’ala (“koshering” through immersion in boiling water). Some authorities, cited by the Mishna Berura (328), maintain that the since the food was cooked under circumstances that allow eating food prepared by a non-Jew, the utensils are entirely permissible and do not require Hag’ala. The Mishna Berura writes that those who act leniently in this regard have a legitimate basis on which to rely. In practice, however, the Mishna Berura writes that the utensils should undergo Hag’ala. He adds that although earthenware utensils are generally considered unable to be koshered, and once they are used with forbidden food they can never again be used, there is room to be lenient in the case of food prepared by a gentile on Shabbat for an ill patient. If an earthenware utensil was used, the utensil should be immersed in boiling water three times, and it may then be considered permissible. Since some opinions do not require Hag’ala at all in this case, the Mishna Berura allows koshering earthenware utensils in such a situation, despite the fact that we generally do not allow koshering earthenware utensils.
If one did not kosher the utensil and used it to prepare food, then as long as the amount of food prepared in the utensil exceeds the amount of food particles absorbed in the utensil – which will virtually always be the case – the food may be eaten after the fact.
Summary: If an ill patient suffers on Shabbat from a condition that is not life-threatening, and he needs to eat a certain food, a Jew may not cook the food for the patient, but one may ask a gentile to cook the food for the patient. The food remains permissible after Shabbat, and may be eaten even by other Jews immediately after Shabbat. However, the utensils in which the gentile cooked the food must be koshered, though if one cooked food in those utensils without koshering, the food may be eaten.