In all the Star Trek series the medical bay is a large, open area where the doctor talks to and examines the patient, where just about anyone can walk in uninvited, and often does. Sometimes confidentiality is discussed and the doctor always says "Of course what you're telling me/your condition is confidential", but unless this is explicitly mentioned it can't be assumed. So, why no automatic confidentiality for everybody when in real society it is a breach of medical ethics to talk about a patient without their permission?
We are talking about a medical station in a naval context here. I guess that privacy isn't that great a concern in the military (which ST is in large parts modelled after).
See for example this picture from the USS Yorktown: Caption "Sick bay on USS Yorktown"
I have 2 explanations:
It's still more or less a military organization that operates in an extremely dangerous environment. When your chief engineer starts having blackouts, it's not just his issue. The dude fiddles with anti-matter generators and warheads and his actions can cost hundreds of lives, including civilians'. And things like work ethics can shift.
It's still a TV show. Yes I know it's lame, but some plots are too stupid to deserve any in-lore explanation whatsoever and medical drama tends to be on that list. Star Trek always struggled with its continuity and some changes were literally changed on whim.
Privacy in the future is very different from what we define as privacy
In the star trek universe, especially TNG and onwards, the opinion on what should and should not be private is completely different from our own privacy standards. It seems to be normal that many things are potentially known to everybody unless confidentiality is explicitly requested. We have to assume that the same applies for medical.
Here are a few examples:
- Communicators work by broadcasting the message to everyone within earshot. No one pays attention to it, it is very rare that anyone asks "can you talk freely"? This communication is the norm, and there seems to be no way anyone can take a private call at work other than finding a quiet place.
- Related to that: The computer is always listening
- The computer happily discloses the location of any crew member to anyone who is asking. It even adds the information about when someone left the ship and where they are going, unless you explicitly wipe the data (which is usually taken as a sign that something is wrong)
- No matter how private the stuff you are doing on the holo deck, it appears to be the norm that you can just enter and no one will take an issue. In TNG: Hollow Pursuits we see Lt. Barclay living out very private fantasies on the holodeck, and Geordi walks in on him. If I remember correctly, the issues that a) Barclay should have locked the door and b) Geordi was invading his privacy are never discussed.
- The biography of many people, not all of them in Star Fleet, is readily available on the federation database. It's like having a very detailled Wikipedia entry for everyone in the Federation.
To me, it's obvious that in the world of Star Trek, privacy by default is not a given any more, and medical records or conditions are no exception.