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?
When EMTALA was passed, its authors were most afraid that legal status would become an issue, so they included a strict prohibition against status checking, and included (just because they felt like piling on) the requirement that all medical services in a hospital anywhere in the US be made available in 73 languages 24 hours a day, 7 days a week.