Mishkat al-Masabih 1528
Abu Huraira reported God’s messenger as saying:
On the day of resurrection God most high will say, “Son of Adam, I was sick and you did not visit me.” He will reply, “My Lord, how could I visit Thee when Thou art the Lord of the universe?” He will say, “Did you not know that my servant so and so was ill and yet you did not visit him? Did you not know that if you had visited him you would have found me with him? Son of Adam, I asked you for food but you gave me none.” He will reply, “My Lord, how could I feed Thee when Thou art the Lord of the universe?” He will say, “Did you not know that my servant so and so asked you for food and yet you gave him none? Did you not know that if you had fed him you would have found that with me? Son of Adam, I asked you for drink but you gave me none.” He will reply “My Lord, how could I give Thee drink when Thou art the Lord of the universe?” He will say, “My servant so and so asked you for drink but you gave him none. Did you not know that if you had given him something to drink you would have found that with me?’’

Muslim transmitted it.
وَعَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: 
" إِن الله عز وَجل يَقُولُ يَوْمَ الْقِيَامَةِ: يَا ابْنَ آدَمَ مَرِضْتُ فَلَمْ تَعُدْنِي قَالَ: يَا رَبِّ كَيْفَ أَعُودُكَ وَأَنْتَ رَبُّ الْعَالَمِينَ؟ قَالَ: أَمَّا عَلِمْتَ أَنَّ عَبْدِي فُلَانًا مَرِضَ فَلَمْ تَعُدْهُ؟ أَمَا عَلِمْتَ أَنَّكَ لَوْ عُدْتَهُ لَوَجَدْتَنِي عِنْدَهُ؟ يَا ابْنَ آدَمَ اسْتَطْعَمْتُكَ فَلَمْ تُطْعِمْنِي قَالَ: يَا رَبِّ كَيْفَ أُطْعِمُكَ وَأَنْتَ رَبُّ الْعَالَمِينَ؟ قَالَ: أَمَا عَلِمْتَ أَنَّهُ اسْتَطْعَمَكَ عَبْدِي فُلَانٌ فَلَمْ تُطْعِمْهُ؟ أَمَا عَلِمْتَ أَنَّكَ لَوْ أَطْعَمْتَهُ لَوَجَدْتَ ذَلِكَ عِنْدِي؟ يَا ابْنَ آدَمَ اسْتَسْقَيْتُكَ فَلَمْ تَسْقِنِي قَالَ: يَا رَبِّ كَيْفَ أَسْقِيكَ وَأَنْتَ رَبُّ الْعَالَمِينَ؟ قَالَ: اسْتَسْقَاكَ عَبْدِي فُلَانٌ فَلَمْ تَسْقِهِ أما إِنَّك لَو سقيته لوجدت ذَلِك عِنْدِي ". رَوَاهُ مُسلم