The Messenger of Allah ﷺ said, "When Allah tests his Muslim servant with an affliction in his body, He says to the angel, 'Record for him the righteous deeds he used to perform.' If He restores him to health, He washes him clean and purifies him, and if He takes his soul, He forgives him and grants him mercy."
حدثنا عفان حدثنا حماد بن سلمة حدثنا أبو ربيعة
أن رسول الله ﷺ قال إذا ابتلى الله العبد المسلم ببلاء في جسده قال للملك اكتب له صالح عمله الذي كان يعمل فإن شفاه غسله وطهره وإن قبضه غفر له ورحمه