Security
Data Integrity
Versions, optimistic locking, history, Provenance, and encryption
Resource Versioning
Every FHIR resource has a version that starts at 1 and increases with each update. It appears in meta.versionId. The ETag header (W/"<version>") is returned on PUT/PATCH responses and on reads of some resources, such as Patient.
{
"resourceType": "Patient",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"meta": {
"versionId": "2",
"lastUpdated": "2026-01-15T10:30:00Z"
}
}
The API does not send Last-Modified. Use meta.lastUpdated instead.
Optimistic Locking with If-Match
Send the version you read so you do not overwrite someone else’s change:
curl -X PUT https://api.esus.health/fhir/Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6 \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/fhir+json" \
-H 'If-Match: W/"2"' \
-d '{ "resourceType": "Patient", "active": true }'
- If the current version is
2, the update proceeds and the version becomes3. - If it is no longer
2, the API returns412 Precondition Failed. Read the resource again and retry. W/"2","2", and2are equivalent.If-Matchis optional: without it, the write is not checked (there is no428). It applies toPUTandPATCH, not toDELETE.- The API serializes updates to the same resource. If two writes send the same
If-Match, the second receives412once the first changes the version.
Version History
# Every version of the resource
curl https://api.esus.health/fhir/Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6/_history \
-H "Authorization: Bearer TOKEN"
# A specific version
curl https://api.esus.health/fhir/Patient/3fa85f64-5717-4562-b3fc-2c963f66afa6/_history/1 \
-H "Authorization: Bearer TOKEN"
Esus also records every change to PHI tables in an internal change log, written by a database trigger. That log is not exposed through the API.
Provenance
Provenance documents where data came from (for example, an import from another system). Esus does not create it automatically: your integration must create it. In practice, it requires admin or an API key with Provenance.* scopes, because no role policy covers it.
curl -X POST https://api.esus.health/fhir/Provenance \
-H "Authorization: Bearer TOKEN" \
-H "Content-Type: application/fhir+json" \
-d '{
"target": [{ "reference": "DiagnosticReport/bb22cc33-dd44-ee55-ff66-778899001122" }],
"recorded": "2026-01-15T10:30:00Z",
"activity": { "coding": [{ "code": "import", "display": "Imported from external system" }] },
"agent": [{
"who": { "reference": "Practitioner/a7b1c2d3-e4f5-6789-abcd-ef0123456789" },
"onBehalfOf": { "reference": "Organization/9a8b7c6d-5e4f-3210-9876-543210fedcba" }
}],
"entity": [{
"role": "source",
"what": { "reference": "DocumentReference/cc33dd44-ee55-ff66-7788-990011223344" }
}]
}'
target, recorded, and agent (with who) are required. To query it:
curl "https://api.esus.health/fhir/Provenance?target=DiagnosticReport/bb22cc33-dd44-ee55-ff66-778899001122" \
-H "Authorization: Bearer TOKEN"
target matches by substring within the references. recorded (date) is also supported. Together with _history, this shows how a resource changed and where its data came from.
PHI Encryption at Rest
Esus encrypts selected fields with AES-256-GCM before storing them. Your application always sends and receives plaintext.
| Fields | Key |
|---|---|
| Names, telecom (phone/email), addresses, and identifiers of Patient, Practitioner, and RelatedPerson | Platform key, derived with HKDF-SHA256 |
Clinical free text: Observation.valueString, DiagnosticReport.conclusion, ClinicalImpression.summary, and annotations (note) | Key derived per organization (HKDF-SHA256 with the organization’s salt) |
Keys are stored on the server and are never exposed to clients. Not every column is encrypted: codes, numeric values, dates, and references are stored in plaintext and protected by Row-Level Security and access control.
Encrypted fields can still be searched through HMAC-SHA256 blind indexes:
- Name: hashed tokens per organization, for name search.
- Phone and email: HMAC of the normalized value, for exact match only.
- Identifiers:
_valueHash, soidentifier=matches exactly without decrypting.