Praise be to Allah, The Lord of The Worlds.
Islamic Law permits and encourages accessing medication in case of sickness. Jurisprudents regarded learning medicine and specializing in its various sciences as a collective duty.
Islamic Law has established a set of controls that doctors should take into consideration. Some of these are:
It identified the Awrah (Pudendum, intimate parts) of both male and female. It showed that it isn`t permissible for the male to look at or touch the Awrah of female as doing so violates the teachings of Sharia and assaults modesty, since the Prophet (PBUH) said (What means): "A man must not look at a man's private parts nor must a woman look at a woman's private parts." {Muslim}.
In principle, it is forbidden to look at or touch the Awrahs save for a necessity. Therefore, Islam permitted looking and touching for the necessity of treatment, but this necessity has limits where the jurisprudential maxim states that necessities are estimated by the extent there of.
Based on the above, in principle, a woman should be treated by a doctor from the same sex. Thanks to Allah, Muslim countries are replete with experienced female doctors through whom the collective duty is met, and they are good at what they do. Therefore, we are of the view that it is safer for men to specialize in fields other that Gynecology and Obstetrics. However, if there was no female doctor specialized in this field and it was necessary that the female patient be treated by a male doctor then a woman or a Mahram should be present when the patient is being examined. This doctor should also fear God, lower his gaze and avoid touching the patient`s Awrah save for a necessity. And Allah the Almighty Knows Best.