Yes, but it’s not a guaranteed means to staying - it’s an H1B which is a work visa and not permanent. It would be the same for the UK, although you are less likely to see equivalent headlines to “H1B doctor deported” there.
There are so many ifs to this route, the first if is just being accepted to medical school in the first place as an international.