Past Prayer

There is a clear halachah in Shulchan Aruch (230:1) that a prayer on the past is a wasted prayer. The two examples offered are based on a Mishnah and Gemara in Berachos.
The first is that if one hears a commotion upon approaching a city, he should not utter a prayer that states, “Hashem, may it be Your will that this commotion is not in my house.” The commotion either already is or is not in his house when he approaches the city. Therefore, if the commotion is in his house, his prayer is tantamount to asking Hashem to change the past. While, obviously, nothing is beyond the power of Hashem, asking Hashem to change the past is beyond the realm of normative prayer. The Shulchan Aruch also writes that one should not pray for an unborn baby to be a specific gender after the gender has already been determined. The Shulchan Aruch deems these two prayers to be prayers in vain. Rav Scheinberg, zt’l, remarked that, in actuality, they are more than just wasted prayers; they are improper prayers. It is highly inappropriate to utter this type of prayer.
The Gemara in Shevuos (37b) discusses a “goseis,” a sick individual in the throes of death. Most individuals in this state unfortunately do not recover. This is in contradistinction to a “choleh,” as most cholim do recover. This is relevant to the following discussion.