Medics, field hospitals, and other medical personnel/facilities are specifically protected by the Geneva convention from being specifically targeted or attacked by combatants. Doing so is considered a war crime, so more often than not, soldiers on both sides were specifically instructed to not fire upon medical personnel unless they were actively taking up arms while wearing Medic insignia (which is also against the convention, IE the use of medic insignia to deceive the enemy for tactical advantage). Medics however lose this protection if they become active combatants (actively firing a weapon at the enemy, assisting with crew served weapons, etc.). Though it was not unheard of for medics to pick up arms to defend themselves and their charges if they felt they were in immediate danger of being overrun and killed (rather than captured).
To answer your question, both Germany and the United States were signatories of the Geneva Conventions of 1906 and 1929. So in theory, neither side should have targeted or attacked medical personnel or facilities, but this was not necessarily always the case on either side.
As far as how often this held up in practice, it varies but more often than not in the Western ETO, medical personnel and facilities weren't specifically targeted by either Axis or Allied forces. The two main reasons being that willfully attacking an enemy's medical personnel invited the possibility retaliatory attacks against your own medical personnel, as well as the possibility that enemy medical personnel would refuse to provide medical treatment to captured wounded. Not to mention, ignoring the ethical constraints of firing at someone providing medical care, medics are non-combatants and are far far less of a threat or priority to take out or suppress in comparison to an enemy soldier actively fighting.
The same cannot be said as much for the Pacific theater, where Japan was not a signatory (and where both the US and Japan are recorded as having fired upon medical personnel as well as refusing medical treatment to enemy wounded), as well as the Eastern Front.
Sources:
Previous answer to a similar question How dangerous was it for medic during warfare?