They anonymise or pseudo anonymise data wherever possible: https://digital.nhs.uk/your-data/understanding-data-in-health-and-care
They also allow you to view who accesses the data with their register: https://digital.nhs.uk/services/data-access-request-service-dars/data-uses-register
Edit: you can also opt out/in of sharing at any time: https://www.nhs.uk/using-the-nhs/about-the-nhs/opt-out-of-sharing-your-health-records/
Thanks