The EHDS Opt-Out Mechanism: Building Patient Preference Into Every Secondary-Use Query

The EHDS opt-out is not a consent form or a policy paragraph. It is a runtime condition that has to hold on every secondary-use query, and if you cannot demonstrate that it does, you cannot demonstrate compliance at all.

Article 71 of the European Health Data Space Regulation (Regulation (EU) 2025/327) gives every natural person the right to opt out, at any time and without giving a reason, from the processing of their electronic health data for secondary use. The consequence is precise: where a person has exercised that right, their data must not be made available or otherwise processed under a data permit issued under Article 68 or a health data request approved under Article 69. Member States have to offer the mechanism. Data holders and Health Data Access Bodies have to honour it. The regulation puts the obligation on the outcome — the data does not reach the query — not on the existence of a preference record somewhere.

That is a systems problem, and it is worth being blunt about where it usually goes wrong before the secondary-use regime starts applying from 26 March 2029.

Free · 4 minutes

When two of your systems disagree, do you know which one to believe?

Fourteen questions on ownership, lineage, and quality — the difference between a number on a dashboard and a number you could defend. Banded finding on screen, full sheet by email.

Why a policy answer fails the test

The instinct in most organisations is to treat opt-out as a governance control: a register of who has objected, a procedure that says analysts must check it, an attestation in the data-permit workflow. That satisfies an auditor who reads documents. It does not satisfy the regulation, because the regulation is about what actually happens when a permitted dataset is assembled and queried. If honouring the opt-out depends on a human remembering to filter, or on an extract script that someone maintains by hand, the opt-out will eventually fail — quietly, on a dataset that has already left your control inside a secure processing environment.

The only defensible design is one where an opted-out record is structurally incapable of reaching a secondary-use query. The check belongs in the data-access path itself, not in the conduct of the people using it. Get that right and the evidence for a supervisor is the enforcement point, not a promise about behaviour.

The preference store is the primary artefact

Start with the store that holds the choice. It sounds trivial; it is where most of the design decisions actually live. A workable preference model needs to capture more than a boolean:

  • A stable subject identifier that can be resolved against every dataset in scope, which is harder than it looks when records are pseudonymised differently across sources.
  • The state of the choice and the timestamp it took effect, because Article 71 makes the right reversible — a person can opt out and later opt back in, and the store has to represent the current state without losing the history.
  • The provenance of the change: who recorded it, through which channel, so the record is itself auditable.
  • Scope, if your national transposition allows granular opt-outs rather than a single blanket objection — verify this against the transposing law, as the Regulation leaves Member States room to go further.

Treat this store as authoritative and singular. If two systems each keep their own copy of who has opted out, you have two chances to be wrong and no single place to prove you were right. The same lineage discipline that governs the datasets themselves applies here: the preference store is a piece of governed data with its own provenance, and it should be modelled that way from the start.

Where the check sits in the access path

The enforcement point should be as close to the data as you can put it and impossible to route around. A filter applied in application code protects only the queries that go through that application. A filter applied in the query layer — a mandatory view, or a row-level security policy the database enforces regardless of how the connection arrives — protects every query, including the ad-hoc one an analyst runs directly inside the processing environment. That distinction is the whole game. The opt-out has to bind the data, not the interface.

A concrete pattern: hold the preference state in the same governed store the access layer reads, and expose secondary-use data only through a view that excludes any subject with an active opt-out as of query time. The exclusion is evaluated on every read, so an objection recorded this morning takes effect this afternoon without anyone rebuilding an extract.

-- Authoritative preference store: current state per subject, with history retained elsewhere
CREATE TABLE secondary_use_optout (
    subject_id      text        NOT NULL,
    is_opted_out    boolean     NOT NULL,   -- reversible per Art. 71
    effective_from  timestamptz NOT NULL,
    recorded_by     text        NOT NULL,
    recorded_via    text        NOT NULL,
    PRIMARY KEY (subject_id, effective_from)
);

-- Current opt-out state: the latest record per subject wins
CREATE VIEW current_optout AS
SELECT DISTINCT ON (subject_id) subject_id, is_opted_out
FROM   secondary_use_optout
ORDER  BY subject_id, effective_from DESC;

-- The ONLY object a data-permit query is allowed to touch.
-- An opted-out subject is structurally absent, evaluated at query time.
CREATE VIEW ehds_secondary_use AS
SELECT h.*
FROM   health_records h
LEFT   JOIN current_optout o ON o.subject_id = h.subject_id
WHERE  COALESCE(o.is_opted_out, false) = false;

-- Revoke direct access to the base table inside the processing environment;
-- grant only the filtered view, so no query can bypass the exclusion.
REVOKE ALL   ON health_records      FROM ehds_analyst;
GRANT  SELECT ON ehds_secondary_use FROM ehds_analyst;  -- adjust to GRANT ... TO in your dialect

The mechanism matters less than the property it guarantees: no path from an analyst to the base table, and one filter that every permitted query inherits. Whether you implement it as a view, a row-level security policy, or an equivalent in your platform, the test is the same — can a query reach an opted-out record by any route. If the answer is no by construction, you have something to show.

The exception you must not hard-code away

Article 71 is not absolute. Member States may, in national law, permit access to opted-out data where the applicant is a public sector body or Union body with a public-health mandate and the purpose falls within specific grounds — certain public-interest and public-health uses, or scientific research for important reasons of public interest — and only where the data cannot be obtained by other means and suitable safeguards apply. This is a deliberate, narrow override, and it will vary by jurisdiction.

The engineering implication is that the default has to be exclusion, and any override has to be an explicit, permissioned, logged path bound to a specific permit — never a flag an analyst can set to widen their own query. If your architecture makes the opt-out the default and the override the exception that has to be justified and recorded, you are aligned with the Regulation. If it is the other way round, you are one misconfiguration away from processing data a person asked you not to.

Where this sits in the wider build

The opt-out enforcement point is one control inside the larger secondary-use machinery — the data permit, the Health Data Access Body and the secure processing environment your queries run through, which we have covered in the piece on the data permit and secure processing environment. It also depends on the same subject-identity plumbing that the primary-use data model forces you to get right, because you cannot honour a preference for a person your datasets cannot agree on.

2029 is not far away for a control that has to be built into the data layer rather than bolted onto a workflow. The organisations that will be able to evidence the opt-out are the ones treating it now as an enforced property of their access path — not a promise they intend to keep.

Free interactive tool

Website compliance checklist

What your site has to do, based on what it actually does

Answer as much or as little as you like — the list builds as you go. Nothing is stored against your name and no email is required.

Free interactive tool

Interactive deadline calculator

Check which regulations apply to you and when

Regulation across the EU, UK, US and Asia-Pacific has moved considerably in the past eighteen months, and several headline dates have shifted more than once. Twelve questions, about three minutes.

Results are shown on screen — no email required. A dated summary is available to download, and can be sent on if that's more useful. What we do with your answers.

Most technology problems are not technology problems. They are control problems.

The systems exist. The investment has been made. The question is whether leadership can understand, direct, evidence, and sustain what those systems produce. Find out where control exists — and where it only appears to.

Full Governance by Sixteen Pillars

Govern your business. Prove your compliance.

A board assurance cockpit for EU-regulated financial firms — tamper-evident, hash-chained proof of governance across DORA, GDPR, NIS2, ISO 27001, the EU AI Act and MiCA. In development.

See what's coming