Hospitals are generally protected
"The protection to which civilian hospitals are entitled shall not cease unless they are used to commit…acts harmful to the enemy. Protection may, however, cease only after due warning has been given, naming, in all appropriate cases, a reasonable time limit, and after such warning has remained unheeded.”[5]
While the period of ‘reasonable time’ is not specified, it must be ‘long enough’ to allow the hospital to respond to unfounded accusations, to cease the unlawful acts and retain its protected status, or to remove the hospital patients to safety before an attack.
However, even in a situation where a hospital is acting as a command centre, and after due warning has been given, any attack has to adhere to the principles of IHL in order to be lawful, namely proportionality and precaution. Only the specific part of the hospital in question, one particular wing, for example, could be targeted. Crucially, however, the damage to civilians must be carefully measured and it cannot exceed the expected military advantage of the attack. The threshold of proportionality for essential civilian infrastructure, including medical facilities and hospitals, is very high."
Operation Protective Edge: Medical facilities and IHL - Diakonia