All perfect praise be to Allah the Lord of the Worlds. May His peace and blessings be upon our Prophet Mohammad and upon all his family and companions.
Medicine is one of the noble humanitarian professions that is always in demand and is considered a communal obligation. Therefore, a certain group of students must be capable of practicing it to fulfill this humanitarian duty. In addition, a physician needs to possess the highest level of skill and professionalism to be able to deal with patients.
In principle, a woman should be treated by a woman and a man by a man. Accordingly, sufficient measures should be taken to ensure the availability of specialized doctors from both genders. This is considered a communal obligation in Islam. However, if a specialized doctor of the same gender is not available, and there is a necessity for a man to treat a woman or vice versa, it is permissible in that case.
It is mentioned in [Hashiyat al-Bajirmi, Vol. 3/P. 380] from the books of the Shafi'i scholars: "It is a condition that there isn`t a man capable of handling the treatment of a man. That is, if the patient is a man and the healer is a woman, it is a condition that there isn`t a man who can treat him."
In some situations, the patient may be a woman, and it may be difficult to find a female practitioner. Additionally, a man might be more skilled and proficient, or the cost of treatment may be affordable for him while unaffordable for a female practitioner. In such cases, it is permissible for the woman to seek treatment from a male doctor. However, there are legal conditions and guidelines for a man treating a woman and vice versa, including:
Firstly, avoiding looking at or touching private parts except when necessary. Islamic law has defined the private parts for both men and women, and it is not permissible for a man to gaze at the private parts of a non-mahram woman (not a close relative) or touch them. This is considered a violation of the teachings of Islamic law and an infringement upon modesty and proper conduct. The Prophet Mohammad (peace be upon him) said: "A man should not see the private parts of another man, and a woman should not see the private parts of another woman…." (Transmitted by Muslim). The general rule is that looking at or touching private parts is prohibited unless there is a genuine necessity. In such cases, Islam permits looking and touching for the purpose of medical treatment, provided it does not exceed the limits of necessity, as the extent of necessity is determined by its urgency.
Secondly, it is obligatory to avoid situations of seclusion (khulwah) that are deemed impermissible. The rule for such situations is when a man and a woman are alone in a place where there is a potential for suspicion, such as when a man and a woman are alone in an unmonitored area or when the door of a room is closed. Seclusion is eliminated when examining a female patient, or in operating rooms, in the presence of her husband, a mahram (a close male relative), or the presence of a female nurse with the doctor. In [Boshra al-Karim, Vol. 1/P. 602], from the books of the Shafi'i scholars, it is mentioned: "It is permissible for a man to be alone with two women, but not the opposite, meaning it is impermissible for two men to be alone with a woman."
Thirdly, it is incumbent upon the doctor, in general, to consider the ethics of medicine, including the fear of Allah in treating patients, sincerity in one's work, and adhering to noble ethical standards. And Allah the Almighty knows best.