There is nothing wrong in working in optometry and medical treatment of patients. It is something recommended and urged by sharia to relieve the pains of patients and their sufferings and as long as you stick to the Islamic rules of medical treatment, i.e. the rules of avoiding seclusion of a man and a woman (Khalwah), the rules of exposing the parts of the body that are not meant to be exposed to others (`Awrah), except in cases of exigency or real, compelling need.

To shed more light on this, Sheikh Ahmad Kutty, an Islamic scholar stated:
“Islam has stipulated very strict rules with regard to the permissible boundaries of interactions/physical contacts between males and females who are not related either through marriage or blood relations.

According to these rules, it is considered Haram for males and females who are not related in marriage or blood to be in private or come into direct physical contacts with one another. As everything that leads to Haram is Haram, they ought to avoid circumstances or avenues that might lead to such close contacts as far as possible.

The above rules are designed specifically to protect us against our own vulnerabilities and weaknesses for as Allah says in the Qur’an, “Verily mankind has been created weak.” (An-Nisa’: 28) As one poet rightly remarked, “All illicit relations can be traced to a single unlawful gaze, just like all burning fires often proceed from a single spark.”

Having said this, however, I must add the following:

Since Islam takes into account the realities of everyday life, and, therefore there may be situations where such contacts are necessary, and therefore unavoidable, the scholars of sharia have allowed certain exceptions to the above rule: Thus they have considered such contacts permissible if undertaken strictly for the purpose of saving lives or administering essential treatments wherever applicable. This special ruling falls under the rule of necessity, which stipulates that in exceptional cases what has been otherwise considered as impermissible becomes permissible.

In order to qualify for permission under the rule of necessity, however, certain conditions apply: Firstly, the physician of the same gender must be unavailable; secondly, contacts should be kept to the absolute minimum limit as necessary.”