All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
If a fence or the like was built around this prayer location, then according to many scholars, it has become an endowment (Waqf). Al-Bujayrimi said: “If one made a fence around a spot in order to make it a mosque then it becomes a mosque, even if he did not say (that it is a mosque) or did not build on it or make a roof for it; and the same applies to the ‘Eed Musalla (prayer place). As-Subki said that it cannot be considered a mosque unless a roof is made for it.”
However, if no fence or the like has been built around that land, then it is not an endowment. If it is not an endowment, then it is permissible to build a hospital on it and there is nothing wrong in doing so. But if it is an endowment, then you should leave it as it is and build the hospital in another place. For more benefit, please refer to Fatwa 117368.
Nonetheless, some scholars are of the view that it is permissible to change the endowment for the greater advantage. Ibn Taymiyyah said: “It has been confirmed that the rightly guided Caliphs – like ‘Umar and ‘Uthmaan – changed the form of an endowment for the greater interest; rather, ‘Umar ibn Al-Khattaab went so far as to change the old mosque of Al-Koofah to a market for selling dates and he built a mosque for people in another place.”
Allaah Knows best.