Explore documentation

Patient Consent

Managing consent with the FHIR Consent resource

Staff can find and open patients in the Patient directory when their role allows it. Reading, searching, updating or deleting linked clinical records, such as an Observation, also requires an active Consent with scope "treatment" for that patient in the organization.

  • The check applies per patient + organization, not per practitioner.
  • It does not apply to admin users, API keys, or emergency override.
  • Only the exact string "treatment" grants access. Other scopes are stored but do not affect access.
  • A consent with provision.type: "deny", a future start or an expired provision.period does not grant access. actor and purpose are stored but do not select individual practitioners.

Who can manage consents? Staff need the corresponding Consent permission in their role; API keys need its scope. Managing consents does not itself require an existing treatment consent. Record one only when the patient actually gave it: Esus does not verify that.

scope is a required plain string (max 50 characters) and patientId is the patient’s UUID. If you omit status, it is created as active.

curl -X POST https://api.esus.health/fhir/Consent \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "status": "active",
    "scope": "treatment",
    "patientId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "policy": [{ "uri": "https://example.org/privacy-policy" }]
  }'

The response returns the resource in FHIR form: scope appears as { "text": "treatment" } and the patient as patient.reference.

StatusDoes it grant access?
activeYes, with scope treatment and a provision that permits access now
draft, proposed, rejected, inactive, entered-in-errorNo

Other Scopes

You can record consents with other values, such as "research", for your own records. They do not affect access control:

curl -X POST https://api.esus.health/fhir/Consent \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "status": "active",
    "scope": "research",
    "patientId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "provision": {
      "type": "permit",
      "purpose": [{
        "coding": [{
          "system": "http://terminology.hl7.org/CodeSystem/v3-ActReason",
          "code": "HRESCH",
          "display": "Health Research"
        }]
      }]
    }
  }'

Change the status of the treatment consent to inactive or rejected, or delete it. When no other active treatment consent exists, users who are not admin receive 403 when they try to access that patient’s linked clinical records. The Patient directory remains available according to their role.

curl -X PUT https://api.esus.health/fhir/Consent/c1a2e3d4-5b6f-7890-abcd-ef1234567890 \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/fhir+json" \
  -d '{ "status": "inactive" }'

Deleting a consent (DELETE /fhir/Consent/:id) sends the consent.revoked webhook to your organization’s apps. Changing its status does not send that webhook.

Query Consents

# The patient parameter accepts a bare UUID or "Patient/<id>"
curl "https://api.esus.health/fhir/Consent?patient=3fa85f64-5717-4562-b3fc-2c963f66afa6&status=active" \
  -H "Authorization: Bearer TOKEN"

Supported filters: patient (UUID or Patient/<id>) and status. Each consent has a _history (/fhir/Consent/:id/_history).

Example: What Esus Checks

When a non-admin user requests GET /fhir/Observation/aa11bb22-cc33-dd44-ee55-ff6677889900:

  1. It checks that the user has the Observation.read permission.
  2. It resolves the patient linked to that Observation.
  3. It looks for an active consent with scope "treatment" for that patient in the organization, excluding deny provisions and periods that do not cover the current time.
  4. If there is none, or the check fails, it returns 403 with an OperationOutcome.
  5. It also requires the resource policy to permit the request for the user’s role. See Access Control.

For searches such as GET /fhir/Observation?patient=<id>, Esus checks the patient in the parameter. A PHI search without patient/subject is denied for non-admin users.

Patient and Consent remain controlled by role permissions. $everything also checks each included resource type: permission to read Patient does not grant access to Observation.

Updating or deleting Patient still requires active treatment consent for non-admin staff. Opening the directory does not remove this write restriction.