All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Lying is a reprehensible quality as per the Sharee‘ah, and it is possible to bring happiness to the patient and boost his hopes without lying. The scholars said: “It is prohibited to lie about any praiseworthy purpose that can be realized through truthfulness,” as Ibn Hajar Al-Haytami said in Az-Zawajir.
You may realize that objective by relieving the patient, cheering him up with kind words, and urging him to have good faith in his Lord and boost his hope in Him.
Ghithaa’ Al-Albab reads: “A visitor of a sick person should ask the patient how he is doing, cheer him up, and bring happiness to his heart. The Prophet said: “When you visit a sick person, cheer him up, and give him hope of a long life for that does not change anything (of the Divine Decree), but it will cheer the heart of the sick person.” It is an inauthentic Hadeeth as stated in Al-Furoo’.”
Al-Qaari said in Al-Marqat: “The Prophet said: ‘When you visit a sick person, cheer him up, and give him hope of a long life,’ meaning ease his sadness about the approach of death by saying nice words like: ‘No harm, (it will be a) purification (from sins), Allah Willing,’ or ‘May Allah prolong your life and bless you with recovery and wellbeing.’ It could also mean relieving his distress by boosting his hopes of (recovery and) a long life. At-Taybi, may Allaah have mercy upon him, said: ‘It means to give him hope of a long life, and the Lam letter in (له) is used for emphasis.”
Therefore, the permissible alternatives are sufficient and there is no need to opt for what is impermissible. These kind words and sincere wishes of recovery and well-being such as: “No harm, (it will be a) purification (from sins), Allah Willing,” “Allah is Able to bless you with recovery, and He has blessed many other sick people with more deteriorated health conditions (serious illnesses),” and the like, are adequate and leave no need for lying.
In addition, informing a sick person of his disease may be of real benefit to the patient; it may prompt him to hasten to write an obligatory will, fulfill the due rights of others over him, and the like before he is unable to do so. If people lied to such patients, these rights may be lost.
Moreover, the applicable laws oblige doctors to inform a patient of his health condition. He should be informed of his health condition at the right time and in an appropriate manner that mitigates the effect of the shock.
Allah knows best.