Doctor-patient confidentiality was a medical and legal concept present in many cultures, especially in the Federation. It held that information regarding an individual's medical condition and any related communications are protected from being divulged by the doctor to any third party without the patient's consent. This applied to any third party, but especially to police agencies or other forms of authority, such as Starfleet.
In Starfleet, such confidentiality could be broken if a doctor was ordered to do so, but only if the security of the starship or Federation is at risk. Such was the case in 2371 when Kathryn Janeway ordered The Doctor to violate this confidentiality with regards to Samantha Wildman. (VOY: "Fury")
In 2151, Doctor Phlox told T'Pol that everything said between them was strictly confidential after she told him she hasn't slept for two days and Phlox assumed that something was on her mind. (ENT: "Breaking the Ice")
When Jonathan Archer asked Phlox how he'd finally convinced Hudak to have surgery for his condition, Phlox said he must be familiar with the concept of doctor-patient confidentiality, reminding him that he could always order the doctor to tell him. (ENT: "The Breach")
In 2372, when Tom Paris asked The Doctor why he was suddenly interested in romance, the latter dodged the question by saying he couldn't tell him, as it was a matter of doctor-patient confidentiality. (VOY: "Lifesigns")
While playing the role of Father Mulligan in the Fair Haven holoprogram, The Doctor reminded Tom Paris of the doctor-patient confidentiality after Paris asked him if he heard any new confessions lately. (VOY: "Fair Haven")
When The Doctor told Seven of Nine that the captain is informed about Seven's medical needs, Seven reminded The Doctor that all members of this crew had the right to doctor-patient confidentiality. (VOY: "Imperfection") Some time later, Seven of Nine reminded The Doctor about this confidentiality again. (VOY: "Human Error")
One variation on this was when Chakotay refused to tell Janeway what he had discussed with his Maquis raider, the Val Jean, after catching her talking to USS Voyager, citing "captain-starship confidentiality". (VOY: "The Haunting of Deck Twelve")