This matter is subject to further discussion.
For those whose presence is required in the hospital, such as guards etc., or for patients who are unable to get to the mosque, they do not have to go out to the mosque; rather they should pray where they are with the jamaa’ah that they are able to pray with.
But for those who can reach the mosque, they have to do so, in accordance with the shar’i evidence, such as the hadeeth in which the Prophet (peace and blessings of Allaah be upon him) said: “Whoever hears the call to prayer and does not respond, there is no prayer for him (his prayer is not valid), except for those who have an excuse.” It was said to Ibn ‘Abbaas (may Allaah be pleased with him), What is the excuse? He said, Fear or sickness. (Narrated by Ibn Maajah and al-Daaraqutni; classed as saheeh by Ibn Hibbaan and al-Haakim; its isnaad is saheeh).