Anas ibn Malik reported: The Prophet, peace and blessings be upon him, said, “If Allah puts the Muslim servant to trial in his body, Allah says: Record his righteous deeds for him that he used to do. If he is healed, it is his cleansing and purification. If his soul is taken, he will be forgiven and shown mercy.”
Source: Musnad Aḥmad 12503
Grade: Sahih li ghayrihi (authentic due to external evidence) according to Al-Arna’ut
عَنْ أَنَسِ بْنِ مَالِكٍ عَنْ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ أَنَّهُ قَالَ إِذَا ابْتَلَى اللهُ الْعَبْدَ الْمُسْلِمَ بِبَلَاءٍ فِي جَسَدِهِ قَالَ اللهُ اكْتُبْ لَهُ صَالِحَ عَمَلِهِ الَّذِي كَانَ يَعْمَلُهُ فَإِنْ شَفَاهُ غَسَلَهُ وَطَهَّرَهُ وَإِنْ قَبَضَهُ غَفَرَ لَهُ وَرَحِمَهُ
12503 مسند الإمام أحمد
12503 المحدث شعيب الأرناؤوط خلاصة حكم المحدث صحيح لغيره في تخريج المسند