The obligation to help save someone’s life even if it involves desecrating Shabbos:
A. The Mitzvah and its reason: 
One who has a life threatening illness it is a Mitzvah to transgress Shabbos on his behalf [to help heal him] and those which act with alacrity [and do so first] are praised. One who seeks [Halachic advice to verify if he is allowed to save him] is spilling blood [through this delay] and the one who is asked [such a question] is to be ashamed because he should have made a public speech mentioning that it is allowed.
If there is doubt whether the situation is life threatening: Even a questionable life threatening situation pushes off [the prohibitions of] Shabbos.
If there is doubt if the person is alive or dead, Jew or gentile: One which a mound fell upon him and there is doubt as to whether he is still alive or already dead, [and] a doubt if he is under there or he is not under there, and even if one were to say that he is under there is doubt as to whether he is a Jew or a gentile, one is to undo the mound from upon him even though many doubts are involved.
The reason for all the above is because: it says [in the verse] “That one should do and live by them” and what is “and live by them” trying to teach us? It is saying that one should see to it that one will for certain live through doing the Mitzvah and should not [do so if] he will come through this [Mitzvos] to a case of a possible life threatening danger.
B. Helping to save a life even he will further live only momentarily:
Even if [the victim] was found to be crushed and is thus is only able to live momentarily, [nevertheless] one is to undo the mound up to his nose and check him [for if he still has life] and if he is still alive then one is to undo the mound and take him out for him to live whatever amount longer [that doing so will allow him to live]. [However] if one did not feel life in his nose, then he has certainly already dead even if he was not crushed.
C. Being swift to transgress Shabbos to save a life even if doing so swiftly involves additional transgressions:
Whomever is swift to transgress Shabbos for a life threatening situation is praised [for doing so] even if [in the process of doing so hastily] he has done with it an additional [unnecessary] transgression, such as for example one spread out a net to remove a child that fell in a river and consequently caught fish with it, as well as any case of the like. [However if the matter is not so urgent then when possible to lessen the amount of prohibition done, then one must do so as will be explained in Halacha 3B.]
D. One who refuses to accept treatment:
If [the sick person] refuses to accept the treatment because he does not want Shabbos to be desecrated on his behalf, then he is to be forced [into taking it] as this is a ludicrous form of [supposed] piety.
E. May a treatment be started on Shabbos if the doctors say that he will regardless live until after Shabbos?
A deathly ill person which was diagnosed on the day of Shabbos that he requires a known treatment which contains Shabbos prohibited labor [and the treatment must be] done for the next eight days, then we do not say “let us wait until night [to begin the treatment] in order so we only transgress one Shabbos”. Rather we desecrate Shabbos immediately even though that through doing so one will desecrate two Shabbosim.
The reason: Now, although we know for certain that [the patient] will not die today being that he was evaluated to live through the eight days [of the required treatment], nevertheless we are worried that perhaps he may die after the eight days, if the treatment were not to be started immediately.
F. If many figs were picked when only one was needed:
[If] the doctors evaluated that [the patient] needs one fig and ten people ran and each one brought back one fig, they are all exempt of liability and they all receive reward from G-d even if [the patient] became better from the first fig.
G. Must one help save another Jew if there is danger involved for him?
Although it is a commandment upon every individual to desecrate Shabbos in order to save them, even if there is doubt as to whether they will be saved, nevertheless if there is danger [involved in trying to save the Jew] one may not endanger himself in order to save his friend because [in the mean time] he is not within the range of danger. [This applies] even if one is witnessing the death of his friend and even if his danger [in trying to save him] is doubtful while his friends is certain, nevertheless [he is not to put himself in danger to save him]. [However see supplement that this is only in accordance to one opinion].
The reason for this is: as the verse states “You shall live by them” and not that one should come into doubt of death through fulfilling the Mitzvah of “Do not stand by the blood of your friend”.
Supplement from Choshen Mishpat Hilchos Nizkeiy Haguf Vehanefesh Halacha 7:
One who sees a friend drowning in the sea or that murderers are coming upon him and he is able to personally save him or to hire someone to help save him, then he is obligated to trouble himself to hire others to save him, and he then returns and collects the money from the victim if the victim has the money, and if not then he may not refrain from [paying to help save him], and if he does refrain from doing so then he transgresses the command of “do not idle while your friends blood is being spilled”.
When there is danger involved for the rescuer: Even to enter oneself into a questionable case of danger one must do in order to help save his friend from definite death. (However there are opinions which argue on this, and Safek Nefashos Lehakel).
H. Saving a Jewish robber from death on Shabbos:
One who comes through a tunnel [to rob a house] in a scenario that [the robber] has given up his blood and it is permitted [for the homeowner] to kill him [in self defense], and a mound fell on him there [in the tunnel] one may not undo it for him (as one is not commanded to help him live).
[See Q&A regarding one who is trying to commit suicide, and non-religious Jews]
I. Transgressing Shabbos to help save a person which is questionably Jewish:
We do not follow after the majority [of a population’s ethnic group] by a life threatening situation [as will be explained].
A mound fell in an area that a Jew was definitely around: It goes without saying that if there nine gentiles and one Jew standing in a courtyard and a building fell on one of them in that courtyard, and it is not known if it was a Jew [upon whom it fell] or a gentile, that one may undo the mound.
The reason for this is: being that the Jew and the gentiles were set in that courtyard and anything which is set is considered [a ratio of] half and half [even though in truth there is less than half of it] and in a case of doubt regarding if there is a life threatening situation [to a Jew] we rule leniently.
If one person separated from the group: [Furthermore] even if one person left to a different courtyard and [in that courtyard] a building fell on him in which case it is appropriate to follow the majority [of people, and thus not allow to remove the mound on Shabbos], even so we clear [the rubble] from on top of him.
The Reason: As since the original establishment [of 50:50] has remained in its state (at the time [that the person] left the [50:50] establishment) we therefore consider [this person who separated] as if he were still established with them to be lenient in a life threatening situation.
If the entire group left one after the other: However if the [entire] group uprooted from [their original place of establishment] one after the other, and at the time of the uprooting one of the group members left to a different courtyard and there a building fell on him, then one may not uncover it for him.
The reason for this restriction is: as since the original [50/50] establishment has already moved from its place (when this person separated from them) it is thus impossible to be lenient in it due to the concept of a [50/50] establishment and we [thus] go after the majority of which were gentiles.
If the entire group left together: However if the entire group left together, then they are still considered established together and when one person separates from them, he has separated from a [50/50] establishment and one is to undo the mound from on top of him.
An abandoned baby in a city of majority gentile population: Likewise an [abandoned] baby which was found in a city that is majority gentile, there are opinions which say that one may not desecrate Shabbos for him, as since every day everyone separates from their established area we therefore go after the majority (as is explained in Even Haezer Chapter 4 [Halacha 34], [although] see there for opinions which argue).
J. Checking if the person is already dead: 
Whether [the victim] got hit first on his head or first on his feet and one sees that there is no life in his heart, even so one is to check up to his nose, as the main evidence of whether there is life is in the nose, as it says [in the verse] “all that have a soul of life in their nose”. [See Q&A regarding using a resuscitation machine]
Summary of the obligation to help save someone’s life even if it involves doing Shabbos transgressions:
It is a Mitzvah to do everything possible to help save a Jews life, even if it involves transgressing Biblical prohibitions, and one who delays doing so even in order to receive Halachic permission is considered to have spilled blood. Even in a case of doubt as to whether the person is in life threatening danger one is to do all that is possible to save him.
Even if one will only be able to help him live for a very short amount of time, he is to save him.
One who is swift to transgress Shabbos to save a life even on account of doing additional prohibitions is praised. However if the matter is not so urgent then if it is possible to lessen the amount of prohibition done, one must do so.
If the patient refuses to accept treatment then he is to be forced into it.
Even if the treatment can be pushed off until after Shabbos one is not to do so, due to worry that perhaps by then he may not be able to be cured anymore by that time.
Danger is involved for the rescuer: Then even if the danger is only a doubt while the danger of the victim is certain, nevertheless one is not allowed to enter himself into danger in order to try to save him. [However elsewhere Admur rules he is obligated to do so.]
Saving a robber from death on Shabbos: One who is in the process of robbing a home and falls in danger may not have Shabbos desecrated for him.
May one desecrate Shabbos to help save a person if one does not known if he is Jewish? Whenever there is a gathering of people of which there is at least one Jew within the gathering then one may save any person that is in danger within that gathering if it is unknown if he is that Jew or not, whether the danger occurred in the area of the gathering or after he personally left the gathering. However if every individual separated [in different directions or] one after the other, then one may not desecrate Shabbos for an unknown person unless the majority of the group was Jewish.
An abandon baby found on Shabbos: May not have Shabbos desecrated on its behalf unless the majority of the city is Jewish. Although there are those which argue.
May one desecrate Shabbos if it is unknown if the person is still alive?Yes. In any case of doubt, even if it involves many doubts such as he may not even be Jewish, and he may not even be alive, nevertheless one is commanded to desecrate Shabbos for him.
When is one considered dead that Shabbos may no longer be desecrated for him? When there is no longer sign of life from his nose, even if there is no sign of life from his heart.
May one desecrate Shabbos to help save one who is committing suicide?
May one desecrate Shabbos to save a Jew which does not keep Shabbos, or a heretic?
Yes, as although ideally one who desecrates Shabbos in public or a Jew which is a heretic, may not have Shabbos desecrated on their behalf, nevertheless many Poskim today rule that it is allowed [and an obligation] as they are a Tinuk Shenishbu, as well as refraining from doing so will cause enmity and is thus allowed just like by a gentile, as well as perhaps they have repented due to their illness.
Practically today may one give medical treatment to a gentile on Shabbos, and may he desecrate Shabbos on his behalf?
Yes, as due to advanced communication and the constant anticipation of reasons to use to hate and attack Jews the matter can lead to actual danger for other Jews if one were to refuse to treat them. It is thus allowed to even do Biblical transgressions. However some have written that while doing so one is to constantly think that he is doing so simply to save himself or other Jews from danger, and then it is considered like a Melacha Sheiyna Tzarich Legufa which many Poskim allow to be done to help save a gentile.
May one turn on a resuscitation machine to help revive one who is not breathing?
 Lit. has fixed another matter
 Based on 328/13 and 18
 The Michaber there rules like the Rambam, that if majority of the town are gentiles then one may not remove a mound from an Asufi on Shabbos.
 The Rama there rules that even if the majority of the population is gentiles one may still desecrate Shabbos to save the Asufis life, as we view the Jews in the city as Kavua and thus is 50/50.
 Chapter 329 Halacha 3
 329/8 and
 Piskeiy Teshuvos 329/1
 So rules IG”M 1/127; Bircheiy Yosef 301/1; Kinyan Torah; Bitzeil Hachachma
 Chachmas Shlomo on chapter 329
 Piskeiy Teshuvos 329/2
 M”B 329/9 and PM”G – M”Z- 328/6
 Sheivet Halevy 3/36; Chelkas Yaakov 1/45; Minchas Yitzchak 3/20;10/31 letter 14;10/151; Mahrahm Shick 140
 So rules Minchas Yitzchak
 Piskeiy Teshuvos 330/2
 So rules: Chasam Sofer  Yoreh Deah 131; Divrei Chayim 2/25; Igros Moshe 4/49; Chelkas Yaakov 2/54; Minchas Yitzchak 1/53, 3/20
 Shearim Hametzuyanim Behalacha 92/1; Titz Eliezer 8/15-6
 Piskeiy Teshuvos 329/3