“And the children agitated within her, and she said, ‘If so, why am I thus?’ And she went to inquire of Hashem.” (Bereishis 25:22)
In recent years, prenatal ultrasound imaging (as well as other advanced scans and tests) has become the norm in pregnancy. In general, these tests are performed to rule out possible defects in the fetus or issues that may affect the health of the mother.
It is common for expectant parents to want to discover the gender of their child before delivery. This information can, of course, be gleaned from a simple ultrasound. We will examine a number of sources in Chaza”l that are relevant to this topic.
The Medrash Rabbah in this week’s Parsha (65) lists seven things that are “hidden from human beings”. The sixth item on that list is the knowledge of the gender of a baby before it is born. The Medrash proves this from the Posuk in Koheles (11:5) which states: “Just as you do not know the way of the wind, nor the nature of the embryo in a pregnant abdomen, so can you never know the work of G-d who makes everything.” This Posuk does not just reveal the fact that the “nature of the embryo” is unknown to us, but also implies that Hashem expressly created it as a hidden matter.
Why is it important for the gender of the fetus to remain hidden until birth? The Yefei Toar explains that if parents were to find out the gender of their unborn child, and it is not the gender they hoped for, they will be distressed for the remainder of the pregnancy. Furthermore, even if it was what they wanted, the mother will not experience the excitement and anticipation of discovering the gender at birth, which helps her overcome the pain of delivery.
Tiferes Tzion (and others) explain that there may be a different reason why ascertaining the gender of a fetus may be ill-advised. If, for example, a husband dearly wants a son and he discovers that his wife is carrying a daughter, he may force her to abort the child. Hashem therefore ensured that the gender of a fetus during pregnancy remains unknown.
These are interesting sources regarding determination of the gender before birth. Clearly, there is no Halachic prohibition to determine the gender, and, as it generally makes no difference whether the fetus is male or female from the medical perspective, it remains a matter of parental choice.
The Poskim discuss a fascinating question: is the pregnant wife of a Kohen obligated to find out whether she is carrying a son or daughter? The Rokeach (366, cited by the Sha”ch Y.D. 371:1) rules that the pregnant wife of a Kohen may enter an “Ohel haMeis” (room containing a dead person which a male Kohen may not enter) because the child she is carrying may not be male and it may even be a Nefel (non-viable fetus or abortus). According to the Rokeach, clearly, if she were to know that she was carrying a male child, she would be forbidden to enter an Ohel haMeis.
The Magen Avraham (O.C. 343:2, cited by the Pischei Teshuva Y.D. 371:1) challenges this ruling and contends that it should surely be permitted for her to enter an Ohel haMeis regardless, as the child she is carrying is inside of her body and not exposed to the outside world. How could it possibly contract impurity?
The Pischei Teshuva cites the Radva”z (Shu”t haChadashos 200) who answered that the Rokeach must have been discussing a woman whose pregnancy was close to term. At that point, it is possible that the child’s head could emerge at any moment and be exposed to the impurity. The Rokeach therefore only permitted her to enter the room because the child may not even be a male.
The Mishna Berurah (343:3) rules like the Rokeach and permits the pregnant wife of a Kohen to enter an Ohel haMeis. However, Rav Shlomo Zalman Auerbach zt”l (in the name of Rav Isser Zalman Margolies zt”l) forbade it if she is close to term. Rav Shmuel Wosner zt”l (Shevet ha’Levi 2:205) maintained that due to the ruling of the Rokeach, one should not prevent her from entering a hospital (which may be an Ohel haMeis due to the presence of dead bodies or limbs) during her pregnancy.
The modern Poskim discuss whether the pregnant wife of a Kohen should be obligated to find out whether she is carrying a male or female child now that ultrasound examination is widely available. As the ruling of the Rokeach that permitted her to enter an Ohel haMeis was based on the possibility that the child may not be a male, now that it is possible to find out the gender of the fetus, perhaps she should do so. This would then dictate whether she may enter a hospital late in her pregnancy and inform her decision as to whether to choose a hospital where dead bodies or limbs are unusual.
The Nishmas Avraham cites Rav Yehoshua Neuwirth zt”l as ruling that indeed, all things being equal, the wife of a Kohen should find out whether she is carrying a male child and conduct herself accordingly.
Nevertheless, if a Kohen’s wife wishes to be attended to by a specific doctor, or she feels more confident giving birth in a particular hospital, she may do so even if she is certainly carrying a male and even if the hospital in question does have an issue of Tumas Meis. She should, however, ensure that the hospital will discharge her child as soon as he is in a condition to leave. Rav Elyashiv zt”l (as attested by Rav Yosef Efrati Shlit”a) ruled similarly.
Obviously, all of the above discussion applies only to a woman who has the choice of a qualified hospital with proficient, expert staff. In no way should she endanger herself or her child by choosing a hospital that is less qualified just to avoid concerns of Tumas Meis.
 R’ Shmuel Yaffa Ashkenazi (16th century, Turkey)
 Therefore, there is a “Sfeik Sfeika” – a double doubt and it is permitted for her to enter.
 See also Avnei Miluim (82:1)
 For example, it would theoretically be better to deliver in a hospital that is dedicated to women and children where there is a lower statistical risk of patients dying on any given day than a hospital with a higher rate of deaths. At the very least, she should choose a hospital that is sensitive to the issues of Tumas Meis for Kohanim and endeavors to remove dead bodies from the premises as soon as possible.
 But not for financial reasons.