Praise be to Allaah.
There is nothing wrong with your having a contract and working with the hospital that deals with insurance companies to treat patients at their expense.
The fact that the hospital benefits financially from the insurance companies does not affect your work at all, because you get paid for treating patients, and that has nothing to do with the insurance companies directly.
Although the hospital acquires money by haraam means, you are taking money from it in return for permissible work, and the ruling on money changes according to the way in which it is acquired.
Al-Bukhaari (5097) and Muslim (1504) narrated that âAaâishah (may Allah be pleased with her) said: The Messenger of Allaah (blessings and peace of Allah be upon him) came in when the earthen pot was on the fire. Some bread and ordinary condiments were brought to him. He said: âDo I not see an earthen pot?â It was said: That is meat that was given in charity to Bareerah and you do not eat from charity. He said: âIt is charity for her and a gift to us.â
Al-Nawawi said: This indicates that when the nature of a thing changes, the ruling on it also changes.
Sharh al-Nawawi âala Muslim, 5/274
Ibn âAbd al-Barr said: In the words âIt is charity for her and a gift to usâ there is an indication that what is haraam for a particular reason is no longer haraam when that reason no longer applies. The prohibition ceases to apply when the reason ceases to apply. Do you not see that a dirham that is seized by force or stolen is haraam for the one who seized it or stole it because of his seizing it or stealing it, but if he gives the seized or stolen item away willingly, it becomes permissible for the recipient, although it is the same dirham. End quote.
Shaykh Ibn âUthaymeen (may Allah have mercy on him) said: If something is haraam because of the way in which it was acquired, the sin is only upon the one who acquired it, not on the one who takes it in a permissible way from the one who acquired it. End quote.
Al-Qawl al-Mufeed âala Kitaab al-Tawheed, 3/112
Based on that, there is nothing wrong with you working in this hospital, and the sin of the contract with the insurance company will be upon those who drew up that contract with them.
And Allah knows best.