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 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 to ONS under the Statistics and Registration Service Act 2007. This is in recognition of the importance of accurate 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 health data that ONS holds will often include identifiable information, and this is because it is needed to be able to link the data with other sources at an individual level. Such data linkage is a key step in producing quality statistics fit for supporting decision making. However, we are committed to protecting confidentilaity, are only interested in aggregate statistics and trends, and the data are never used for operational purposes.

To help support this commitment, only a very small number of specially trained ONS data engineers with high levels of security clearance ever process identifiable data. These data engineers are not be responsible for analysis, and there is a separation of duties between them and the analysts who produce our statistics. Our analysts will only access the data after it has been linked and deidentified, are also specially trained, and will never seek to re-identify individuals.