For AI agents: the documentation index is at /docs/aidbox/llms.txt. A Markdown version of this page is available at /docs/aidbox/access-control/audit-and-logging.md or by requesting it with the Accept: text/markdown header.
Aidbox Docs

Audit and Logging

Audit logging is essential in healthcare systems because it:

  • Protects Patient Privacy: Tracks who accessed sensitive medical records, ensuring compliance with privacy laws like HIPAA
  • Prevents Data Breaches: Helps detect and investigate unauthorized access to patient data
  • Ensures Accountability: Records all changes to medical records, creating a clear trail of who modified what and when
  • Supports Legal Requirements: Provides evidence for compliance audits and legal investigations

Aidbox provides comprehensive audit and logging capabilities:

  • FHIR Basic Audit Logging Profile (BALP) implementation
  • FHIR Resource versioning
  • Logging configuration

FHIR Basic Audit Logging Profile (BALP) implementation

Aidbox supports the FHIR BALP Implementation Guide.

Since version 2609, Aidbox publishes audit events to a built-in subscription topic. The security.audit-log.* settings are deprecated. For earlier versions, see How to configure FHIR Audit Log (deprecated).

Audit events topic

Aidbox publishes audit events to a built-in AidboxSubscriptionTopic:

http://health-samurai.io/fhir/core/StructureDefinition/AuditEventsR4BALP

Each event is a FHIR R4 AuditEvent resource. To receive events, create an AidboxTopicDestination with this URL in the topic element. Any destination kind works: webhook, Kafka, GCP Pub/Sub, and the others listed in supported channels.

API request Aidbox Audit events topic Webhook destination Kafka destination Other destinations

How the topic behaves:

  • Destinations switch audit logging on. With no destination on the topic, Aidbox builds no audit events and requests carry no audit overhead. Delete the last destination to stop audit logging.
  • The topic is part of Aidbox. You do not create an AidboxSubscriptionTopic resource for it, and Aidbox rejects a stored topic that reuses its URL with 422.
  • Every destination receives its own copy of each event. Delivery guarantees, batching, and retries come from the destination kind.
  • Aidbox publishes events produced from the moment a destination exists. A new destination receives no earlier events.
  • With organization-based hierarchical access control, the AuditEvent meta carries the organization of the request.

For a step-by-step setup, see How to subscribe to audit events.

Aidbox as a source of audit events

Aidbox produces audit events for significant events:

  • FHIR CRUD & Search operations for basic FHIR resources and custom resources (with BALP profiles)
  • FHIR CRUD & Search operations for Patient compartment resources (with Patient-specific BALP profiles)
  • User login and logout events (custom Aidbox event types, not BALP-conformant)
  • Password change events (DICOM subtype 110139)
  • SQL operations via $psql/$sql (custom aidbox/sql-interaction type, not BALP-conformant)
  • Bundle transaction entries (each entry audited individually with BALP profiles)

BALP profile selection

Aidbox assigns a BALP profile to each AuditEvent based on the operation type and whether the operation involves a Patient.

OperationGeneric ProfilePatient-specific Profile
CreateIHE.BasicAudit.CreateIHE.BasicAudit.PatientCreate
Read / VReadIHE.BasicAudit.ReadIHE.BasicAudit.PatientRead
Update / PatchIHE.BasicAudit.UpdateIHE.BasicAudit.PatientUpdate
DeleteIHE.BasicAudit.DeleteIHE.BasicAudit.PatientDelete
Search / QueryIHE.BasicAudit.QueryIHE.BasicAudit.PatientQuery

When Patient-specific profiles are used:

  • The resource is a Patient — CRUD operations directly on the Patient resource (e.g. PUT /fhir/Patient/123)
  • The resource is in the Patient Compartment and references a Patient (e.g. creating an Observation with subject pointing to a Patient)

Patient search (GET /fhir/Patient?...) uses the generic IHE.BasicAudit.Query profile, not IHE.BasicAudit.PatientQuery. This is because a search does not reference a specific Patient. The PatientQuery profile is used when searching compartment resources that reference a Patient (e.g. GET /fhir/Observation?patient=123).

Example: AuditEvent for Patient update

When you update a Patient resource, the generated AuditEvent uses the IHE.BasicAudit.PatientUpdate profile:

