organization_consent Validator Documentation
organization_consent Validator Documentation Organization Membership AND Active Consent, for FHIR Resources
Intent
The organization_consent validator grants access only when both of two conditions hold: the caller is a practitioner in an organization the resource belongs to, and an active Consent names that practitioner — or their organization — as someone the patient has authorised. Either condition alone is not enough.
It exists for tenants who need to say "my organisation may treat me, but only the people (or organisations) I have actually consented to may see my records" — organisation membership on its own, the organization_compartment validator, cannot express that narrower promise.
Key Use Cases:
- A patient consents to a specific practitioner, or to their whole treating organisation, and everyone else in that organisation stays out even though they share the same employer.
- A patient revokes access from one named practitioner without affecting the rest of the organisation.
- Recording, and enforcing, the acceptance of your platform's terms and conditions as a first-class FHIR
Consent.
Consent means no accessAbsence of a Consent is not a neutral default here — it is a denial. A patient with zero Consent resources is invisible under this validator to every caller, including their own organisation. If you select this validator, consent capture has to be part of your onboarding flow, or your practitioners will see nothing.
What this validator checks, in order
- Organisation membership — exactly the
organization_compartmentcheck: is the caller an active practitioner in an organisation the resource (or its patient) belongs to? If this fails, the request is denied and the consent question is never asked. - Active consent — does an active
Consentfor the patient the request touches grant the caller (or one of their active organisations) access, and does nothing in thatConsentdeny it?
Both must pass. Neither can substitute for the other: organisation membership without consent denies, and a Consent naming a practitioner outside the patient's organisation also denies — the compartment check runs first and stops the request before consent is ever considered.
Who and what this validator applies to
| Caller role | Practitioner only. A rule pairing this validator with Patient, RelatedPerson or Device as client_role is rejected at rule-write time. |
| Resource types | Patient-linked clinical resources — the same set organization_compartment resolves through a referenced Patient (see its field map) — plus Patient itself for read and search. |
| Not supported | Resources with no patient to resolve consent for — Organization, Location, Device, and the rest of the types organization_compartment resolves directly rather than through a patient. Use organization_compartment for those. |
Consent is evaluated per patient the operation touches, not merely the patient named in the request payload. An update or delete that would move a resource between two patients requires active consent for both — one consented patient's data cannot be reassigned onto an unconsented one, or vice versa, by a single write.
Patient/create is not a usable rule under this validator
Patient create is deniedA registration-time Consent (if your tenant records the terms-and-conditions acceptance as one) is written after the Patient resource exists. At the moment a Patient is created there is no patient yet to search for a Consent against, so the consent check always finds nothing and denies — for every Patient create, unconditionally.
Do not select organization_consent for Patient / create. Use organization_compartment, or another validator, for patient registration, and gate subsequent reads of that patient with organization_consent once their Consent exists.
A create for any other supported resource type behaves as expected: if the payload references a patient who already has an active, matching Consent, and the caller's organisation membership checks out, the write is permitted.
A create naming an existing id is always denied
Independent of the two-part check above: a create that supplies an id already in use is an upsert of an existing resource, and this validator refuses it outright — the same behaviour as allowed and the project's default_access: "Allowed" fallback, and stricter than the other compartment validators, which permit an upsert onto a resource the caller already owns. Under organization_consent, ownership is never checked for this case; it is refused regardless. See what a compartment validator asks of a write for how every validator compares.
What a Consent needs to look like
The validator reads only active Consent resources for the patient in question — Consent.status must be active; anything else (draft, inactive, entered-in-error, …) is invisible to it. Within an active Consent, access is decided by walking Consent.provision and its nested provision.provision entries:
| Element | What it means here |
|---|---|
provision.type | permit or deny. Anything else — absent, misspelled, or a non-string — matches nothing and is skipped; it neither grants nor blocks. |
provision.actor | Who the provision applies to: a Practitioner reference, an Organization reference, or omitted entirely. |
provision.period | An optional validity window, checked only on permit — an expired or not-yet-open permit does not grant. A deny is never time-limited by period; once written, it keeps denying. |
Consent has no top-level period in R4That field is an STU3 leftover. Setting it on an R4 Consent has no effect on this validator, or on anything else. Use provision.period if you need a permit to expire.
Precedence — deny always wins
There is no partial credit and no tie-break in the patient's favour. Within one Consent, evaluated across every provision at every depth:
- Any matching
denydenies the request outright, regardless of what else the document permits, and regardless of how much more specific a matchingpermitelsewhere is. - Only if nothing denies does the most specific matching
permitdecide — a provision naming the calling practitioner directly outranks one naming their organisation, which outranks a provision naming no one.
The practical consequence: you cannot write "not my organisation in general, but this one practitioner may" as an organisation-level deny plus a practitioner-level permit — the deny wins and the permit is discarded. Express that narrower grant the other way round instead: no organisation-level provision at all, and a practitioner-level permit naming only the practitioner who should see the record.
Omitting actor — the asymmetric rule
FHIR treats an element with nothing in it as placing no restriction. This validator follows that convention for deny and deliberately does not for permit:
- A
denywith noactorapplies to everyone — this is the natural way to write "revoke all access," and it is honoured. - A
permitwith noactorapplies to no one. Taking the R4 reading literally here would turn one field, invisible in any rule editor, into a standing grant of the patient's entire record to every practitioner on the tenant. That reading is refused on purpose.
Both directions resolve toward denial, consistent with the opt-in default above.
Nesting
A nested provision.provision is scoped inside its parent, matching R4: a child provision is an exception within what its parent already covers, not a free-standing rule of its own. A deny you did not expect to apply can still surface from a parent provision the child sits under — read the whole tree, not just the node that appears to match.
Practical limits worth knowing before you design around this
- A patient with more than 50 active
Consentresources is denied outright rather than decided on a partial read — clean up old or supersededConsents rather than leaving them active. - A single
Consent's provision tree is capped at 1,000 nodes and 10 levels of nesting. Exceeding either denies rather than evaluating a partial tree. Keep consent documents flat and specific; there is no benefit to deep nesting under this validator. - There is no cache. A revoked
Consenttakes effect on the very next request — there is no TTL to wait out, and none to invalidate. This also means every row this validator decides costs a request-time lookup; it is not free relative to a plain compartment check.
Enabling this on a project that already has patients
Switching an existing, populated project onto organization_consent denies access to every patient who has no Consent yet — which, for most tenants, is their entire existing patient population, all at once, on the config change. Unless every one of your existing patients already carries an active Consent, plan a backfill or an explicit cutover before enabling this validator on a project with real data in it.
Denial messages are deliberately uniform
Every denial under this validator returns the same message: "Access denied: no active consent covers this request." Whether the caller has no active organisations, the patient has no Consent at all, an active Consent explicitly denies them, or a Consent search itself failed — the caller sees the same sentence. The specific reason is recorded for audit purposes but is never disclosed in the response, because a more specific message would tell a denied caller facts about a patient's consent choices that the patient did not agree to share with them.
Example Configuration
{
"client_role": "Practitioner",
"entity_name": "Observation",
"operation": "read",
"validator": "organization_consent"
}
Explanation: A practitioner can read an Observation only if both hold: the Observation's patient has a managingOrganization the practitioner is active in, and an active Consent for that patient permits the practitioner or their organisation, with no matching deny anywhere in the document.
{
"resourceType": "Consent",
"status": "active",
"patient": { "reference": "Patient/123" },
"provision": {
"type": "permit",
"actor": [
{ "reference": { "reference": "Organization/clinic-a" } }
],
"provision": [
{
"type": "deny",
"actor": [
{ "reference": { "reference": "Practitioner/dr-jones" } }
]
}
]
}
}
Explanation: Every practitioner active in Organization/clinic-a may read Patient/123's data under this validator, except Practitioner/dr-jones, whose nested deny overrides the organisation-level permit for them specifically.