Pesachim Chapter 8, Mishnah 6. This mishnah deals with whether a Pesach offering may be slaughtered on behalf of someone about whom there is a concern that he will not be able to eat from it that night: he may be included among those registered for the offering, but as we will see, the offering may not be slaughtered for him alone.
The categories listed in the mishnah:
"Onen" - one who has lost a close relative and upon whom the obligation of mourning has fallen. The entire day on which the relative died he is an onen by Torah law, and an onen does not eat sacrificial food. On the following night he is an onen by rabbinic law only, and with regard to the Pesach offering the Sages did not enforce their ruling. Therefore one who became an onen on the eve of Pesach eats his offering that night.
"Vehamefake'ach es hagal" - one who is engaged in clearing away the rubble of a building that collapsed, God forbid, upon a group of people, and it is not known whether he will find someone alive or dead beneath it. As long as no corpse has been found, we presume him to be pure, and therefore the Pesach offering is slaughtered on his behalf.
"Vechein mi shehivtichuhu lehotzio mibeis ha'asurin" - one who has been promised that he will be released from prison before Pesach, and this applies even when the prison is located outside the walls of Jerusalem, so that if the promise is not kept it will be impossible to bring the offering to him. Even so, he is included among those registered for the offering.
"Vehacholeh vehazakein sheyecholin le'echol kezayis" - a sick person or an elderly person who at this moment is able to eat an olive's worth of the Pesach offering.
Regarding all of these the mishnah states "shochtin aleihen" - the Pesach offering may be slaughtered on their behalf, provided that they are registered together with additional people who are not subject to any of these concerns.
"Al kulan ein shochtin aleihen bifnei atzman":
For none of these may the Pesach offering be slaughtered on its own. Not when the offering is slaughtered for one of them alone, and not even when several of them are registered for it together, as long as everyone registered belongs to these categories. The reason: "shema yavi'u es hapesach lidei pesul" - lest it turn out in the end that the offering has become invalid.
In detail:
The onen: because of his emotional state he is liable to become impure through contact with the dead and will then be unable to eat from the Pesach offering.
The one clearing the rubble: he may find a corpse there and become impure.
One who was promised release from prison: perhaps they will not release him, and the case under discussion is one who is held under gentile rule, in whose eyes the Pesach offering counts for nothing.
The elderly person and the sick person: perhaps they will be unable to eat an olive's worth.
Exemption from Pesach Sheni:
Even if an invalidation did occur in the end, that they became impure or were unable to eat, since in our case the offering was slaughtered not for them alone but for others along with them, they are exempt from bringing a second Pesach offering. They have fulfilled their obligation with the first Pesach, since at the time of the slaughtering and the sprinkling of the blood they were in principle fit to eat from the offering.
"Chutz min hamefake'ach begal":
The exception is the one engaged in clearing away the rubble, who was impure from the outset: if it turns out that the person under the ruins was already dead, then he was impure all along, only that he did not yet know it.
The Gemara qualifies this: this applies when the heap of ruins is round, in which case he certainly formed a covering over the corpse as he passed above it. But if the heap is long, and it is possible that at the time of the slaughtering he had not yet reached that spot, he is exempt from Pesach Sheni, since he was pure at the time the offering was slaughtered, unless he knows for certain that he passed over the place where the corpse was lying.
In summary: in this mishnah we learned that the onen, the one clearing away rubble, one who was promised release from prison, the sick person and the elderly person - the Pesach offering is slaughtered on their behalf together with others, but not for them alone, lest they cause the Pesach offering to become invalid. And if it was slaughtered for them together with others, they are exempt from Pesach Sheni even if an invalidation did occur, except for the one clearing away rubble, who was impure from the outset, under the conditions explained in the Gemara.