For sake of argument, would a Flag rank medical corps officer be considered a code but also incapable of taking command of the aircraft?
Yes. I know what 3710 says, but codes are for rendering honors, letting a base CO know a flag-or-higher is arriving aboard, etc. Nothing really to do with authority in the aircraft. If you had a flag URL aboard and he ordered you to, say, change destination - well, presumably he's aboard because you're taking him somewhere, so okay. But otherwise, I can't imagine any flag attempting to 'take command' of a flight in any plausible scenario.
Pops had a 1LT General (as in, surname "General") in his squadron. Got yelled at by a base air ops guy who'd heard he had a LTG on board but no code on the flight plan.
@LaFway It's not uncommon at all in my experience for a more junior guy to be AC/MC even when flying with the Skipper or XO. The AC/MC is responsible for flight/mission planning, which can take a while, and the senior guys have senior guy stuff to do. Plus it's good for more junior guys to get that experience.