When it comes to refuos, medications, we must believe that refuah comes from Hashem. A person must take medications, consult doctors, etc., because he is obligated to act according to the laws of nature; however, he must simultaneously believe that Hashem is healing him. When he engages in natural means of refuah, he attains refuah from Hashem, and not directly from the means of hishtadlus he undertook.
Sefer Chut HaMeshulash, written by the grandson of the Chasam Sofer zy'a, tells the following story:
"When the Ksav Sofer zt'l (a son of the Chasam Sofer) was six years old, he was very sick, and the doctors predicted he would die. The chevra kadisha was summoned to prepare for what they thought was the inevitable. The chevra kadisha lit candles and davened the prayers that are said at such times. The doctors sat in the room and spoke with my grandfather, the Chasam Sofer. They said, 'We know you are a holy man of G-d, but your prayers won't be able to save your son this time. Nothing can save your son.' When the Chasam Sofer heard those words, he stood in a corner of the room next to a box of his handwritten divrei Torah and he said a short tefillah, and the child shouted Shma Yisrael...! Just moments earlier, the child was so weak, he couldn't say a word, and now he shouted Shma Yisrael! Hashem answered the father's and son's tefillos. The doctors said, "Now we know that you are a man of G-d! According to our understanding, it was impossible for this to occur!" The Chasam Sofer said, "I never lost hope, not even for a moment. There is no limit to Hashem's kindness." The Chevra Kadisha extinguished the candles they had lit and went home.
The Chut HaMeshulash writes that when the Ksav Sofer turned thirteen, the Chevra Kadisha gave him a present, a utensil made of gold. Inside were the thin wax candles they had lit when they thought he would die.
Shiltei Giborim (Sanhedrin, end of Ben Sorer u'Moreh, page 18b in the Rif) states, "Many times, doctors predict that a person will die, but in reality, they soon recover and become better." The Meiri (Magan Avos) teaches, "Even when doctors tell you that there is limited or just one method with which to heal him, there are many ways to heal him; only the doctors don't see them."
Tzaddikim say: The Torah permits doctors to heal, but they weren't given permission to cause despair. They have no right to say that someone will die. Anyway, how do they know that the patient will die? Hashem can heal the illness in all situations. We should ignore the doctors when they pass these disheartening verdicts and not lose our bitachon in Hashem.