Texas doesn't actually care. The whole point is simply to harass and intimidate people.
One of two things will happen. Either non-citizens will be scared out of seeking treatment in the first place, resulting in spreading health maladies and possibly unnecessary deaths. Or, they will quickly realize, as you point out, simply lying about it is an easy and effective way to move on and get the care they need without repercussions. In the latter case, Texas Republicans will look for a new way to harass illegal immigrants.