Surgery usually requires viewing parts of a naked person. Are there halachic problems with a doctor of opposite gender doing this on a Jewish patient? If the procedure is one where part of the body may be covered such as an endoscopy or repairing an arm or leg, would the halacha be different?
Shulchan Aruch Even Haezer Siman 21 Saif 5
Sefer Nishmat Avraham- The Tosfot write that it is because we depend on this that we today use the services of women. The Aruch Hashulchan writes the above ruling only applies if she does not do this as a service, but if these acts are performed as a service it would appear to be permitted. However, washing his face, hands and feet are clearly forbidden for this involves close contact. Rav Neuwirth wrote that this is only true with regard to a healthy male but if he is ill a woman (such as a nurse) may attend to his needs if another male is not available to do so.
The Birkei Yosef writes that one may ask how we permit a woman to attend to a man suffering from intestinal disease (presumably diarrhea) for since she has to attend to his private ares he may come to sinful thoughts resulting possibly in the emission of semen. However, since he is ill his inclinations will not overcome him for his body is weak as the Terumat Hadeshen writes.
A male doctor, student or any other caregiver, whose work in treating and caring for the sick in undoubtedly noble, must be most careful that when attending to a woman, his eyes and thoughts are entirely focused upon his job and that he is intent only on what he is doing. In addition, he must also be acutely aware of the patient's feelings, for example, where possible, only uncovering that part of her body that he needs to examine, re-covering it before examining elsewhere.