That raises an interesting question. Do officers in the military who are doctors get referred to by their rank or simply as Dr.?
M*A*S*H would be a good guide on this. It depends how gung-ho the particular officer is.
Are they in it to be a doctor or military?
Maybe less "military" in 24th century Starfleet though.
Would also depend on the Doctor's actual position or job within the organization as well.
For example, in 'All Good Things', future-Beverley had become the Captain of a Star Fleet vessel. As such, she was addressed as "Captain" rather than "Doctor" - noting also that there were probably a bunch of other doctors on her ship anyhow.