Further to the National Data Guardian Review of patient opt-outs, and the subsequent government response in 2017, the Department of Health and Social Care have confirmed that those who have opted out of having their data shared for purposes beyond their direct care will not be removed from data flowing under section 45(a) of the Statistics and Registration Service Act 2007. This is in recognition of the importance of official statistics which are in the public interest. See here for the full list of exemptions when the opt-out does not apply:

https://digital.nhs.uk/services/national-data-opt-out/operational-policy-guidance-document/when-does-a-national-data-opt-out-not-apply

The ONS needs identifiable information to be able to link the data with other sources at an individual level and linkage is a key step in producing quality statistics fit for supporting decision making. However, it is worth highlighting here that the ONS are only interested in aggregate statistics and trends. The ONS possesses expertise in this area. Only a very small number of the ONS’ employees with high levels of security clearance will ever be permitted to process identifiable data, and these staff will not be responsible for analysis. That is, there will be separation of duties and the majority of analysts will not be permitted to work with identifying data.