Our teacher, the Beit Yosef, wrote: Nevertheless, it is forbidden for a kohen to enter a house in which there is a goses. Thus far his words. Our teacher, the Rema, wrote regarding this: And there are those who permit it, and it is good to be stringent. Thus far his words. For there is a dispute regarding this in Nazir (Nazir 43a), as there are those who expound "to profane himself" that one who enters to a goses, even though he does not become tamei until he dies, nevertheless profanes his priesthood. And there are those who disagree in the Gemara there. Most of the poskim ruled for prohibition, and so the Acharonim (Bach and Shach) agreed. And they disagreed with our teacher, the Rema, who wrote "it is good to be stringent," for by the letter of the law it is forbidden. In our times, the kohanim are careful regarding this and exit the house of the goses, and may their strength be firm for they sanctify the priesthood. However, if the kohen is sleeping—there is no need to awaken him from his sleep before he dies (Shach, subsection 4). And when the kohen is a doctor—it is permitted for him to enter to the goses to see if perhaps he can provide him a cure, for pikuach nefashot overrides everything. And if he dies—he shall flee from there. (And those kohanim who are doctors and cast off the yoke, who attend to the dead, and we are forced to call them according to the laws of the kingdom—the sin is not upon us, as the Chatam Sofer wrote in siman 338, and the Pitchei Teshuva cited him, see there.)
וכתב רבינו הבית יוסף: ומכל מקום אסור לכהן ליכנס בבית שיש בו גוסס. עד כאן לשונו. ורבינו הרמ"א כתב על זה: ויש מתירין, וטוב להחמיר. עד כאן לשונו. דיש פלוגתא בזה בנזיר (נזיר מג א), דיש דורשין "להחלו" דהנכנס לגוסס, אף על פי שאינו מטמא עד ימות, מכל מקום מחלל כהונתו. ויש חולקין בגמרא שם. ורוב הפוסקים פסקו לאיסור, וכן הסכימו האחרונים (ב"ח וש"ך). וחלקו על רבינו הרמ"א שכתב "וטוב להחמיר", דמעיקר הדין אסור. ובזמנינו נזהרים הכהנים מזה ויוצאים מבית הגוסס, ויישר כחם שמקדשים את הכהונה. מיהו אם הכהן ישן – אין צורך להקיצו משנתו קודם שימות (ש"ך סעיף קטן ד). וכשהכהן הוא רופא – מותר לו ליכנס להגוסס לראות אולי ימציא לו רפואה, דפיקוח נפשות דוחה הכל. ואם ימות – יברח משם. (ואלו הכהנים רופאים פורקי עול שמשמשים את המתים, ואנחנו מוכרחים לקוראם על פי חוקי המלכות – אין עלינו העון, כמו שכתב החת"ם סופר בסימן של"ח, והביאו הפתחי תשובה, עיין שם.)