It is narrated from Sayyiduna Ali (may Allah be pleased with him) that he said: "The Prophet (peace and blessings be upon him) passed by me while I was ill, and I was saying (this supplication): 'O Allah, if my appointed time has come, then give me rest; if it is still delayed, then raise me up (restore me to health); and if it is a trial, then grant me patience.' Then he (peace and blessings be upon him) struck my chest with his blessed hand and said: 'O Allah, grant him well-being and cure him.' After that, I never again suffered that pain."
Imam Ahmad (may Allah have mercy on him) narrated it from Yahya bin Sa'id, Affan, Waki' and Ghundar, from Shu'bah (may Allah have mercy on him).
Ishaq bin Rahwayh (may Allah have mercy on him) narrated it from al-Nadr bin Shumayl, from Shu'bah (may Allah have mercy on him).
Imam al-Tirmidhi (may Allah have mercy on him) narrated it from Muhammad bin al-Muthanna, from Ghundar, from Shu'bah (may Allah have mercy on him), and said: "This hadith is hasan sahih."
Imam al-Nasa'i (may Allah have mercy on him) narrated it from Isma'il bin Mas'ud, from Khalid, from Shu'bah (may Allah have mercy on him).
Imam Ibn Hibban (may Allah have mercy on him) narrated it from Umar bin Muhammad al-Hamdani, from Bundar, from Yahya and Muhammad, from Shu'bah (may Allah have mercy on him).
Imam al-Daraqutni (may Allah have mercy on him) was asked about it, and after mentioning the disagreement in its chain he said: "The correct version is that of those who narrated it as: from Amr bin Murrah, from Abdullah bin Salimah (may Allah have mercy on him), from Sayyiduna Ali (may Allah be pleased with him)."
Related hadith on this topic