{
  "resourceType": "AuditEvent",
  "meta": {
    "profile": [
      "https://profiles.ihe.net/ITI/BALP/StructureDefinition/IHE.BasicAudit.PatientUpdate"
    ]
  },
  "type": {
    "system": "http://terminology.hl7.org/CodeSystem/audit-event-type",
    "code": "rest",
    "display": "Restful Operation"
  },
  "subtype": [
    {
      "system": "http://hl7.org/fhir/restful-interaction",
      "code": "update",
      "display": "update"
    }
  ],
  "action": "U",
  "recorded": "2026-02-25T12:00:00Z",
  "outcome": "0",
  "agent": [
    {
      "who": {
        "reference": "Client/my-client"
      },
      "requestor": true
    }
  ],
  "source": {
    "observer": {
      "display": "Aidbox"
    }
  },
  "entity": [
    {
      "what": {
        "reference": "Patient/example"
      },
      "role": {
        "system": "http://terminology.hl7.org/CodeSystem/object-role",
        "code": "4",
        "display": "Domain Resource"
      },
      "type": {
        "system": "http://terminology.hl7.org/CodeSystem/audit-entity-type",
        "code": "2",
        "display": "System Object"
      }
    }
  ]
}

Password change AuditEvent

When a user's password is changed (via PUT /User/:id or PATCH /User/:id), Aidbox generates an AuditEvent with DICOM subtype 110139 ("User password changed").

{
  "resourceType": "AuditEvent",
  "type": {
    "system": "http://terminology.hl7.org/CodeSystem/audit-event-type",
    "code": "rest",
    "display": "Restful Operation"
  },
  "subtype": [
    {
      "system": "http://dicom.nema.org/resources/ontology/DCM",
      "code": "110139",
      "display": "User password changed"
    }
  ],
  "action": "U",
  "outcome": "0",
  "entity": [
    {
      "what": { "reference": "User/example-user" },
      "type": {
        "system": "http://terminology.hl7.org/CodeSystem/audit-entity-type",
        "code": "2"
      },
      "role": {
        "system": "http://terminology.hl7.org/CodeSystem/object-role",
        "code": "4"
      }
    }
  ],
  "agent": [
    {
      "who": { "identifier": { "value": "root" } },
      "requestor": true
    },
    {
      "who": { "display": "Aidbox" },
      "requestor": false
    }
  ]
}

Aidbox generates this event regardless of whether the password value changed.

External Audit record repository support

To send audit events to an external Audit record repository, create a webhook AidboxTopicDestination on the audit events topic with the repository endpoint. Aidbox delivers events as a FHIR Bundle of type history, described in Notification shape. The first entry of the bundle is an AidboxSubscriptionStatus, so check that the repository accepts this shape.

For setup instructions and a payload example, see How to subscribe to audit events.

FHIR Resource versioning

A separate version is recorded in the history table each time a resource is created, updated, or deleted.

All versions can be accessed using the _history operation.

Logging configuration

Aidbox automatically logs all auth, API, database, and network events, so in most cases, basic audit logs may be derived from Aidbox logs.

Aidbox also provides ways to extend Aidbox logs.

Audit coverage

OperationAuditedBALP ProfileNotes
REST Create (POST)YesIHE.BasicAudit.Create / PatientCreate
REST Read (GET)YesIHE.BasicAudit.Read / PatientRead
REST Update (PUT/PATCH)YesIHE.BasicAudit.Update / PatientUpdate
REST DeleteYesIHE.BasicAudit.Delete / PatientDeleteEntity reference includes /_history/version, see Known limitations
REST SearchYesIHE.BasicAudit.Query / PatientQuery
Bundle transactionYesPer-entry BALP profilesEach entry gets its own AuditEvent
Password changeYesNo (DICOM 110139)See Password change AuditEvent
$psql / $sqlYesNo (aidbox/sql-interaction)Custom Aidbox type system
User login/logoutYesNo (custom)Not BALP-conformant
GraphQLIndirectVia underlying FHIR callsThe GraphQL query text is not captured; only the translated FHIR operations are audited
Bulk $import / $loadNo—Imported resources have no audit trail
Bulk $exportNo—
Auth token issuanceNo—client_credentials grant, /auth/token not audited
/auth/userinfoNo—
Configuration changesNo—
AuditEvent search, read, createExcluded—Intentional, prevents infinite audit loops

Known limitations

Delete entity reference includes version: Delete AuditEvents carry the entity reference as ResourceType/id/_history/versionId (e.g. Patient/123/_history/5). A consumer that matches events by Patient/123 misses delete events unless it strips the version suffix.

Bulk import has no audit trail: Resources created via $import or $load bypass the CRUD pipeline and do not generate AuditEvents. If you need a complete audit trail, use individual FHIR CRUD operations or Bundle transactions instead.

GraphQL queries are not directly audited: GraphQL requests generate AuditEvents only for the underlying FHIR search/read operations, not for the GraphQL query itself. The original query text is not captured in any AuditEvent.

See also:

Last updated: