1) HALACHAH: HOW TO FULFILL THE MITZVAH OF BIKUR CHOLIM
The Gemara earlier (end of 39b) quotes Rebbi Acha bar Chanina who states that one who visits a sick person removes one-sixtieth of his pain (or, according to an alternate Girsa, his sickness). The Gemara says that this applies only when the visitor is "Ben Gilo" with the sick person, which means (according to the RAN) that they were born in the same Mazal (cosmic influences) or (according to the MEFARESH) that they are the same age.
The Gemara here relates that Rebbi Akiva once visited a student who was mortally ill whom no one else had visited. Rebbi Akiva had the student's quarters cleaned and washed, and as a result the student recovered from his illness. Rebbi Akiva proclaimed that anyone who does not visit a sick person is guilty of spilling innocent blood.
The Gemara then quotes Rav Dimi who says that whoever visits a sick person causes the sick person to recover. The Gemara explains that this is because one who visits the sick person prays for his well-being, and through his prayer he "causes" the sick person to recover.
These three statements teach three important practical aspects about performing the Mitzvah of Bikur Cholim:
(a) The RAMBAM (Hilchos Avel 14:4) rules like Rebbi Acha bar Chanina and writes that one who has visited a sick person is considered to have taken away part of his illness and helped him to recover. This benefit of visiting the sick is achieved only through a personal visit to the sick.
(b) The RAMBAN (in SEFER TORAS HA'ADAM, page 17 of the Chavel edition) writes that the Gemara here (40a) implies that there are two basic practical components to the Mitzvah of visiting the sick.
The first is that one must take care of the physical and emotional needs of the sick person (as derived from the conduct of Rebbi Akiva).
(c) The second practical component of the Mitzvah of visiting the sick is praying for the sick person's full recovery (as Rav Dimi teaches). The Ramban writes that one who visits the sick and does not pray for him or her does not fulfill the Mitzvah.
The Ramban cites further support that one is required to pray for the sick person from the statement of Rav Shisha. Rav Shisha states that one should not visit a sick person during the first three hours of the day or during the last three hours of the day, since he will not pray properly for the sick person during those hours (during the first three hours of the day, the sick person appears strong and healthy, while during the last three hours he looks so ill that one despairs of praying for him). Rather, one should schedule his visit so that he will be able to pray properly for the sick person.
The RAMBAM (Hilchos Avel 14:6) also stresses that the visitor should pray for the recovery of the sick person before he leaves. This is the Halachah as recorded by the SHULCHAN ARUCH (YD 335:4-6), who also records a short prayer to say in the presence of the sick person (see Insight #4 below).
It is clear from the Gemara and the Rishonim that there is a Mitzvah to visit a sick person even when he is not conscious, or even if he is in quarantine, since one is still able to pray for him and to make sure that his needs are being met.
2) LIMITS TO VISITING THE SICK
The Gemara earlier (39b) notes that there is a Mitzvah to visit a sick person even one hundred times in one day. However, this applies only in a situation in which the sick person is interested in the company of the visitor. The RAMBAM (Hilchos Avel 14:4) writes that the more one visits the sick person, the more he is praised, provided that the sick person is comfortable with the visits. This is also the implication of the Gemara later (41a) which says that one should not visit a sick person who has a stomach illness, an eye disease, or headaches, since a person with one of those illnesses finds it uncomfortable to have visitors.
The Gemara's directive may help understand the wording of the Rambam there (14:6). When the Rambam describes how to fulfill the Mitzvah of visiting a sick person, he writes that "... one sits near his bedstead, and prays for mercy on his behalf, and leaves." Why does the Rambam mention in his description of how to fulfill the Mitzvah that the visitor "leaves"? The answer is that the Rambam is stressing that one of the Halachos of Bikur Cholim is to know when to leave.
Similarly, the CHASAM SOFER points out that the Gemara in Bava Metzia (30b) derives the Mitzvah of Bikur Cholim from the verse in Parshas Yisro, "You shall inform them of the path in which they should go..." (Shemos 18:20). The Chasam Sofer writes that this verse teaches that when visitors come to fulfill the Mitzvah of Bikur Cholim, they must know when "they should go."
3) HALACHAH: VIRTUAL VISITATION OF THE SICK (VIA TELEPHONE, E-MAIL, AND THE LIKE)
RAV MOSHE FEINSTEIN zt'l (IGROS MOSHE YD 1:223) writes that there is a Mitzvah to take interest in and pray for the sick even when one does not actually visit the sick in person. However, one does not fully fulfill his obligation of Bikur Cholim without a personal visit to the sick.
As proof that there is benefit in taking interest in the sick person without actually visiting him, he cites the Gemara earlier (39a) which says that one who is prohibited to receive pleasure from his friend may not enter his friend's house to visit his friend's sick son, but he may express interest and care for his friend's son when he meets his friend in the marketplace. This implies that it is proper to take interest in the sick person if one is unable to visit him personally.
4) HALACHAH: PRAYING FOR THE SICK
The Gemara quotes Rav Dimi who says that whoever visits a sick person causes the sick person to recover. The Gemara explains that this is because one who visits the sick person prays for his well-being, and through his prayer he "causes" the sick person to recover. The Gemara also says that the Shechinah is above the head of the sick person, and therefore one's prayer for the sick is more readily accepted there.
The Rishonim and Acharonim derive from the Gemara that one of the purposes in personally visiting the sick is to pray to Hash-m for his recovery in his presence (see previous Insights).
The Poskim record a number of important Halachos with regard to praying for the sick:
(a) The SHULCHAN ARUCH (YD 335:5) writes that one who visits a sick person may pray for him in any language. This is because, as the Gemara says, the Shechinah rests in the presence of the sick person, and thus there is no need for the Mal'achei ha'Shares to understand the prayer in order to bring it to the Shechinah (see Shabbos 12b and Insights to Shabbos 12:3). (Hence, one who says merely, "May Hash-m grant you a complete recovery," he fulfills the Mitzvah of praying for the sick person.)
(b) The RAN (DH Ein Mevakesh) writes that the conduct of the maidservant of Rebbi, as recorded in Kesuvos (104a), teaches that there are times when one is permitted to pray that a sick person not recover. However, several conditions must be met:
1. There is no hope for the sick person's survival. RAV MOSHE FEINSTEIN zt'l (IGROS MOSHE CM 2:74:4) writes that one may pray for the demise of a sick person only in a case similar to that of Rebbi, in which all of the great Tzadikim of the generation were praying for his recovery but his condition remained unchanged.
2. The sick person must be in extreme pain, similar to the case of Rebbi.
3. Rav Moshe Feinstein points out further that when these two conditions are met, one is permitted only to pray for the demise of the sick person. Actively shortening his life in any way is absolutely forbidden; one is obligated to do whatever is necessary to prolong his life, as the SHULCHAN ARUCH (OC 329:4) rules that one is obligated to desecrate Shabbos by doing Melachos in order to prolong the life even of one whose skull has been crushed and will certainly die within a short period of time. When a person is going to die imminently ("Goses"), one is prohibited even from touching him in a manner which might hasten his death (Shabbos 151b, and Shulchan Aruch YD 339).
It must be added that one should never give up hope in Hash-m's ability to heal the sick, even when there seems to be no chance of survival. The Gemara in Berachos (10a) teaches that even if a sharp sword is placed upon one's neck, he should not refrain from praying to Hash-m for mercy.

