In what situation is a doctor allowed to go to the hospital to work on a patient on Shabbos? And is he allowed to take pay for his work?
In general a doctor needs to be in contact with a competent Rav for general guidelines for the multiple and constant Shaylos that relate to Shabbos and Yom Tov. It is self understood that any Jewish doctor should make his absolute best efforts that he does not need to be on call for Shabbos and Yom Tov.
Most views hold that Shabbos is דחויה ולא הותרה. When the doctor must attend a sick patient on Shabbos (which again is a topic of it’s own and should be addressed by a Rav who knows the doctor) who needs emergency medical attention at the hospital, the doctor may travel to the patient on Shabbos. Walking is the best if that is possible. If it is too far and/or is technically feasible albeit very difficult but it can cause the doctor to be extra tired, then the doctor may travel by car.
In any case a doctor may not collect payment for Shabbos work.
ראה ארחות שבת כ הערה מג.