I suppose she might have been studying here and there during the 5ym. Plus, some of her experiences during the mission might have given her a leg up. I imagine McCoy might have recognized her latent abilities and encouraged her/provided opportunities for her, despite his later rant about doctors arguing every diagnosis with him (that was due to his crankiness over being drafted)