There are laws that protect people against self-incrimination in most countries, so that analogy doesn't work, but if a doctor can uniquely perform a procedure that can help an investigation because of some relation to the person under investigation, she can be compelled to perform that procedure in most countries, including the US.
You're not wrong about the Fifth Amendment, but you're assuming the compelled testimony is self-incriminating. What if the FBI decides to round up all the people in the area of a crime, and coerce a doctor to administer some "thought extraction" procedure that would offer evidence of the culprit? If one of the witnesses turned out to be the perpetrator, their testimony would be unconstitutional, but the other witnesses would (in theory) be valid and admissible.