All praise is due to Allah, and may peace and blessings be upon our Master, the Messenger of Allah.
Islam encourages seeking medical treatment for illness, since Prophet Muhammad (PBUH) said: "Seek treatment, for Allah, the Exalted, has not created a disease except that He has also created a cure for it—except old age." [Abu Dāwood].
It is an act of Sunna (recommended) for a sick person to seek treatment, as Allah Has Made it a means of recovery. Besides, Al-Imam Baʿshan Al-Shāfiʿī (may Allah have mercy on him) stated: "Seeking treatment is recommended when accompanied by reliance on Allah and contentment with His decree. This is because it combines the virtue of trusting in Allah with the act of taking the means He created for healing." [Bushrā Al-Karīm/vol.1/pp.445].
According to the principles of Islamic jurisprudence, it is generally impermissible to use impure (Najis) substances for treatment. However, scholars have made an exception in cases of necessity—excluding pure alcohol—when no pure alternative is available. Since, Sheikh Al-Islām Zakariyyā Al-Anṣārī (may Allah have mercy on him) said: "It is permissible to treat illness with impure substances—excluding intoxicants—if no pure alternative is available, such as snake meat or urine." [Asnā Al-Maṭālib/vol.4/pp.159].
If treatment with substances that are wholly impure is permitted in cases of necessity, then it is all the more permissible to use compounds that merely contain impure components under the same conditions.
As for the use of parts from deceased human bodies, scholars are unanimously agreed that it is impermissible when a suitable alternative exists—even if the alternative is impure. However, the Shāfiʿī school of thought allows such use in cases of absolute necessity, even when the only available alternative is impure. In this regard, Al-Imam ʿAbd Al-Ḥamīd Al-Sharwānī (may Allah have mercy on him) said: "The prohibition on using bones from deceased humans applies when a suitable substitute is available—even if impure. However, if no suitable alternative exists, then using bones from a deceased human is likely permissible, just as consuming human flesh is permitted for the one in absolute need who finds nothing else to survive." [Ḥawāshī Al-Sharwānī and Al-ʿAbbādī on Tuḥfat Al-Muḥtāj/vol.2/pp.126].
In conclusion, it is permissible to use impure substances for medical treatment, excluding pure alcohol, when no pure alternative is available. However, if a permissible and pure option does exist, then it is not allowed to resort to impure means. Likewise, it is permitted to use body parts from deceased humans for treatment only when no suitable alternative can be found, even if the available alternatives are impure. This ruling applies equally to Muslim and non-Muslim patients, with no distinction made between them. And Allah The Almighty Knows Best.