Skip to main content

Audit trail

Operations on a project's FHIR data, including refused ones, are recorded by default as FHIR AuditEvent resources in that project's own store. The trail is data like any other: you read it with the GraphQL API, and scope who may read it with an access rule. No caller, including a project administrator, can create, edit or delete an AuditEvent through the API.

What a record holds​

FieldContent
recordedWhen the operation happened, in UTC
actionThe kind of operation: create, read, update, delete, or execute for searches and operations. A login, or a refused request the platform could not classify, carries no action
agent.whoThe caller, as a FHIR reference such as Practitioner/def456 or Device/abc123
agent.networkThe caller's network address
entityThe resource the operation touched
outcomeWhether the operation succeeded or was refused

Reading the trail​

Grant the role that audits a read rule on AuditEvent; search follows from it.

{
"client_role": "Practitioner",
"entity_name": "AuditEvent",
"operation": "read",
"validator": "allowed",
"required_role_system": "http://terminology.hl7.org/CodeSystem/practitioner-role",
"required_role_code": "ict"
}

The rule above lets practitioners holding the ICT role, and nobody else, read every audit record in the project. Choose the validator deliberately: allowed reads the whole trail, which is usually what an auditor needs and rarely what a clinician should have.

query {
AuditEventConnection(count: 50, _sort: "-date") {
next
edges {
resource {
... on AuditEvent {
recorded
action
outcome
agent { who { reference } }
entity { what { reference } }
}
}
}
}
}

Page with next as on any other search; see the GraphQL guide.

What cannot be changed​

  • AuditEvent is read-only through the API. A create, update or delete is refused whatever your rules say. See Behaviour you cannot configure.
  • Erasing a patient does not erase the trail. An account erasure anonymises the Patient resource and leaves the audit records in place. See Account erasure.