Musnad Ahmad 1057
It was narrated that ‘Ali (رضي الله عنه) said:
l fell sick and the Prophet (ﷺ) came to me when I was saying: O Allah, if my time has come then grant me relief; if it has not yet come then heal me or grant me well being, and if this is a trial then grant me patience. He said: `What did you say?` I repeated it to him, then he touched me with his hand and said: `O Allah, heal him” or “grant him well being.” And I never suffered that sickness again after that.
حَدَّثَنَا وَكِيعٌ، عَنْ شُعْبَةَ، عَنْ عَمْرِو بْنِ مُرَّةَ، عَنْ عَبْدِ اللَّهِ بْنِ سَلِمَةَ، عَنْ عَلِيٍّ، رَضِيَ اللَّهُ عَنْهُ قَالَ اشْتَكَيْتُ فَأَتَانِي النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ وَأَنَا أَقُولُ اللَّهُمَّ إِنْ كَانَ أَجَلِي قَدْ حَضَرَ فَأَرِحْنِي وَإِنْ كَانَ مُتَأَخِّرًا فَاشْفِنِي أَوْ عَافِنِي وَإِنْ كَانَ بَلَاءً فَصَبِّرْنِي فَقَالَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ كَيْفَ قُلْتَ قَالَ فَأَعَدْتُ عَلَيْهِ قَالَ فَمَسَحَ بِيَدِهِ ثُمَّ قَالَ اللَّهُمَّ اشْفِهِ أَوْ عَافِهِ قَالَ فَمَا اشْتَكَيْتُ وَجَعِي ذَاكَ بَعْدُ‏.‏