Even if a doctor says there is no chance of recovery, one should not despair. There are an extremely large amount of cases when doctors have given up hope and nevertheless the patient recovered. While it is irresponsible to disregard reliable medical advice when something practical can be done, doctors are only human and are fallible. It is important for doctors themselves to realize this and even when the situation appears bleak, they should realize that while we cannot rely on miracles, medical miracles do occur.
Whenever Rabbi Yehoshua Leib Diskin was told that a doctor had given up hope on a patient, Rabbi Diskin would comment, "A doctor has a right to heal, but who gave him the authority to despair?"
(Amud Aish, p.158; Gateway to Happiness, p.377)