Explore documentation

Access Control

Permissions, ABAC policies, consent, and emergency override

How Esus Decides

Each FHIR route is protected by guardResource. It maps the HTTP method to an action (GET → read, POST → create, PUT/PATCH → update, DELETE → delete; searches are read) and evaluates the request in this order:

  1. Permission (RBAC): your roles must include Resource.action, Resource.*, or *.
  2. Consent: for PHI resources, users who are not admin need an active treatment consent for the patient. See below.
  3. Policies (ABAC): any deny wins. For console users, a request that passes steps 1 and 2 and that no policy denies is allowed: your role’s permissions are what grant access. Policies add context rules on top (for example, a receptionist cannot read clinical data).

A denial returns 403 Forbidden with an OperationOutcome and is recorded in the audit log. Organizations are also isolated by Row-Level Security: a resource from another organization is never returned. admin users and API keys get 404; for other users, a PHI resource from another organization fails the consent check first and returns 403.

Roles and Policies

Any role works, including the console templates (medico, profesional, administrativo, auditor) and custom roles: it can do exactly what its permissions say. Some policies also recognize these role names and add rules for them:

RoleAccess granted by the policies
adminEverything (*:*). Skips the consent check
doctorPatient (without delete), Encounter, clinical data, documents, scheduling; reads financial data
nurseRead and partial updates of clinical data, encounters, and scheduling
receptionistPatient (read), scheduling, communication and tasks; no clinical data
lab-technician, radiologist, pharmacist, billing, data-exportTheir specific areas (laboratory, DiagnosticReport, pharmacy, financial, bulk export)
emergency-responderCan use emergency override

Two exceptions stay admin-only even if a role has the permission: writes to organization management (Role, TenantApp, SmartApp, /admin/*, queues, billing; reading the audit log with AuditEvent.read is allowed), and Bulk Export, which needs the admin or data-export role.

Managing Roles

All of these endpoints require admin.

# List roles (with their permissions)
curl https://api.esus.health/roles -H "Authorization: Bearer TOKEN"

# Permission catalog (each one with its id)
curl https://api.esus.health/roles/permissions -H "Authorization: Bearer TOKEN"

# Create a role (name and description only)
curl -X POST https://api.esus.health/roles \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "name": "nurse", "description": "Floor nursing" }'

# Set its permissions (replaces the whole set; use the catalog ids)
curl -X POST https://api.esus.health/roles/ROLE_ID/permissions \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "permissionIds": ["PERMISSION_ID_1", "PERMISSION_ID_2"] }'

# Assign a role to a user, or remove it
curl -X POST https://api.esus.health/roles/users/USER_ID/assign \
  -H "Authorization: Bearer TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "roleId": "ROLE_ID" }'
curl -X DELETE https://api.esus.health/roles/users/USER_ID/ROLE_ID \
  -H "Authorization: Bearer TOKEN"

Role changes can take up to 5 minutes to apply to active sessions because of caching.

API Keys

API keys follow a separate path: only their scopes are checked (Resource.action, Resource.*, or *). They skip the consent check and the role policies, so a key with Patient.read can read every patient in the organization. Grant the minimum scopes and see Authentication.

Patient and Consent are available to staff according to their role permissions. Linked clinical resources, such as Observation, Encounter, Condition, MedicationRequest or Claim, also require consent when the user is not admin and is not using an API key:

  • Read, update, or delete by ID: Esus resolves the resource’s patient and checks for an active Consent with scope "treatment" in the same organization.
  • Search: the patient is taken from ?patient=, ?subject=, or ?subject:Patient=, as a bare UUID or as Patient/<id>. A PHI search that does not identify a patient is denied.
  • Create: no consent check.
  • If the check fails or returns an error, access is denied (fail-closed).

Consent applies per patient and organization, not per practitioner. Deny provisions and periods outside the current time do not grant access. provision.actor is stored but does not select individual practitioners. See Patient Consent.

Emergency Override

Users with the emergency-responder role can skip the consent check with this header:

curl https://api.esus.health/fhir/Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6 \
  -H "Authorization: Bearer TOKEN" \
  -H "X-Emergency-Override: true"
  • It skips only the consent check and the per-role restrictions of clinical policies. The user still needs the RBAC permission for the resource.
  • It works only on resources whose policy contemplates the emergency (Patient, Encounter, clinical data, documents, medication, scheduling, financial, pharmacy).
  • It does not apply to SMART tokens or operator support sessions.
  • Each access is recorded with entity.resourceType set to Resource[emergency], for example Patient[emergency].
  • Esus does not include an automatic post-access review flow: review those events yourself in the audit log.

If the header is sent without the role, there is no 403 for that reason. The request continues with normal authorization, and a generic failure event is recorded with entity.resourceId set to authorization-denied.

Support Sessions

When Esus support impersonates a user to help, the session is read-only and cannot access PHI, regardless of that user’s permissions.