In introducing the laws concerning forbidden relationships, the Torah states that Hashem commanded Moshe to tell the people that they must observe His decrees and His laws in order that each person may do them and live by them (ויקרא י"ח:ה'). The Gemara in Yoma (דף פ"ה:) derives from the words "וחי בהם," "and live by them," in that Posuk (שם) that the Mitzvos of the Torah were given so that every person may live by them, "ולא שימות בהם," "and not that one should die because of them;" the Mitzvos were given for the sake of life, and not for the sake of death. This phrase is consequently considered by the Gemara (שם) to be the primary source for the idea that פיקוח נפש, saving a life, takes precedence even over the observance of Shabbos; the Mishnah earlier in Yoma (דף פ"ג.) gives some examples of activities which are usually prohibited, whether on Shabbos or in general, that may be done in order to save a life. The Gemara in Sanhedrin (דף ע"ד.), citing this same phrase from this Posuk in our Parsha (שם) and the above derivation, states clearly that one may commit any Aveirah mentioned in the Torah if the failure to commit that Aveirah would result in one's losing one's life, with only three exceptions: idolatry, having illicit sexual relations, and murder. Aside from those three, however, the Mitzvos of the Torah are inapplicable if one would be endangering his life as result of adhering to them. Similarly, the Gemara in Kesubos (דף י"ט.) indicates that nothing takes precedence over saving a life aside from the requirement to avoid those three Aveiros. The Rambam (פרק ה' מהל' יסודי התורה הלכה א',ב') and the Shulchan Aruch (יורה דעה סימן קנ"ז סעיף א') rule accordingly, and elaborate on some of the details of this idea that in order to save one's life, one may violate any commandment of the Torah except for those three "cardinal" sins.
It is clear from the aforementioned Mishnah in Yoma (שם) and from the Gemara there (שם דף פ"ד.-פ"ה:) that the preservation of life supersedes even the observance of Shabbos, as noted above, and, as the Mishnah (שם) adds, Shabbos may be overridden even if there is only a doubt and thus only a possible danger to somebody's life; Tosafos (לדף פ"ה. שם בד"ה ולפקח) cites the same phrase "וחי בהם" from the Posuk in our Parsha (שם) to explain that we must preclude even the possibility of a Jew dying, and one may violate Shabbos in order to accomplish that. The Tosefta in Shabbos (פרק ט"ז הלכה י"ג) also states that saving a person whose life is in danger, and even saving a person whose life is possibly in danger, takes precedence over observing Shabbos, and other sources for this are presented there. The Rambam (פרק ב' מהל' שבת הלכה א') rules that Shabbos is pushed aside, like all other Mitzvos, where there is a threat to someone's life, and thus one may do on Shabbos anything which is necessary to assist a person whose life is in danger, even if, as he adds, there is some doubt about whether or not one needs to violate Shabbos for this sick person, and even if there is some difference of opinion among the doctors as to the patient's condition. The Rambam then adds (שם הלכה ב') that one may violate Shabbos as often as one needs to for the sake of a dangerously ill patient, and he concludes simply (שם) that for the sake of an ill person whose life is in danger, Shabbos may be treated as an ordinary weekday.
The Shulchan Aruch (אורח חיים סימן שכ"ח סעיף ב') rules that it is in fact a Mitzvah to violate Shabbos in order to save someone who is dangerously ill, and that one who is enthusiastic and diligent about doing so is praiseworthy; the Mishnah Berurah (שם ס"ק ד') as well as the Kaf HaChaim (שם אות ו') cite the phrase "וחי בהם" from the Posuk in our Parsha (שם) as the source for this being a Mitzvah. The Be'er Heitev (שם ס"ק א') notes that even if the patient does not want Shabbos to be violated on his behalf, we require it anyway because such piety is considered foolish; we thus listen to the doctor if he says that the patient must be treated, even if the patient feels otherwise, but we also listen to the patient if he says that he must be treated, even if the doctor feels otherwise. The Mishnah Berurah (שם ס"ק ו') also writes that if a dangerously sick person refuses treatment because he does not want Shabbos to be violated, we try and convince him that he is exhibiting foolish piety, and we even force him to accept treatment if necessary; the Pri Megadim (באשל אברהם שם ס"ק א') implies that this is true as well even if there is a doubt about the danger to the person's life. The Magen Avraham (שם ס"ק א') refers to a statement of the Ramo elsewhere in the Shulchan Aruch (יו"ד סימן קנ"ה סעיף ג') which indicates that when one violates something for the sake of a sick person, the treatment must be known to be effective or guided by an expert; this point is echoed by the Mishnah Berurah (או"ח שם ס"ק ה') and the Kaf HaChaim (שם אות ט'), among others.
The Shulchan Aruch (או"ח שם) then states that one who asks questions (of a Rav) in such a case is compared to a murderer, and the Mishnah Berurah (שם ס"ק ו') and the Aruch HaShulchan (שם סעיף א') explain that this is because of the possibility that while the person is asking the question of the Rav, the sick person's condition may worsen and his life will become even more endangered. This idea that questions should not be asked in this kind of case is found in the Yerushalmi in Yoma (פרק ח' הלכה ה', דף מ"א:), which actually states that the one who asks the question is like a murderer, but also states that the one who is asked the question is shameful and blameworthy; the Korban HaEidah (שם בד"ה והנשאל) explains that this is because the Rav should have publicly spoken about these matters so that people would know the Halachos in advance, an explanation also cited in the Beis Yosef, commenting on the Tur (או"ח בד"ה הנשאל), from the Terumas HaDeshen (שו"ת תרומת הדשן סימן נ"ח, ובפסקים וכתבים סימן קנ"ו). The Mishnah Berurah (שם) also writes that it is the job of a Rav to explain these Halachos to the members of his community so that they know them and will not have to ask questions when a situation arises; the Kaf HaChaim (שם אות ט') implies the same thing, as does the Aruch HaShulchan (שם) who actually compares the person who is asked the questions on these matters to a murderer.
The Aruch HaShulchan (שם סעיף ב') then qualifies this, though, by writing that the Ohr Zarua (חלק ב' סימן ק"ח) implies that this idea that it is so terribly improper to ask questions when a life is in danger is true only when the situation is truly urgent and time is absolutely of the essence; in such a case, one should do whatever one must without asking questions and, if necessary, treat Shabbos as a weekday. But if the situation is not quite that urgent, one must certainly ask a Rav what should be done, and the Aruch HaShulchan (שם) cites a proof for this from a Gemara in Menachos (דף ס"ד.) which indicates that legitimate questions can come up even in a life-threatening situation; he concludes (שם) that only in a case of extreme danger should one act as one sees fit without asking any questions, but in a more ordinary type of case, one should consult with a competent authority, as he says is the prevalent custom. It should be noted that the Kaf HaChaim (שם אות י') states that a Rav must make sure that he is fluent in these Halachos so that if a question comes up, he will not have to spend valuable time looking into Seforim; he also quotes from the Mateih Ephraim (שם סימן תרי"ח סעיף ט"ז) that one who does know the answer to a question in this area may speak up even in the presence of a Rav if the Rav is unsure, and he need not be concerned about the honor of the Rav at that moment because of the emergency situation.
The Tosefta in Shabbos (שם הלכה י"ב) indicates that when Shabbos must be violated in order to save someone's life, the actual act of violating Shabbos should be done not by a non-Jew or by a child (under the age of Bar or Bas Mitzvah), but by a Jewish adult; this idea is also mentioned in the Gemara in Yoma (דף פ"ד: ועיין שם בהגהות הגר"א אות א') where Tosafos (שם בד"ה אלא) explains that this is preferable because the Jewish adult will not be lazy or careless and will thus definitely prevent further danger. The Rosh in Yoma (פרק ח' סימן י"ד) writes that we do not have children take care of these emergencies even if there are some qualified children available because we are afraid that there will be other occasions when no children will be around, and precious time will be lost by looking for a child when an adult can actually take care of things; the Mishnah Berurah (שם ס"ק ל"ג) applies this reason to explain the exclusion of non-Jews as well. The Rambam (הל' שבת שם הלכה ג') and the Shulchan Aruch (שם סעיף י"ב) rule in accordance with this position that it is preferable that the act of violating Shabbos for a sick person should be done by a Jewish adult; the Taz (שם ס"ק ה') quotes the reasons for this presented above, as does the Aruch HaShulchan (שם סעיף ו') who stresses that we don't want anyone to think that violating Shabbos for a sick person is not really allowed and must thus be done by people who are not really obligated to observe Shabbos in the first place, and we thus prefer to have a Jewish adult engage in this activity. The Kaf HaChaim (שם אות ע'), however, notes that if a non-Jew began to help the sick person on his own, one need not stop him, at least according to some opinions; the Sefer Shemiras Shabbos KeHilchossoh (חלק א' פרק ל"ב הערה ט"ז) suggests that if a Jew is present with the non-Jew and oversees his activity, we should allow the non-Jew to work on the patient on Shabbos, and the Kaf HaChaim (שם אות ע"ו) mentions this as well.
The Rambam (שם) actually appears to hold that not only should the person who violates Shabbos to save a life preferably be a Jewish adult, it is in fact proper that a Talmid Chochom be the one to do it; the Taz (שם) explains that this is in order to teach people the Halacha that one is required to violate Shabbos in order to save a life. Some authorities disagree with the Rambam (שם) about this point, including the Tashbatz (שו"ת התשב"ץ חלק א' סימן נ"ד), who notes that the Yerushalmi in Shabbos (פרק ט"ז הלכה ז', דף פ"א.) implies otherwise, while the Beis Yosef (שם בד"ה ואין) reads the Rambam (שם) differently, but the Taz (שם) defends his understanding against the position of the Beis Yosef (שם), while the Aruch HaShulchan (שם סעיף ז') states that Gedolei Torah should violate Shabbos to save a sick person in order to demonstrate to everyone that just as Hashem commanded us about Shabbos, He also commanded us to violate it in a case of a dangerous illness. This indeed seems to be the position of the Rambam in his Peirush HaMishnayos in Shabbos (פרק י"ח משנה ג'), where he writes that other people, if allowed to violate Shabbos in order to save a life, may erroneously conclude that Shabbos is not that significant; the Kaf Hachaim (שם אות ע"ג) mentions this reasoning as well. It must be noted, though, that the Ramo (שם) writes that if it is possible to have the sick person taken care of by a non-Jew without any extra delay so that no Jew will have to violate Shabbos, that is certainly preferable, as it is preferable, if no extra delay will result, for a Jew who must be involved to do what he has to do with a שינוי, that is, in an abnormal manner so that the action does not constitute a true violation of Shabbos MideOraisa; if, however, there is reason to believe that the non-Jew may not do the job properly, then he should not be relied upon. The Ramo concludes (שם) that the prevalent practice is indeed to try to have a non-Jew save the patient's life if possible; the Mishnah Berurah (שם ס"ק ל"ה) and the Kaf Hachaim (שם אות ע"ה) explain that we must try as much as possible to do what has to be done without violating Shabbos, and we may even allow a slight delay if the situation is not that urgent in order to prevent the violation of Shabbos. The Taz )שם(, however, rules that this is not correct, asserting that it is always preferable for a Jew to treat the patient, even if he will have to violate Shabbos thereby, and the Aruch Hashulchanשם( ) concurs; the Kaf HaChaim )שם אות ע"ב( also concludes that it is better for a Jew to take care of the sick patient himself.
It is noteworthy that the Aruch HaShulchan (שם סעיף כ') writes that in all situations regarding an ill person, there is no difference between the person himself doing what must be done to preserve his life and another Jew doing it for him; whatever a sick person may do for his own self-preservation, another Jew may do for him. It should also be pointed out that the Mishnah Berurah, in his Biur Halacha (שם בסוף ד"ה כל), states that one may do on Shabbos whatever is necessary to either heal the sick person or to prevent his situation from deteriorating, and he adds in the Mishnah Berurah (שם ס"ק י"ז) that even if there is only a possibility that the person's condition will worsen without a particular treatment, one may violate Shabbos in his behalf, and the Kaf HaChaim (שם אות כ"ט) concurs; the Mishnah Berurah writes earlier, though (שם ס"ק י"ד), that if it is clear that a particular procedure, if not done, will not lead to a greater danger, then even though it is a standard procedure, it is preferable to avoid it on Shabbos, although he does note (שם) that some disagree with this, and the Kaf HaChaim (שם אות כ"ד) summarizes the opinions about this. The Gemara in Yoma (דף פ"ה.) also indicates that even for חיי שעה, that is, for prolonging a life for a limited period of time, meaning that a full recovery is not possible, one may still violate Shabbos; the Rambam (שם הלכה י"ח) and the Shulchan Aruch (שם סימן שכ"ט סעיף ד') rule accordingly. The Mishnah Berurah in his Biur Halacha (שם בד"ה אלא) elaborates on some of the details about this, adding that there is no difference whether the ill person is a child or an adult, or what type of person he or she is; Rav Moshe Feinstein (שו"ת אגרות משה או"ח חלק א' סימן קכ"ז) writes that Shabbos may be violated even to save the life of a person who is attempting to commit suicide. All of the above demonstrates that a human life, and indeed, every moment of any life, is of infinite value and significance.
One of the interesting questions which arises from time to time is about whether or not one who has gone somewhere, in permissible violation of Shabbos, to try and save the life of a deathly ill patient may return to his own home after his job is done, but before Shabbos has ended, if doing so will involve further violation of Shabbos. The Gemara in Beitzah (דף י"א:) discusses certain activities which are ordinarily prohibited, but become permitted because if they are not, people will then avoid involving themselves in certain related activities which are necessary and important for that day; this may have bearing on this question. The Chasam Sofer (שו"ת חתם סופר חלק או"ח סימן ר"ג) rules that even something forbidden by the Torah can become permissible because it is related to another action which may, and even should, be done, but will otherwise not be; he cites proof for this from the Mishnah in Rosh HaShanah (דף כ"ג:) which allows a Shabbos violation under certain emergency conditions in order to allow for another, necessary activity which otherwise might not get done, and the Rambam (פרק ב' שם הלכה כ"ג ובפרק כ"ז הלכה י"ז) rules accordingly. Rav Moshe Feinstein (שו"ת אגרות משה או"ח חלק ד' סימן פ') notes that the medical workers may certainly return home on Shabbos after finishing their job if they may be needed again elsewhere and will have to be reached, but he also allows them to return home simply because they may, in the future, not want to participate in a life-saving mission if they know they may not be able to return home. There is some discussion among the Poskim, however, as to whether even activities prohibited MideOraisa may be done in such a case or not; Rav Feinstein (שם) appears to be lenient about even this, as are the Chasam Sofer (שם) and Rav Yaakov Emden (שו"ת שאילת יעב"ץ חלק א' סימן קל"ב), among others, but other authorities disagree.