Which by law they're allowed to do.
That law needs to be changed. Hospitals should be allowed tp predicate ER treatment on proof of citizenship or legal entry into the USA. Won’t happen, but I can dream, can’t I?