I’m sorry. Did you maybe sign a transfer of records waiver at some point? I know my pdoc asked me to sign a release so he could see my medical records when he first took my case. That waiver would make it possible for my GP to tell my pdoc if I was saying things that seemed to need pdoc attention.
Another possibility is that the medical records are stored on the same server. For example, I used to see a pdoc who was affiliated with the hospital, and a GP who was also affiliated with the hospital. Since they both stored my records on the hospital server, they could both access my files.
As an aside - it can work in your favour if you give consent. The local council (my landlord) have permission to see my medical records and speak to the police about me.
It puts their mind at rest in my case - that when im ill and shouting my head off, they know the reasons why.
The CMHT will always tell me if some professional body has asked about me. I got nothing to hide.