All large hospitals have emergency generators. Of course they are supposed to be for emergencies, not for dealing with regularly intermittent power. That is typically dealt with advertised in advance power shutdowns to residential areas, and in richest countries, by not sending the signal that remotely turns on your water balloon heater during cheap hours.