Ruling on working in medical coding to transfer patient information and treatment costs to insurance companies
Question

I want to ask that job in field of medical coding is halal or haram.medical coding job is in multi-national company which receive information from hospital and then convert it to medical codes then send it to insurance company.Medical coder gives codes to patient information and give codes to treatment that are carried out by the patients.Then these codes are passed to medical billers which gives information to insurance company ... Then the insurance company pay the doctor who carried out the patient tests. medical coding does not directly deals with insurance company.patient in America usually have there insurance and does not carry money for hospital test purpose.so when doctor checks the patient and carry out their tests insurance company pays for patient test to doctors ...Well i know insurance is not allowed in islam so Does it count that as a medical coder we are associating or helping in sin of the insurance company.is it halal to do a job as a medical coder.please help me...i am in desperate need to find its answer
Praise be to Allah.Firstly:
Ruling on commercial insurance
Commercial insurance is haram in all forms, whether it is life insurance, health insurance or insurance on property and belongings.
But in the case of health insurance – for which the insured person does not receive money; rather the insurance company covers the costs of medical tests and treatment – the reason why it is prohibited is the fact that it is based on ambiguity and gambling, not riba (usury).
Whatever is like that is permissible in the case of necessity.
The reason why it is ambiguous is that the insured person pays money without knowing whether he will receive medical services equivalent to what he paid, or more or less than that.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said: The harm caused by an ambiguous transaction is less grievous than that caused by a riba-based transation. Hence there is a concession in the case of need, because prohibiting the ambiguous transaction completely would cause more harm than the harm caused by its ambiguity.  Examples of that include the sale or purchase of property, (which is valid) even though you do not know what exactly is inside the walls and foundations; or the sale or purchase of a pregnant or lactating animal, (which is valid) even though you do not know how many offspring or how much milk it will produce, and even though it is prohibited to sell the offspring in the womb on its own, and also the milk in the udder on its own, according to the majority. Another example is the sale or purchase of fruit after it has started to show signs that it will be fine; this transaction is valid, as is indicated by the Sunnah and as is the view of the majority of scholars, such as Malik, as-Shafa‘i and Ahmad, even though the other factors which are required for the fruit to mature fully have not yet been created."(Al-Fatawa al-Kubra 4/21).
And he (may Allah have mercy on him) said: The same applies to ambiguous transactions, which come under the same heading as gambling, but some types may be permitted in the case of necessity and when the benefit outweighs the harm."(Majmu‘ al-Fatawa 14/471).
A number of contemporary scholars are of the view that health insurance is permissible in the case of necessity, including Dr. ‘Ali Muhyi’d-Din al-Qurrat Daghi, Dr. ‘Abd ar-Rahman ibn Salih al-Atram, Dr. Yusuf ash-Shubayli, and Dr. Khalid ad-Du‘ayji.
So if someone needs health insurance because he cannot afford treatment otherwise, or paying for it would cause real hardship for him, it is permissible for him to take out health insurance.
If someone has no choice but to take out health insurance, or he is compelled to do so, or his company compels him to do that, there is nothing wrong with him benefitting from it, as is quite clear.
Secondly:
Working in the field of medical coding
There is nothing wrong with working in the field of medical coding, and that is not regarded as helping in something that is haram, because some people need this insurance, or are compelled to take it out, or their company compels them to have this insurance for themselves or for their families. In such cases, it is permissible for them to benefit from the health insurance, as noted above, and there remain those who do not need it, but it is difficult to tell who is who.
Moreover, the role of the medical coder and the company he works for is to help the hospital to charge the fees for the services it has provided, and it has no connection to helping anyone to take out insurance, whether the insurance is prohibited or permissible; rather the insurance is a contract that came before the work of the coder.
And Allah knows best.