After saying Shema Al Hamita and hamapil, a person sometimes needs to visit a restroom or eat/drink (esp. for pregnant women). Is it right to say a bracha (asher yatzar) after using the restroom or before eating/drinking in this case?
Although a person has already said the berachah of hamapil, it is permitted to say the berachah of asher yatzar after using the bathroom.
The same applies to a berachah before and after eating or drinking, though one should not to eat or drink after hamapil unless one has to.
The Rema (239:1) rules that one should not make a hefsek between reciting the Shema and going to sleep, but he does not specifically address the issue of ha-mapil.
However, the Mishnah Berurah (4) writes that one should be careful not to eat, drink, or speak after saying hamapil, so as to avoid a hefsek between the berachah and actually sleeping.
Nonetheless, it appears clear that the berachah is not a birchas hanehenin: sleep is not a type of “pleasure” over which Chazal enacted a berachah, and the blessing is rather an expression of praise, which corresponds to the blessing of “ha-maavir sheina” in the morning (this parallel is drawn by the Mishnah Berurah).
Thus, just as the berachah of “hamaavir sheina” should be made upon waking up, but not necessarily immediately upon waking up, so too the berachah of hamapil does not have to be made immediately before going to sleep, and where one needs to make an interruption, it is permitted to do so.
The Biur Halachah also adds that according to the Chayei Adam the berachah is made over the general “way of the world,” and not over the individual’s personal sleep, so that even somebody who is not going to sleep at all can still make the berachah. The Mishnah Berurah does not rely on this, but for purposes of an interruption it can be added as another reason for leniency.
Thus, a number of authorities rule that asher yatzar can and should be said after hamapil: see Shut Pri Ha-Sadeh Vol. 1, no. 93; Shut Hitorerus Teshuvah Vol. 1, no. 125; Halichos shlomo Chap. 13, note 14; Shut Tzitz Eliezer Vol. 3, no. 27; Shut Be’er Moshe Vol. 1, no. 62.