Q. Re – question above. If one is allowed to violate Shabbos when one is under extreme mental and emotional pain and stress?
A. Igrois Moshe (Y. D. 2: 174) explains (Sefer Melakhim I: ch.17), that Eliahu, who was a Cohen, was permitted to touch and revive the dead Ben Hatzarfatis because of pikuach nefesh and danger of life, not of the child, but rather of the mother who was suffering tremendously and in extreme mental pain for loosing her only miraculously given child. That extreme pain placed her life in danger. (See Tosafos, Baba Metzia 114b).
However Nishmas Avrohom (O. H. 5: 334: p.39) quotes Horav Yehoshua Neuwirth as questioning why then someone (l”a), watching his house being consumed by fire during Shabbos and all his wealth going up in flames, is not permitted to intervene due to the extreme agony, worry and mental pain his losses are causing.
Minchas Shlomo (7) and Shemiras Shabbos K. (41: n. 8) mention that even when there is a possibility of loosing a major limb, and one is then subject to the ensuing extreme emotional pain for the great loss involved, it is not considered as pikuach nefesh or a life threatening situation. In all those cases we urge the victim to exercise trust in Hashem, calm down and take control of himself. (See HaDeres, Over Orach 334).
Horav Shlomo Miller’s Shlit’a opinion is similar, unless one is dealing with an extreme aged or debilitated and emotionally ill individual, when this very painful situation may indeed cause his sudden collapse and death.
Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit’a