To get a sex change, the Doctor has to write down that the patient has "Gender Dysphoria" which is classified as a mental illness.
The Military still has a long list of reasons why you can be barred from serving. That list includes a lot of the things that are commonly associated with Gender Dysphoria.
If you want the list, I can leave a link. But I'm not really in the mood for a full debate right now.