40b----------------------------------------40b

5) HALACHAH: "TEVILAH" IN A RIVER
OPINIONS: The Gemara discusses the status of a river that expanded (swelled) as a result of the rains. Rav says that the increased size of the river is treated like rainwater. Shmuel says that the river swells from its source and therefore its water is still considered natural river water. According to Rav, one may not use such a river as a Mikvah since the water therein has the status of rainwater, and rainwater constitutes a valid Mikvah only when it is gathered in one place and not flowing. According to Shmuel, the river may be used as a Mikvah because it is considered like a natural stream, and a natural stream is valid for Tevilah when it is flowing.
The Gemara says that Shmuel himself did not rely on his own opinion in practice, and he rules that one should not immerse in the Euphrates River except during the season of Tishrei, at which time of year there is no concern that the river's waters have increased due to the rains. The Gemara also relates that Shmuel's father made special Mikva'os for his daughters in the month of Nisan (when the rivers expanded from the rainwater).
In practice, may a river be used as a Mikvah for Tevilah?
(a) RABEINU TAM rules that one may rely on Shmuel's initial opinion since it is supported by the Gemara in Bechoros (55a) which says that the Euphrates River is called "Pras" because its waters are fruitful (Parin) and multiply.
(b) The RACH and RIF disagree with Rabeinu Tam. The RAMBAN writes that one may not rely on the Gemara in Bechoros to resolve the Halachic dispute here, because a Gemara of Agadah cannot override a Sugya which discusses the practical Halachah (see following Insight).
HALACHAH: The REMA (YD 201:2) writes that when there is no Mikvah nearby, the custom is to rely on Rabeinu Tam's ruling that one may immerse in a river throughout the year, provided that it is known that the river flows even during the summer months when there is no rain.
In practice, however, since the situation varies in different places and at different times, each question must be brought to a competent rabbinical authority. There are other difficulties involved with using the water at a beach as a Mikvah. (See the RAN who writes that Shmuel's father made mats for his daughters in order to prevent problems of Chatzitzah, and who cites those who rule that there is a need for a partition for purposes of modesty. See also Nidah 66b.)
6) DERIVING HALACHAH FROM AGADAH
OPINIONS: The RAN quotes the RAMBAN who says that a Halachic practice cannot be overruled based on opposing evidence from Agadah (see previous Insight).
May the teachings of Agadah ever be used to determine Halachic practice? The Acharonim discuss the extent to which Halachah may be derived from Agadah.
(a) The NODA B'YEHUDAH (YD 2:161) writes that no Halachos may be learned from Agadah, even when there is no contradiction from any Halachic Sugya in the Gemara. He explains that the Agados were written in order to teach principles of Musar and fundamental concepts of Torah, but not to teach practical Halachah.
RAV HAI GA'ON (in Otzar ha'Geonim, Chagigah, Siman 67) seems to express this opinion.
(b) REBBI AKIVA EIGER (on Mishnayos Berachos, Perek 5) quotes the PRI CHADASH who disagrees and says that although it is true that we do not rely on Agadah in order to resolve Halachic disputes that were not resolved in the Gemara, we may rely on Agadah to resolve a question of Halachic practice that was not discussed in the Gemara.