In such cases the same rule applies to all the remaining commandments as has been laid down concerning the celebration of the Sabbath: namely, that it must give way as soon as danger to life is in any way to be feared for us or for others.
דחויה היא שבת אצל סכנת נפשות כשאר כל המצות.
[The Sabbath is set aside in the face of danger to life, like all the other commandments.] (רמב"ם פ"ב מהל' שבת [Maimonides, ch. 2 of the Laws of the Sabbath].)
כל מצות התורה (חוץ מע"ז ג"ע וש"ד) יעבור ואל יהרג. ואם מת ולא עבר, ה"ז מתחייב בנפשו. (פ' ה' מהל' יסודי התורה.)
[For all the commandments of the Torah (except idolatry, forbidden sexual relations and bloodshed), one should transgress and not be killed; and if he died rather than transgress, he is guilty of his own death.] (Maimonides, Hilkhot Yesodei ha-Torah, ch. 5)
כל פקוח נפש דוחה שבת והזריז הרי זה משובח. והשואל הרי זה שופך דמים.
Praiseworthy is he (it says there in the Talmud) who then, without regard to the Sabbath, hastens in person to the aid of the one who is in danger. Whoever first asks about it is a shedder of blood.
(See Maimonides, on the Sabbath, ch. 2.) Among other things it says there:
ואסור להתמהמה בחלול שבת לחולה שיש בו סכנה, שנאמר אשר יעשה אותם האדם וחי בהם, ולא שימות בהם. הא למדת שאין משפטי התורה נקמה בעולם, אלא רחמים וחסד ושלום בעולם. ואלו האפקורסים שאומרים שזה חלול שבת ואסור, עליהם הכתוב אומר וגם אני נתתי להם חוקים לא טובים ומשפטים לא יחיו בהם.
In such cases (e.g., for the sake of a sick person) one may not hesitate or scruple for a moment to perform any work on the Sabbath. For here too the general rule applies which Holy Scripture indicates to us with the words (Lev. 18:5): "These commandments are to be carried out so that man may live by them; but not in order to perish over them." --- For see, the law is surely not there for the torment and torture of men; rather it is meant to promote goodwill, love and happiness among men. Truly, it is only heretical or godless people who on such an occasion can still say: "That is a desecration of the Sabbath! We may not do that!" --- Of such it is said (Ezek. 20:25): "So I too gave them laws that are not good, and judgments by which they cannot live."
(See also Maimonides, on the observance of the Day of Atonement, ch. 2: חולה שיש בו סכנה ששאל לאכול ביום הכפורים, אע"פ שהרופאים הבקיאין אומרים אינו צריך, מאכילין אותו על פי עצמו עד שיאמר די.
[A sick person whose life is in danger who asks to eat on the Day of Atonement, even though expert physicians say he does not need to, is fed on his own word until he says, "Enough."]