If a person’s life is in danger on Shabat, the day is treated as a weekday as far as that patient is concerned. Anything that is necessary to help an ill patient is allowed, including turning on or off lights, if this is necessary to help him/her recover. This halachah is noted in the Shulchan Aruch.
It goes without saying that if a non-Jew is not immediately available, a Jew should perform the melachah that is necessary to help the gravely-ill patient, and the treatment should not be delayed at all. However, if a non-Jew is present and willing to help, should we rather allow him to perform the melachah to avoid chilul Shabat?
The Mishnah Berurah states that it is indeed preferable to ask a non-Jew to perform the melachah, provided that this would not cause any delay whatsoever in tending to the patient. However, this is not the opinion of the Shulchan Aruch which states that in a case of a threat to life, a Jewish adult should violate Shabat to help the patient, even if a non-Jew is present and available to help. This is the ruling accepted by Ha’Rav Ovadyah Yosef (a”h) and by Rav Moshe Feinstein (a”h). Therefore, when a person’s life is in danger on Shabat, a Jewish adult could perform whichever melachot are necessary to help the patient.