Is a Complete Sex Change Operation Possible?

In one of Lois Bujold's books, a character is changed from female to male via a high tech medical procedure. In Karl Gallagher's Torchship series, sex change operations are treated as routine options–one minor character has changed f to m in order to be physically qualified for a preferred military role and plans to change back later.That raises an interesting question. Altering the physical structure of the body looks like something that should be practical with the medical technology we can expect to have sometime in the next century. But a complete change should include a change at the genetic level, from XX to XY or the reverse, and Bujold makes that explicit in her story.This raises two questions. One is whether the change could be made. I think the answer is pretty clearly yes, given a sufficiently advanced technology. One could, after all, have nanotech cell repair machines, very small robot submarines, that go through the body altering every cell.The more interesting question is to what degree the result would still be the same person. The Y chromosome contains lots of genes in addition to the gene SRY that determines testes development. So replacing an X with a Y or a Y with an X would change a lot of the individual's genetic code. Could the problem be avoided by copying all of the genes not relevant to sex determination from the existing Y to the new X? Possibly. But it will not work the other way because the X is much larger than the Y; there is not room on the Y for all the genes from the X. Alternatively, is it an issue that doesn't matter because all the relevant determination of the organism by the genes has already happened in the adult? I don't know the answer.Comments welcome, ideally by people who know more about this stuff than I do.Incidentally, Gallagher's Torchship series is very good--I have now reread it twice. In addition to being a good action story, it raises issues that I have seen discussed at length in non-fiction contexts, including hostile artificial intelligence and problems with a society where everyone gets a basic income. Particularly impressive for a new author, which I believe Gallagher is.P.S. My wife, who remembers books much better than I do, points out that in Bujold's A Civil Campaign the sex change operation only results in the male genitals being XY, leaving all other cells XX. The text implies that a complete conversion was possible but would take longer than was available and "the complications can be strange."