The Mishna Berura (Rav Yisrael Meir Kagan of Radin, 1839-1933), commenting on a ruling of the Shulhan Aruch (Orah Haim 328:17), writes that it is permissible to perform an “Issur De’rabbanan” – an action which the Sages forbade to perform on Shabbat – in an unusual manner for the sake of an ill patient. If the patient is “Nofel Le’mishkab” (literally, “falling to the bed”) – meaning, he is bedridden, or he experiences weakness throughout his body – but his life is not in any sort of danger, then although Torah violations are not permitted (since there is no risk to life), one may perform an act proscribed by the Sages, in an unusual manner, if this is necessary to help the patient.
A possible example of this Halacha is turning off the lights. If a patient is bedridden, and the light either causes him additional discomfort or makes it difficult for him to get the sleep he needs, then, seemingly, it should be permissible to turn off the light with one’s elbow to help the patient. After all, the Torah prohibition of extinguishing on Shabbat applies only to extinguishing a flame to produce a coal; other forms of extinguishing – such as turning off an electric light, which quite obviously does not produce a coal – are forbidden only by force of Rabbinic enactment. Therefore, turning off a light in an unusual manner, such as with one’s elbow, instead of with one’s fingers, should be allowed. The Mishna Berura, however, maintained that this particular case should be treated more stringently, as turning off the light could easily lead to a Torah violation.
Hacham Ovadia Yosef, in Hazon Ovadia – Shabbat (vol. 1, p. 256), disagrees. In the case of a bedridden patient who is disturbed by the light, according to Hacham Ovadia, it is permissible to turn off the light in an unusual manner, such as with one’s elbow. If a non-Jew is available, it is preferable in such a case to ask a non-Jew to turn off the light. However, if asking a non-Jew is not an option, then it is permissible to turn off the light in an unusual manner.
Summary: If a patient is bedridden, or is ill to the point where he feels weakness throughout his body, and the light causes him additional discomfort or prevents him from sleeping, it is permissible to ask a non-Jew to turn off the light. If this is not possible, then one may turn the light off in an unusual manner, such as with one’s elbow.