that (W)ith regard to the treatment of the terminally ill, the element of pain and suffering plays an important role in determining whether or not treatment may be withheld. Both Rabbi Feinstein and Rabbi Shlomo Zalman Auerbach* have ruled that
a dying patient should not be kept alive by artificial means where the treatment does not cure the illness but merely prolongs the patient's life temporarily and the patient is suffering great pain; all the more so where the medical treatment actually causes pain and suffering.(emphasis not in original) ...
In the case of a terminal patient who is suffering pain,
a distinction is drawn between treatment designed to prolong his life— albeit temporarily— and treatment aimed at relieving pain. According to Rabbi Feinstein, it is proper to administer the latter form of treatment but not the former. (Another question is whether it is permitted to administer pain relieving treatment which may shorten the patient's life. Rabbi Feinstein's responsum refers to drugs which "relieve pain but do not shorten the patient's life even for one moment". On the other hand, in a responsum of Rabbi Yaakov Emden, ... Rabbi Emden rules that it is permitted to undergo an operation to relieve extreme pain even where there is a risk that the patient may die as a result.)
Another distinction drawn in the halachic literature is that between routine treatment, which may not be withheld even from the dying patient who is suffering pain, and non-routine treatment, which may be withheld. Amongst the halachic authorities there are differences of opinion as to where to draw the line between routine and non-routine treatment. According to Rabbi Auerbach, food and oxygen, insulin injections, blood transfusions or the provision of antibiotics and other drugs fall under the heading of routine treatment. Rabbi Ovadia Hadava, who served on the Rabbinical Court of Appeals in Israel, on the other hand, has written that it is permitted to withhold insulin injections from a terminally ill patient who is in great pain.
Another question of crucial importance concerns the definition of"gossess" (a person in the process of dying). The question of withholding treatment, as we have seen from the Shulchan Aruch, relates to a "gossess"— a person in the process of dying. But when is that process regarded as beginning? A strict view is taken by Rabbi Bleich— that the process is regarded as beginning when the doctors believe that the patient has at most three days to live. Rabbi Hadava, in the responsum I have just referred to, takes a much broader view. In response to a question as to whether it is permitted to withhold insulin treatment from a terminal patient, he addresses the question of whether the patient is a "gossess". He answers that where the doctors have diagnosed his case as being terminal and the patient is suffering great pain, he should certainly be regarded as a "gossess"
* Rabbi Shlomo Zalman Auerbach is a famous Torach sage of the revered Zalman Rabbincal dynasty
Link:
http://www.jewishvirtuallibrary.org/jsource/Judaism/euth.html#D4