I'm a practice manager and would be utterly horrified if this had happened to one of our patients. Quite clearly your surgery is missing a whole raft of safeguards which could - should - have been implemented to prevent any patient suffering a loss of privacy and/or dignity.
We do not allow patients to access the clinical area unless accompanied by a member of staff. Our clinical rooms are all off a corridor behind another door on which there is a very clear sign stating that patients must not enter without staff.
Occasionally, 'difficult' or 'threatening' patients have attempted to do so in order to force an issue, e.g. when they can't get an appointment at a specific time with a specific clinician, but we have security policies in place to deal with such a situation and therefore the likelihood of them barging in upon someone else is fairly small.
Our GPs and nurses always offer a chaperone for intimate examinations and in fact, patients are welcome to request one as they wish, even if the consultation is 'non-intimate'. They also offer to lock the door.
Within the practice it is drummed in to all staff they must not enter a clinical room when the door is shut unless a) it's a genuine emergency such as fire, or when the clinician has set their alarm off, or b) the clinician has contacted them and requested that they do so, e.g. to bring a particular piece of equipment in. Before they do that they should ask the patient if it's okay to be interrupted and staff have also been trained to knock, wait for the 'come in' just to be sure and furthermore to offer a 'sorry for the interruption' to the patient so, you know, they feel acknowledged.
It is so, so important to maintain dignity as much as possible during important medical treatment which, by its nature, can often feel awkward, embarrassing and scary. The old mantra of clinicians having 'seen it all before' may be true but an empathetic clinician appreciates that they may not have seen yours! Previous posters on this thread have already commented that they've avoided vital and potentially lifesaving checks since a prior appointment made them feel exposed and humiliated which is awful, and which proves that experiences like the OP's are much more than a bit of embarrassment that can be brushed off.
Please do complain OP, and I'm sorry you were put in that position.