Taking medicine, in general, is either allowed or recommended, but not required. If it is likely that you will die or be severely harmed by refusing medicine or treatment then you must take it. However, if taking such medicine or treatment is likely to also result in serious harm (along with the benefit it will bring) then it remains optional: you may take it or leave it.
What the Prophet Said
“Do not cause harm, and don’t get harmed [lā ḍarar wa lā ḍirār].” [Muwaṭṭa’ #1435]
Shaykh Mustafa Umar