Automatic door
Question
A sick person is staying in a hospital over Shabbos. There is an automatic electronic door at the hospital entrance. The door opens when someone walks through it. If our patient needs to pass through this door, and this does not involve a life-threatening danger, is there a way he can walk through it on Shabbos?
Answer
Dear …!
After a gentile or a doctor, who is allowed to do it, walk through this door, our patient can just follow them. And even if a Jew who does not keep Torah and mitzvot, and is not aware that there is a problem with walking through such a door on Shabbos, walked through it, the patient can follow him.
Source
Shulchan Oruch, section Orach Chaim, ch. 318, §1; Mishnah Berurah, ibid., subsection 7. (The author of The Mishnah Berurah decreed that in a case of need, one can utilize results of labor that was unintentionally performed on Shabbos by somebody else.)