Audit trail (IHE ATNA)
FerroEHR keeps a full security audit trail of API access (who did what to which resource, with what outcome, from where, and when) following the IHE ATNA (Audit Trail and Node Authentication) profile, the standard the openEHR reference text points at (its platform service description names a system log “IHE ATNA-compliant”). It is on by default: every deployment records a queryable audit trail with zero external dependencies.
Warning
Two postures are legitimate to run and wrong to run silently, so the server says them at
warnon boot (structured fieldposture = "audit"), in theaudit_senderreadiness indicator and on/management/info: auditing off ([audit] enabled = false) writes no access log and leaves the EHDS logging component off, and the shipped defaultfail_mode = "open"drops a record the audit queue cannot take while the request succeeds, so an access under load can go unrecorded. A deployment that must never serve an unrecorded access setsfail_mode = "closed", which answers503andRetry-Afterinstead. A deployment declaringdeployment.profile = "production"refuses to start with auditing off.
- The record, in both official formats
- The openEHR access-log entry
- Reads are logged too, per record
- The EHDS logging elements, mapped
- Reading the access log over ITS-REST
- Sinks
- Tamper evidence
- Checkpoints and the transfer of a log
- Retrieving audit records (ITI-81)
- Node authentication (ITI-19, mutual TLS)
- Against independent ATNA implementations
- Configuration summary
The trail is orthogonal to openEHR’s own CONTRIBUTION/AUDIT_DETAILS
change-control audit (which the server always writes in the same transaction
as every version change): openEHR audit records what a version says about its
own authorship; ATNA records security surveillance of access, including
reads and rejected attempts.
The record, in both official formats
Every audited operation produces one record, rendered in the two formats the
IHE standards define. Both are written by the shared audit crates of the
FerroHEALTH products (FerroAUDIT): ehds-logging writes the EHDS access
record, and ihe-atna writes the BALP AuditEvent and the DICOM audit
message and sends them. FerroEHR decides which accesses are logged, what each
record says and where it is stored.
- FHIR R4
AuditEventfollowing the IHE BALP 1.1.4 (Basic Audit Log Patterns) content profiles: the modern RESTful-ATNA form and the canonical stored form. An access to clinical content is the EHDS access record:ehds-loggingwrites it on theRESTfulpattern of its action, with the patient behind the EHR as the patient entity (PatientRead,PatientCreateand the otherPatient*claims), the categories, the retention, the security labels and the origins. Every other record (an authentication, a template or party operation, a refused access) is a BALP exchange FerroEHR fills directly. The person is theagent:userslice, named by the token’s issuer and subject, with the token’sjtias itspolicy, the caller’s roles as itsroleand the client application as an agent of its own (BALP 1.1.4 §3:5.7.5.4); a Basic user is named by the account alone, with no issuer and no client. The ITS-REST operation id is a secondsubtype(urn:openehr:its-rest:operation). The object an access record reads, creates, updates or deletes is named by its openEHR object id asentity.what.identifierin the systemurn:openehr:object-id, never as awhat.reference, since it is no FHIR resource (FHIR R4 references.html §2.3.0.3). The outcome is stated inoutcomeDesc, andsource.typenames an application server. Query executions carry the search expression. - DICOM Audit Message (DICOM PS3.15 §A.5 XML): the classic ATNA form,
shipped as RFC 5424 syslog over RFC 5425 TLS per IHE ITI-20 when the syslog
sink is enabled, with the optional
EventOutcomeDescription,AuditSourceTypeCode(4, an application server) and each participant object’sParticipantObjectDataLifeCycle. A record about a patient’s data names the patient (Patient Number) and, when it has one, its object as a System Object with the ID type URI (PS3.15 Tables A.5.1.2.2-1 and A.5.1.2.4-1), the same id the FHIR form names. Dedicated DICOM event ids are used throughout: Patient Record (110110), Query (110112), Export/Import (110106/110107, the EHR-Extract directions), User Authentication (110114, with the LoginEventTypeCode110122).
Both formats give the client and the server the same data-flow role: on a
read the server is Source (DCM 110153) and the client Destination (110152),
because the data moves from the server to the client (DICOM PS3.15 §A.5.2.7,
the BALP Read profiles); on a create, an update and a query the client is
Source (PS3.15 §A.5.3.20 for a query, the BALP Create, Update and Query
profiles).
Every server operation is audited (an unrecognised extension operation fails
closed to a generic audited class, so nothing is silently unaudited) and
access refusals are always recorded: a 401, a 403, and the 400 a
malformed Authorization header earns. A refusal is attributed to the caller
only when one actually authenticated; an unattributable denial is recorded
as unattributed rather than under a fabricated subject, so no audit record
ever names an identity that did not authenticate.
Note
Successful-login records are suppressed by default (
[audit] suppress_login_events = true). Set it tofalseto record them. Even then, a login record marks a genuine authentication event, not every authenticated request: it is emitted when credentials were actually verified: a Basic verified-credential-cache miss. A cache hit continues an established session, and a Bearer request authenticated out of band at your identity provider, so neither mints a per-request login record. Rejections are recorded regardless of this switch.
The openEHR access-log entry
Every access to EHR data is recorded as an openEHR access-log entry: an
ACCESS_LOG_ENTRY of the draft org.openehr.rm.access_log 0.1.0 model,
FerroEHR’s proposal to openEHR, which no openEHR release defines yet. Reads,
writes, AQL queries, exports, refusals and reads of the access log itself each
write one. An access that reaches several EHRs writes one entry per EHR, and
the entries of one request share its request id, so a population query writes
one entry for each EHR that contributed a row, a statement that projects
only the EHR (SELECT e/ehr_id/value FROM EHR e) included.
The administrative routes that touch an EHR write entries the same way, one
per EHR they touched: the physical EHR delete, one EHR or in bulk; the
restriction, research-objection, access-delay and access-repair registers and
the EHR_ACCESS settings commit that carries a restriction or an opt-out;
archiving an EHR and restoring it; its retention anchor and the retention hold
on one of its objects; the repository dump and load; and the EHR Extract
export and import. The import of another system’s access log (ferroehr access-log import) writes its import entry through the same path. SCIM
provisioning touches party data only and writes none.
The entry names who accessed (the bound party, the groups, the provider, the
binding outcome and the credential by its issuer, subject, client and token
id), what (the EHR, the version or object, its categories and origins), why
(the declared purposes), under which authorisation (the agreement, the
representation, a data permit, the emergency mark, and the grounds of the
access decision below), the outcome (granted, refused or failed) and
the request. It carries no data value of the EHR:
a query is named by its stored name or the SHA-256 of its text, never the
text, and a read of the access log through ITI-81 is named by the digest of
its search.
The grounds of the access decision. The access evaluator’s decision on
the EHR is in the entry’s authorisations, each an ACCESS_AUTHORISATION
whose name and version name the document the ground is defined in:
| Kind | When | What it names |
|---|---|---|
role | always | each grant the caller held, by its operation code (name) and the ROLE that carries it (reference); each role the caller held |
subject of care | the person reads their own record | |
consent | a consent permit admitted the access, or the caller is a gate-keeper of the settings | EHR_ACCESS and the uid of its version; the directive by its uid, its first identifier or its position from 1, and its legal grounds |
representation | a delegation permit admitted a representative | as consent |
treatment relationship | the decision read a live care relationship | ACCESS_POLICY and the uid of its version |
emergency | an emergency lifted a directive or steps 4 to 7 | the directive it lifted, or the ACCESS_POLICY version |
The entry of each EHR an AQL query served names the same grounds a read of
that EHR alone names. The query’s condition is built from this replica’s copy
of every EHR’s settings, which holds each EHR’s subject and the uid of its
EHR_ACCESS version beside the settings, so the record adds no database read.
For an EHR with no settings, which the copy does not hold, a care relationship
is named when only a caller in care could have been served its rows.
A refusal names its code in outcome.reason, in the ferroehr-operations
terminology, and in outcome.description the step that refused and the
directive or policy of that step, such as step 2 (restriction): directive 1 of EHR_ACCESS 5a1c…::cdr.example.org::2. This holds for the 404 of an
opt-out or a restriction too: the response says nothing (EHDS Art. 8), and
the entry says why. An override in an emergency sets is_emergency, so the
person sees it in their access log (EHDS Art. 9 and 11(5)). The EHDS record
writes the versions the grounds name after the data permit at
agent[user].policy, “the policy or plan that authorized the activity being
recorded” (FHIR R4 AuditEvent.agent.policy), read from the entry’s grounds
when the record is rendered. Which grounds are named is FerroEHR’s own design.
The entry is the record. The store keeps an access to EHR data as its
entry alone, in audit.access_log_record, chained under one hash chain (see
Tamper evidence), and each entry states the date it is
kept until and why. The FHIR AuditEvent the ITI-81 search and the ITI-20
FHIR feed serve, the DICOM message the syslog sink sends and the EHDS access
record are projections of the stored entry: each is written from what the
log keeps and from nothing else, and none is stored as a second record.
audit.audit_event keeps the records of accesses outside the access log: an
authentication, a template or party operation, an application activity.
The entry is written in one database transaction with the rest of its batch,
and an access whose entry the store cannot take is refused under
fail_mode = "closed". The store requires [audit.store]; with the store off
the drain still builds each entry and sends its projections to the syslog
sink and the FHIR feed, and keeps nothing.
FerroEHR’s access details
The draft’s core attributes are openEHR’s: the action, the outcome, the
accessor, the items, the query, the authorisations, the channel. The facts
the BALP AuditEvent, the DICOM message and the EHDS access record carry
that the core holds no attribute for are kept in the entry’s
other_details, which the draft gives to the fields a jurisdiction adds: one
ITEM_TREE under the archetype id
openEHR-EHR-ITEM_TREE.ferroehr_access_details.v0, one ELEMENT per fact,
named by its at-code. They are part of the entry, so the hash chain covers
them, and a tombstone removes them with the rest of its content. No openEHR
specification governs them: they are FerroEHR’s own.
| at-code | Name | Value | Holds |
|---|---|---|---|
at0001 | event action | DV_TEXT | the DICOM EventActionCode: C, R, U, D or E |
at0002 | resource class | DV_TEXT | the class of resource the access addressed |
at0003 | outcome indicator | DV_COUNT | the DICOM EventOutcomeIndicator: 0, 4 or 8 |
at0004 | principal | DV_TEXT | the login the access was made under |
at0005 | issuer | DV_TEXT | the issuer of the caller’s token |
at0006 | client id | DV_TEXT | the client the token was issued to |
at0007 | token id | DV_TEXT | the token’s jti |
at0008 | organisation | DV_TEXT | the organisation the token named |
at0009 | role | DV_TEXT | a role the caller held, one element each |
at0010 | domain | DV_TEXT | the pseudonymisation domain, when it is not the resource class’s own |
at0011 | ehr id | DV_TEXT | the EHR the request named |
at0012 | subject | DV_IDENTIFIER | the subject of care of the EHR, as EHR_STATUS.subject names it, with its namespace as the issuer |
at0013 | subject lookup failed | DV_BOOLEAN | set when the subject could not be looked up |
at0014 | object id | DV_TEXT | the object the request named; none for a read of the log, whose search the entry names by digest |
at0015 | purpose | DV_TEXT | the purpose of use the caller declared |
at0016 | legal basis | DV_TEXT | the legal basis the deployment attributes |
at0017 | result count | DV_COUNT | how many records the access served |
at0018 | origin | DV_TEXT | an origin of the data, one element each |
at0019 | origin count | DV_COUNT | how many distinct origins the data had |
at0020 | category map digest | DV_TEXT | the category map the access was classified through |
at0021 | category content | DV_PARSABLE (application/json) | what the classification read |
at0022 | acting mode | DV_TEXT | how the credential acted |
at0023 | assurance level | DV_TEXT | the assurance level of the authentication |
at0024 | assurance value | DV_TEXT | the claim value the level was read from |
at0025 | professional id | DV_TEXT | the identifier of the natural person who accessed |
at0026 | token attributes | DV_PARSABLE (application/json) | the purposes and roles the token stated |
at0027 | binding | DV_PARSABLE (application/json) | the party binding with every field |
at0028 | summary | DV_PARSABLE (application/json) | the count and EHRs of a summary of refusals |
at0029 | event type | DV_TEXT | the DICOM EventTypeCode of an authentication record: 110122 Login, 110123 Logout |
The subject of care is kept so the BALP entity:patient and the
patient search parameter name the patient as they did when the access
was recorded, whatever happens to the EHR after. An entry imported from
another system (Checkpoints and the transfer of a log)
keeps that system’s details, and FerroEHR projects none of it.
To read the trail with SQL, audit.access_trail holds every record of
either form with the facts it states, in the audit vocabulary
(operation, principal, binding, party and the rest), an entry’s read
from its content. audit.access_detail(content::jsonb, 'at0022') reads one
access detail of an entry. The categories a classification computes are no
column there: the projection writes them.
The projections and their losses
Each projection reads one stored entry and writes one target record.
“Loss” means the target has no place for the value; the entry keeps it. The
FHIR R4 AuditEvent follows IHE BALP 1.1.4; an access the category map did
not classify is a BALP exchange without the EHDS entities. Each row is a test
(access_log::projection in the source).
To the FHIR R4 AuditEvent (IHE BALP 1.1.4).
| Entry | AuditEvent | Loss |
|---|---|---|
action | action (C, R, U, D, E), type rest and the FHIR interaction as the first subtype; an export or import is type Export or Import | the openEHR action has no code system of its own: export and import fold into R and C |
operation | a subtype in urn:openehr:its-rest:operation | none |
time_recorded | recorded | occurred: no period is written |
outcome.result | outcome: 0 granted, 4 refused or a minor failure, 8 a serious failure | refused and a minor failure share 4; outcomeDesc states the outcome in words and no reason code |
outcome.delivered | the delivered detail of the ehds-categories entity | none, as a detail |
accessor.party | the ihe-otherId typed PRN of agent:user (BALP 1.1.4 §3:5.7.5.4) | none |
accessor.credential | agent:user who.identifier (issuer as system, subject as value), the token id as its first policy, the client as an agent of its own, the assurance as ihe-assuranceLevel | the authentication method has no element |
accessor.provider | an agent naming the organisation | none |
accessor.roles, accessor.kind | agent:user role, the acting mode first | none |
accessor.groups, accessor.binding, accessor.delegation | details of the ehds-accessor entity, one actor per actor in the chain’s order | no element; details |
ehr_id | the ehr entity, with the subject of care as the patient entity (entity:patient, role 1) | none |
items | entity:data (type 2, role 4) naming the version in urn:openehr:object-id; the categories and the template and archetype ids as details of ehds-categories | the RM type and the paths have no element |
items.origins | one origin entity each | no element; entities |
query | entity:query (role 24), a stored query by its name | the text digest is not written |
purposes | purposeOfEvent and agent:user purposeOfUse | none |
authorisations | a permit as a policy of agent:user after the token id; an agreement in the ehds-relayed entity; a representation in ehds-accessor | legal grounds have no element; details |
is_emergency | the ehds-emergency-access entity naming the purposes that marked it | the mark becomes an entity |
channel.request_id, channel.client_address | the X-Request-Id entity; the client agent’s network.address | none |
system_id | source.observer.identifier; source.site from [audit] enterprise_site_id | none |
security_labels | the securityLabel of the entity they label | no meta.security is written |
retention | details of ehds-categories | no element; details |
link, checkpoints | nothing | the chain does not travel; verify it on the openEHR side |
other_details | the values it holds, where the rows above put them | the tree itself is not written |
To the DICOM PS3.15 A.5 audit message (the syslog sink).
| Entry | DICOM element | Loss |
|---|---|---|
action | EventActionCode; EventID Patient Record (110110), Query (110112), Export (110106), Import (110107) | as in R4 |
operation | EventTypeCode in openEHR-ITS-REST | none |
time_recorded | EventDateTime | occurred |
outcome | EventOutcomeIndicator, EventOutcomeDescription | the reason’s code |
accessor.credential | the requestor’s UserID (the subject, or the professional a client acts for) | the issuer, the token id, the assurance |
accessor.roles | RoleIDCode in urn:ferroehr:role | none |
accessor.party, binding, groups, delegation | details of the ehds-accessor participant object | no element; details |
accessor.provider | nothing | lost |
system_id | AuditSourceID, with AuditEnterpriseSiteID from the deployment | none |
channel.client_address | NetworkAccessPointID, type 2 | none |
ehr_id | the patient participant (type 1, role 1) names the subject of care | the ehr_id itself is not written |
items | a System Object (type 2, ID type URI) naming the version | the categories, origins, template and archetype |
query | the query object of the Query event | the text digest |
purposes, authorisations, is_emergency | nothing in the A.5.1 schema | lost |
retention, security_labels, link, other_details | nothing | lost |
To the EHDS access record (ehds-logging AccessRecord).
AccessRecord | Entry | Loss |
|---|---|---|
action | action | export and import fold into Read and Create |
recorded | time_recorded | none |
outcome, outcome_description | outcome.result and the outcome indicator | a refusal shares MinorFailure with a minor failure |
accessor (issuer, subject, client, token id, acting, roles, assurance, provider, party, groups, binding, actors, represents, relayed, purposes, policies) | accessor, purposes, authorisations and the access details | none |
subject.ehrs | ehr_id, with the subject of care found | one record per entry; the entries of a request share its request id |
categories | items.categories, computed again through the category map that classified the access | none |
delivered, origins, origin_count | outcome.delivered, items.origins, the origin count | none |
request (id, operation, resource, stored query, client address, correlation) | channel, operation, items, query | the query text is never carried |
retention, labels, emergency | retention, the categories and origins, is_emergency | none |
| none | link | the chain |
Reads are logged too, per record
A write leaves its own trail in openEHR’s contribution and audit chain. A read leaves nothing behind unless the server records it, and reads are what the access-logging rules are about: NEN 7513 requires per-access logging of who consulted which record and on whose authority, the Wabvpz gives the patient the right to know who consulted their record, and EHDS Art. 9 requires logging of access to electronic health data for primary use. No openEHR specification governs the read side, so this is FerroEHR’s own extension.
Every retrieval in the EHR, Query and Demographic APIs produces a record, and a
test walks the generated route tables to prove it: a newly generated GET that
emits nothing fails the build.
Each record additionally carries:
| Field | What it holds |
|---|---|
domain | The pseudonymisation domain read: ehr, demographic, linkage for a crossing that resolves a party or a subject to its EHRs, or system for an operation that touches no domain. |
organisation | The organisation a record written before 5.7.2 names, as an access-token claim named it. FerroEHR reads no organisation claim, so a new record leaves it empty; the provider the caller acts for is the binding’s provider. |
purpose | The purpose of use the caller declared in the x-purpose-of-use header, when the deployment accepts it. |
token_attributes | The purposes of use and the professional roles the access token states, each with its code system, for an issuer with an [[auth.attributes]] table (where the purpose comes from). |
emergency_access | true when the declared purpose, or a purpose the token states, is one of [audit] emergency_purpose_codes: an emergency access (EHDS Art. 11(5)). |
legal_basis | The basis the deployment processes under, from [audit] legal_basis. |
result_count | How many records the operation served. |
request_id | The x-request-id correlation id the response carried. |
A query is the case a single record cannot describe. One AQL statement is one
operation but potentially many disclosures, so it produces its own execute
record plus one access record per EHR it served, each carrying that EHR’s
served-row count. The served set is read off the rows the caller actually
received rather than the rows the statement matched: a legal record of access
must not name an EHR whose content was never disclosed. Each row names the EHR
of every EHR source and every versioned object it was drawn from, so a
statement that reads only the EHR is attributed too. Two query shapes carry
no per-EHR breakdown, because the shape makes it underivable —
SELECT DISTINCT, where an extra column changes which rows are distinct, and
an aggregate projection, where a per-row EHR is not valid SQL. Those record the
statement and its row count.
NEN 7513 content, field by field
NEN 7513 §5 lists what a logged event has to contain. This is where each item lives in the record:
| NEN 7513 asks for | FerroEHR records it as |
|---|---|
| The identity of the person who accessed the record | principal — the authenticated Basic username or OAuth sub; an unattributable denial is recorded as unattributed, never under a fabricated identity. With [authz.professional] configured, professional_id names the natural person when the token names a client application |
| The identity of the patient whose record was accessed | patient_id — the resolved EHR subject, which under the pseudonymisation boundary is an opaque pseudonym |
| Which record, or which part of it | resource_class + resource_id: the version uid, party uid or EHR id the operation touched |
| The date and time | recorded_at, the event time; stored_at is when the row was persisted |
| The kind of action | action (DICOM C/R/U/D/E) plus operation, the released ITS-REST operation id. It equals the served OpenAPI operationId except for the demographic CONTRIBUTION pair, served as demographic_contribution_create and demographic_contribution_get because the released contribution_create and contribution_get also name the EHR operations and one document needs unique ids |
| Whether it succeeded | outcome, the DICOM outcome indicator (0 success, 4 minor, 8 serious, 12 major) |
| Under which role or authority | roles — the roles the caller held at access time (the RFC 9068 §2.2.3.1 claim carriers for a bearer, the user definition for Basic), rendered as FHIR agent.role on the requestor and as a RoleIDCode per role on the DICOM requesting participant |
| On whose authority, and why | purpose and legal_basis, and permit, the identifier of the data permit a secondary-use caller declares it acts under (Secondary use) |
| Which system, and from where | AuditSourceID and the source participant’s network address (client_ip): the connection’s peer, or the client a peer in [server] trusted_proxies names in its forwarded_header (Server) |
| Who the person is in the demographic store, and for whom they act | binding and the fields beside it (the binding outcome): party (the bound PERSON), party_groups, provider, representation for a representative, and acting_mode (person, delegated, external or system); for a verified external accessor external_fields and agreement stand in for the party, and an organisation record names the organisation. The FHIR AuditEvent, the DICOM message and the syslog feed carry each in the ehds-accessor and ehds-relayed entities (the binding fields in the renderings) |
Two of these are the deployment’s to supply. purpose is only as meaningful as
the vocabulary you agree with your callers: set [audit] purpose_codes to that
vocabulary and a code outside it is recorded as absent rather than as free text
that reads at review time like an established purpose. legal_basis is a
deployment-level fact and is recorded on every access once you set it.
Mapping the recorded fields onto your own retention schedule and review process stays yours: the software records the events and serves them back, and no supplier document discharges the obligation to review them.
The EHDS logging elements, mapped
Annex II 3.2 of Regulation (EU) 2025/327 lists five things the European logging software component must record “on every access event or group of events”. This is where each one lands, or does not. The elements were read from the published text on 2026-09-10; the regulation is the authority and the wording below is a paraphrase.
| Annex II 3.2 | Access-event field | DICOM PS3.15 | FHIR AuditEvent | State |
|---|---|---|---|---|
| (a) the healthcare provider or other individuals having accessed | provider of the binding (the provider of the caller’s party binding, read from the CDR), or the organisation record of a verified external organisation | — (no such attribute) | the acts-for detail of the ehds-accessor entity | Recorded |
| (b) the specific natural person or persons having accessed | principal (+ token_id, client_ip), and professional_id + acting_mode for a caller its issuer classifies as a person or a delegate | ActiveParticipant/@UserID (the professional; a client application acting for one is a second, non-requesting participant; the token subject is @AlternativeUserID when it differs) | the agent:user slice, who the token’s issuer and subject, the professional’s identifier as its ihe-otherId, and the client application as an agent of its own (BALP 1.1.4 §3:5.7.5.4) | Recorded |
| (c) the categories of data accessed | categories + category_basis + category_evidence + category_map_digest, classified by ehds-logging through the audit category register (beside resource_class, domain and result_count) | none (no such element) | the entity named ehds-categories, with one ehds-category detail per category and its basis, each id the classification read and the map digest; each category is also a meta.security label | Recorded |
| (d) the time and date of access | recorded_at | EventIdentification/@EventDateTime | recorded | Recorded |
| (e) the origin or origins of data | origins + origin_count (the FEEDER_AUDIT originating systems of the served version bodies, or the server that created them, derived at commit onto version.origins) | — (no such element) | one entity named origin per origin, its system-id detail the originating system | Recorded |
Read (a) beside (b): they are both about the accessing side, and the pair
distinguishes the organisation on whose behalf the access happened from the
natural person who made it. The principal answers (b); the provider of the
caller’s party binding answers (a). It is read from the CDR, never from a token
claim, so the provider a record names is the one the deployment bound the
caller to. A caller with no binding, such as a Basic user with no PERSON,
leaves it empty rather than guessed.
Element (b) asks for a natural person, and a bearer token can name a client
application instead. Each issuer’s kind and profile
classify the caller, so every record says which it was and who stood behind it:
| Field | Meaning | DICOM PS3.15 | FHIR AuditEvent |
|---|---|---|---|
acting_mode | person when the token names a natural person, client when it names a client application | the participant split below | the agent split below |
professional_id | the natural person: the person’s own claim, or the professional a client token acts for | ActiveParticipant/@UserID of the requesting participant | the ihe-otherId extension of the agent:user, typed NPI |
principal | the token subject, as before: the client application in client mode | a second ActiveParticipant with UserIsRequestor="false" and the network address; @AlternativeUserID in person mode when it differs from the professional | agent:user who.identifier, with the issuer as its system; the acting mode is its first role |
assurance_level | the eIDAS level (low, substantial, high) the token’s assurance claim maps to under [authz.assurance] | none (no such attribute) | the ihe-assuranceLevel extension of the agent:user |
assurance_value | the raw claim value the level was read from, usually acr | none | none |
PS3.15 §A.5
gives ActiveParticipant no assurance attribute, so the DICOM message and the
syslog feed carry no level. The FHIR export carries the level as the BALP
ihe-assuranceLevel extension (BALP 1.1.4 §3:5.7.5.4) and never the raw claim
value, which lives in the local store’s column only. The tamper-evidence digest covers both columns, like every other column of
the record (see Tamper evidence for records written before
the digest was versioned).
For a system caller the mode and the professional stay empty and (b) is
answered by principal, which names the client application. Without [authz.assurance] levels the level stays empty;
the raw value is still recorded when the token carries the claim. A Basic
credential records none of the four.
Element (c) asks for the priority category of the data, in the sense of
Art. 14(1): patient summaries, electronic prescriptions, electronic
dispensations, medical imaging, medical test results and discharge reports,
plus any category a Member State adds in national law. AQL selects archetypes
and templates, never categories, and no openEHR specification maps the one
onto the other, so the deployment declares the mapping in
the audit category register, an
admin register: a
template id, or failing that the root archetype id, maps to a set of categories
(a priority category by its code in HL7 Europe’s
EEHRxFDocumentPriorityCategoryCS, such as Patient-Summaries or
Laboratory-Reports, a national category as its <system>|<code>), or to
none for content that holds no data of any category. While you declare no
template and no archetype, the map FerroEHR ships applies: the published CKM
templates and COMPOSITION archetypes whose data sit in one priority category
(the shipped map). Your own
map replaces it, and ehds-logging classifies each access through the map in
force.
Each record is classified when the access happens, from what it served or wrote, and never at commit, because the map is your reading of your templates and can change:
- a composition read or write is classified by the version’s template id, then by its root archetype id;
- an AQL execution is classified by the template and root archetype ids of the
versions its result page came from; where the answer carries no version (a
DISTINCTor aggregate projection, or zero rows) by the query’s positive archetype and template constraints, so an operand underNOT CONTAINSor a predicate underNOTnever counts. Every id the query constrains to must be mapped, and every content operand bound to an id, or the record isunclassifiedbeside what did map. Each per-EHR record of a query carries the categories that EHR disclosed; - a logical delete writes no content, so it is classified by the version it
deleted; a
VERSIONED_COMPOSITIONread by the composition it holds; - a
CONTRIBUTIONread, with or withoutPrefer: resolve_refs, is classified by the versions the contribution committed, a deleted version again by the version it deleted; - an EHR Extract export is classified by every version it carried, and an Extract import by the newest content of every versioned object it landed;
EHR,EHR_STATUS,EHR_ACCESS, the directory, item tags and revision histories are recorded asnone, by resource kind.
An access the map cannot classify is recorded unclassified, with the
template and archetype ids as evidence, and is never refused; the FHIR record
says why (unmapped, unbound, named-nothing). A stored category is its
<system>|<code> token. category_basis says what the classification was read
from (returned, written, queried or resource-kind; records written
before 5.3.2 carry template, archetype or query and the earlier
spellings), and category_map_digest names the map that produced it, so a
later map never rereads an old record. The map’s
digest is also on the boot line and on GET /management/info under
audit.category_map. The classification stays in the access log: it is never
written to the request log, a span or a metric label. The DICOM rendering has
no element for it (PS3.15 §A.5), so it travels in the local store and the FHIR
export only.
Records in the demographic domain carry no classification, because no priority category lives there.
Element (e) asks where the DATA came from, which is not where the request came
from. openEHR models that provenance as FEEDER_AUDIT on the content itself,
so every committed version records the distinct set of
FEEDER_AUDIT.originating_system_audit.system_id values found in its body, or
this server’s own system id when it carries none. A composition, status or
folder read then records the origins of the version it served, and an AQL
execution the union over the version rows its result page came from. The record
carries the true distinct count beside a set capped at 32, so a page drawing on
more origins than that says how many rather than looking complete. A version
committed before the column existed is assessed when it is read.
One further element, adjacent to the five: the declared purpose of use
reaches one export of the two, and only one of them could carry it. It is
stored on the record, served by ITI-81, and rendered as
agent.purposeOfUse on the
requesting person’s agent in the FHIR export. A declared code carries no
system: the vocabulary is the one you agree with your callers in [audit] purpose_codes, which has no published code system URI, and attributing the
code to a system it does not come from would misdescribe it. A purpose the
access token states keeps the system the token gives it.
The
DICOM Audit Message schema
of PS3.15 §A.5 defines no purpose element at all — EventIdentification,
ActiveParticipant, AuditSourceIdentification and
ParticipantObjectIdentification, and none of them carries one — so on that
side it is a limit of the format, not something this code withholds.
Where the purpose of use comes from
The purpose of use reaches the record from two places:
- The access token. An issuer with an
[[auth.attributes]]table (mapping = "iua") states its professionals’ attributes in the token: the IHE IUApurpose_of_useandsubject_roleclaims underextensions.ihe_iua(IHE ITI TF-2 §3.71.4.2.2.1.1), and withauthorization_details_purposesthepurpose_of_useof each RFC 9396authorization_detailsentry. The record stores them intoken_attributes, and both renderings write them with their code systems: the purposes at the requesting agent’spurposeOfUse, the roles at itsrole, beside the roles the caller held. - The
[audit] purpose_header(x-purpose-of-use), which the caller sets. It works alone for an issuer without an[[auth.attributes]]table, as before.
The token is the authorization server’s statement, so it decides. A request
whose header names a purpose the token, which states purposes, does not
state is refused with 403, and the refusal is recorded as a failed
authentication naming the caller and the token’s purposes. A header naming
one of the token’s purposes is admitted and recorded with both. Which source
wins is FerroEHR’s own design; no openEHR specification governs the purpose
of use.
Note
Every row of this table is asserted by a test (
app/ferroehr/tests/it/audit_ehds_mapping.rs), including the gaps: the tests that record an absence fail the day the field arrives, so the table and the code cannot drift apart in either direction.
The common specifications the regulation’s Article 36 provides for have not been adopted. When they are, this mapping is re-verified against them rather than assumed to still hold; see the EHDS readiness page.
The binding outcome
Every record of an authenticated request carries binding: how the caller
was bound to a demographic party, or why the binding refused it. The
committer the same request writes into a version is on
Who is the committer. It answers
Annex II 3.2(a) and (b) where the token’s subject alone does not. The columns
beside it hold what each outcome needs:
binding | The caller | Recorded beside it |
|---|---|---|
bound | a person bound to a complete PERSON | party, party_groups, provider, guest for an admitted guest, representation for a representative, actor_chain for a delegated token |
provisional | a person bound to an incomplete PERSON | party, party_groups, provider |
external | a verified external person of a federation issuer | external_fields, agreement, provider |
organisation | an organisation under an agreement with accessor = "organisation" | external_fields, agreement (with its legal ground and access class, and for a chained request correlation_id and correlation_source), provider |
system | a client acting for nobody | party, the client’s ACTOR in the policy parties; provider, the identifier of the ORGANISATION its acts-for relationship targets; facilities of the compositions it committed |
self | a patient token of a patients issuer | the principal |
refused-* | a refusal of the binding or of a caller kind: unbound, ambiguous, inactive, abandoned, deprovisioned, wrong-marker, representation-unrecorded, key-claim-missing, groups-unavailable, guest, external-incomplete, trc-patient-mismatch, trc-missing; and of a caller kind, system-personal-scope (a system caller holding a user/ or patient/ scope), no-agreement (no federation agreement admits the accessor) and scope-beyond-agreement (an external caller holding a scope its agreement does not read) and correlation-missing (a chained organisation request without an attested correlation id) | party for a party refused for its state or marker, binding_detail for what else the refusal names (represented, the subject a representative asserted; claim, the name of the key claim a token lacked, never its value) |
acting_mode is person, delegated for a person through a declared client
or actor, external for a verified external accessor and system for a client
acting for nobody (client remains on records written before). The FHIR
AuditEvent writes each mode as the person’s agent.role. A record of a
request with no authenticated caller carries no binding. The columns are in the
chain digest: version 2 hashes them, version 3 adds token_attributes, a new
record is version 3, and a record written before keeps verifying under its own
version.
The binding fields in the renderings
Neither BALP 1.1.4 §3:5.7.5.4 nor DICOM PS3.15 §A.5 has an element for the
binding fields beyond the bound person, so ehds-logging writes them as
details of two entities it adds, and FerroEHR hands it every field. The FHIR
AuditEvent carries each entity as an entity with its name and one
detail per value. The DICOM message carries each as a
ParticipantObjectIdentification of type 4 (Other) with the entity name as
its ParticipantObjectName and one ParticipantObjectDetail per value
(RESTful ATNA Rev. 3.6 Table 3.20.4.2.2.1-1), and the ITI-20 syslog feed
sends that message. Both renderings take the detail list from
ehds-logging, so they never disagree.
| Recorded field | Rendered as |
|---|---|
binding | ehds-accessor: binding, with guest for an admitted guest and security-event for refused-trc-patient-mismatch and refused-trc-missing |
party | ehds-accessor: party as <namespace>|<type>|<id>; in the FHIR AuditEvent also the person’s otherId typed PRN |
party_groups | ehds-accessor: one group per group, in the party’s namespace with type GROUP |
provider | ehds-accessor: acts-for as <issuer>|<id> |
facilities | ehds-accessor: one facility per facility, as <issuer>|<id> |
representation | ehds-accessor: represents, represents-ground and represents-relationship; a refusal’s represented as represents alone |
actor_chain | ehds-accessor: one actor per actor, <issuer>|<subject>, outermost first |
binding_detail | ehds-accessor: binding-claim for refused-key-claim-missing |
external_fields | ehds-relayed, marked asserted and naming the issuer by relayed-issuer: each 2026/2099 Annex field and eHDSI SAML attribute at its own detail (hp-family-name, hp-identifier, provider-identifier and the others), consent.reference as agreement-consent, and every other field as asserted-field <name>=<value> |
agreement | ehds-relayed: agreement-name, agreement-version, agreement-legal-ground and agreement-access-class |
correlation_id, correlation_source | the FHIR AuditEvent: correlation-id and correlation-source of the request id’s entity; the DICOM message: the same two details of ehds-relayed, since it carries no request entity |
acting_mode | the FHIR AuditEvent: the person’s agent.role; DICOM: none |
Every value goes through the renderers’ escape: a control character, a bidirectional control or a line separator is written as its code point, and no value is cut. A DICOM detail value is base64-encoded as given (PS3.15 §A.5.1.1). A binding record that lacks a field its code needs fails the rendering, and the sender reports the failure, never a record without the binding.
Refusal records and their budgets
Every refused request is recorded as a failed user authentication, through the
same path as an operation record: under [audit] fail_mode = "closed" a
refusal whose record the system log cannot take is answered 503. A refusal of
the login binding or of a caller kind carries its refused-* code. Refusals
are charged to one of two budgets, which never draw on each other, so a flood
of invalid tokens cannot hide a verified caller’s probing:
| Budget | Charged to | Per caller in a window | Per window |
|---|---|---|---|
| Failed verification | the source network: the /24 of an IPv4 address, the /64 of an IPv6 one | 10 | 1000 |
| Verified caller | the token’s iss and sub | 10 | 1000 |
A window lasts 60 seconds. Past a caller’s 10 records the rest of its
refusals in that window become one summary record, written when the window
closes: it names the caller and carries summary, the count and the EHR ids
the refused requests named (at most 64, while the count stays exact). Past a
budget’s 1000 records, the refusals of every caller not yet recorded in that
window become one summary record per issuer and outcome, naming no caller. A
security event (refused-trc-patient-mismatch, refused-trc-missing) is
recorded once for every answered request and never summarised. A federation
caller above its agreement’s caller_rate, a contact point’s included, is
answered 429 before any patient lookup, and every such refusal goes into
that caller’s summary record from the first, with binding_detail naming
caller-rate, so the count of security events stays bounded. A refusal
record the system log cannot take is counted in
atna_audit_refusals_unwritten and logged at error.
Note
The limits, the windows and the budgets are kept per replica. Behind a load balancer with three replicas, one caller can have up to 30 refusals recorded one by one in a window before the summaries begin, and each replica writes its own summary records.
Access through FerroBRIDGE’s FHIR facade
The openEHR REST API carries no end-user identity on a read, so when
FerroBRIDGE’s FHIR facade reads or writes through FerroEHR, FerroEHR’s record
names the bridge’s credential under (b) and cannot name the natural person
behind the FHIR request. From FerroBRIDGE 0.0.16 the bridge records each
facade access itself when its [audit] section is on: it writes the Annex II
3.2 record with the person, the categories, the time and the origin through
the same ehds-logging crate, and sends it as an IHE BALP AuditEvent
through ihe-atna over the ITI-20 FHIR feed to the Audit Record Repository
you configure there. The bridge refuses a facade access whose record it
cannot take. Read the two records together: FerroEHR’s says which data left
the CDR and to which client, and FerroBRIDGE’s says which person asked for
it. FerroBRIDGE’s
access record page
describes its record and its configuration.
Emergency access (EHDS Art. 11(5))
A natural person may restrict health professionals’ access to parts of their data (EHDS Art. 8). Art. 11(5) lets a professional reach restricted data where the person’s vital interests require it, and requires such cases to be “logged in a clear and understandable format” and “easily accessible for the data subject”. Art. 9(1) counts these accesses among the ones the person is told about.
You name the purpose codes your callers declare for an emergency in
[audit] emergency_purpose_codes. Each one must also be on
[audit] purpose_codes; the server refuses to start otherwise. An access
whose declared purpose is one of them carries the emergency mark:
- The stored record: the
emergency_accesscolumn istrue. It isfalsefor every other access and for records written before the column existed. - The FHIR
AuditEvent: theentitynamedehds-emergency-accessthatehds-loggingwrites, whosedescriptionstates the mark in plain words (“Emergency access: the accessor declared that the access was necessary to protect the vital interests of the data subject (Regulation (EU) 2025/327 Art 11(5)).”) and whoseehds-emergency-purposedetails name the purposes that marked it. The declared code stays onagent.purposeOfUseand onpurposeOfEvent. A patient portal keys on the entity and shows its description. - The DICOM syslog feed: no mark. The PS3.15 schema has no purpose element.
The person reads their own log, the marked accesses included, through the subject-scoped ITI-81 retrieval.
[audit]
purpose_codes = ["TREAT", "ETREAT"]
emergency_purpose_codes = ["ETREAT"]
The mark records the declaration and lifts no restriction. A composition or
EHR restricted under GDPR Art. 18 stays refused with an emergency purpose,
because Art. 18(2) admits processing only with consent, for legal claims, for
the rights of another person or for an important public interest, and the
person’s own vital interests are not on that list. The refused attempt is
still logged with the mark. An EHDS Art. 8 restriction of access by health
professionals is different: a caller holding authz.rbac.emergency_access_role
that declares an emergency purpose reads the restricted data, and its record
carries the mark
(restriction of access).
An emergency the caller does not declare is not marked.
Retention, and who chooses it
[audit.store] retention decides how long the repository keeps a record:
0, the default, keeps them forever, and any other value sets the horizon.
Every record stores the first date it may be deleted on, and the reaper
deletes each record hourly on or after that date and never before it. An
access record takes its end from the retention its categories and origins
call for (Regulation (EU) 2025/327 Annex II 3.4), so two records written the
same day can end on different dates; every other record ends the day after
its date of access plus the horizon. A record written before FerroEHR stored
per-record ends is reaped by the horizon.
An openEHR access-log entry states its own retention. Each
ACCESS_LOG_ENTRY carries an ACCESS_RETENTION when it is written:
retain_until, the last day it is kept, and grounds, the provisions that
set the period. The period is the one the retention policy above computes from
the entry’s categories and origins, so an entry whose categories call for
different periods keeps the longest, and an entry kept without end states no
retain_until. The grounds are coded in the ehds-logging terminology: the
legal ground of the floor (eu-2025-327-art-9-2 for Art. 9(2)) and what called
for the period (default, category:<system>|<code> or origin:<key>). The
same hourly worker replaces every entry whose retain_until has passed by an
ACCESS_LOG_TOMBSTONE in place, in any order of expiry. The tombstone keeps the
entry’s uid, system_id, time_recorded and chain link, names the grounds of
the period that ended, and holds nothing else of the entry, so the chain
verifies after the content is gone (Tamper evidence). A
tombstone is never replaced again, and the database refuses any other change
to it. An erasure a law orders before the period ends takes the same path
through POST {ext}/admin/access-log/erase, with the law’s provisions as the
tombstone’s grounds; the erasure is an access record of its own
(access-log-erasure:<uid>) naming the administrator
(Admin APIs). No configuration key decides an
entry’s period beyond [audit.store] retention, which stays the floor every
period is held to.
The default is deliberate. An access log is the evidence a data subject’s right of access is served from, and a repository that silently forgets is worse than one that grows — so the software keeps everything until an operator says otherwise, rather than choosing a horizon on their behalf.
Choosing that horizon is the deployment’s, and it is a legal question: EHDS Art. 9(2) makes the access information “available for at least three years from each date of access to the data”, and national law can ask for longer. NEN 7513 is the Dutch reference for this log and the Wabvpz for how long it must survive. The setting is per node, and one node serves one organisation, so two organisations needing different horizons run two instances.
A floor is enforced where a jurisdiction sets one. The jurisdictions a
deployment answers to are the ones its [privacy.identifier_scan] rules name,
and where one publishes a minimum retention for the access log the server
refuses to boot with a shorter horizon, naming the configured value and the
floor. 0 always passes. The floors are written in calendar years, as the law
writes them: a horizon set as [audit.store] retention is compared
against the years exactly, and one set as retention against the most
days those years can span (the day count in brackets below). The floors
registered:
| Jurisdiction | Floor | Source |
|---|---|---|
| Every EU Member State (AT, BE, BG, CY, CZ, DE, DK, EE, ES, FI, FR, GR, HR, HU, IE, IT, LT, LU, LV, MT, NL, PL, PT, RO, SE, SI, SK) | three years from each date of access (1096 days, the most three calendar years can span) | Regulation (EU) 2025/327 (EHDS) Art. 9(2); a longer national floor wins. Iceland, Liechtenstein and Norway are not listed: EHDS reaches the EEA only through an EEA Joint Committee decision |
| NL | five years from the moment the entry is written (1830 days, the most five calendar years can span) | Besluit vaststelling bewaartermijn logging (Stcrt. 2019, 38007), under Art. 5 of the Besluit elektronische gegevensverwerking door zorgaanbieders, which binds the period to NEN 7513 |
| CH | one year, and kept apart from the processing system (366 days, the most one calendar year can span) | Datenschutzverordnung (DSV) Art. 4 Abs. 5, as amended on 1 December 2025, for the logs of a large-scale automated processing of sensitive personal data; the separate storage is the deployment’s, through the forwarding sinks |
For the Netherlands the five national years win over the three EHDS years;
Switzerland is outside the Union and keeps its one year. Of the other shipped
jurisdictions, DE, FI and SE carry the EHDS floor, while GB and NO have no
floor registered: an unknown requirement is never guessed at, and a deployment
there sets its own. Art. 9 applies from 26 March 2029 for patient summaries,
prescriptions and dispensations and from 26 March 2031 for the other priority
categories (Art. 105). The floor is enforced from this release on, so a log
kept today already meets it when Art. 9 applies.
The effective retention is on the boot line beside the audit-enabled facts and
on GET /management/info under audit.
A record takes about 1.2 KB on disk, so the horizon decides how far the log
grows (Storage sizing).
Getting the log out
Three routes, and they answer different questions.
- The access log over ITS-REST: the access-log resources serve the openEHR access-log entries: one EHR’s log to the person it is about and their representative, and the full log to a reviewer. This is the person’s own route (EHDS Art. 9(2)).
- ITI-81 retrieval: the audit search
serves the records back as FHIR
AuditEventresources, filtered by patient, agent, date and outcome. This is the operator’s route and the one an IHE Audit Consumer uses: everything Annex II 3.2 records is reachable through it, including the purpose and the organisation, which the syslog feed’s DICOM form cannot carry. - The BALP feed: records fan out to syslog and to a FHIR feed as they are written, for a SIEM or a central Audit Record Repository.
Reading the access log over ITS-REST
The openEHR access-log entries are served under the extensions root,
/ferroehr/rest/extensions/v1. No openEHR ITS-REST release defines these
resources: they are part of FerroEHR’s access-log proposal to openEHR, and they
follow the ITS-REST 1.1.0 conventions, offset and fetch paging as the Query
API’s and ISO 8601 date-times.
| Method and path | Who | What |
|---|---|---|
GET /ehr/{ehr_id}/access_log | the subject of care, their representative, a reviewer | The entries of one EHR, newest first. Filters: from, to, action, outcome, accessor_kind, emergency, include_self; offset, fetch (1 to 1000, default 100). |
GET /ehr/{ehr_id}/access_log/{uid} | as above | One entry. |
GET /admin/access-log | a reviewer | Records across EHRs, entries and tombstones. Filters: ehr_id, party_namespace, party_type, party_id, issuer, subject, request_id, from, to, outcome, emergency; offset, fetch. |
GET /admin/access-log/chain | a reviewer | The uid and link of each record from from_sequence to to_sequence (at most 10000), without content, for verification. |
GET /admin/access-log/checkpoint | a reviewer | The newest stored checkpoint, or the one at sequence. |
A list answers offset, fetch and entries, and no total count, since a
count over a large log costs a scan. A parameter a resource does not take, or a
value outside its form, is a 400.
The caller’s authorisation selects the view, and no parameter widens it.
- The subject view goes to the person the EHR is about and to their
representative, bound through the party binding: a patient-portal token
reads the EHR of its launch context, and a representative, through a
personsissuer or as the actor of the patient’s token, reads the EHR of the subject the representation names (Operational policy). It shows who accessed (the provider and the party), when, the action and outcome, the items and their categories, the purposes and the emergency mark, and leaves out the credential, the delegation chain, the binding outcome, the channel, the query text and its digest, the security labels,other_detailsand the link, and the accessor members a restriction withholds. An entry about a composition held from the person under EHDS Art. 3(3) is left out until the hold ends, as in the subject-scoped ITI-81 read. Any other EHR answers404, the same as an unknown one, so its existence is not disclosed. - The full view, each record in its ITS-JSON form with its link, goes to
a reviewer: a caller the admin class admits (
admin_roleunder RBAC), the same callerGET /admin/access-logadmits. - Every other caller is refused with
403. The log has its own access control: a clinical grant such aspatient/composition-*.roruser/composition-*.rreaches none of it.
The person’s own reads of their log are recorded like every other read and
are left out of their default view; include_self=true adds them. Every read
of these resources, refused and failed ones included, writes an access-log
entry whose item names the log it read (ACCESS_LOG_RECORD for an entry,
ACCESS_LOG for an EHR’s whole log), with the filter named by its digest. A
tombstone keeps no EHR, so a removed entry is read through the review.
Restricting the subject view (EHDS Art. 9(3))
EHDS Art. 9(3) lets a Member State restrict the person’s right to see who
accessed their data “in exceptional circumstances”. If your law does, declare
the restriction in the controller’s
access policy, never in ferroehr.toml: each entry
of log_restrictions names the accessor kinds it applies to (the accessor kind rubrics of the log, such as person or external person), the
accessor members the subject view withholds (accessor_party,
accessor_provider, accessor_roles, accessor_groups, in
ferroehr-operations), and the provisions that lay it down, coded in your
jurisdiction’s terminology. FerroEHR ships no country’s restriction.
"log_restrictions": [{
"_type": "ACCESS_LOG_RESTRICTION",
"name": { "_type": "DV_TEXT", "value": "External accessor withheld" },
"archetype_node_id": "id11",
"accessor_kinds": [{ "_type": "DV_CODED_TEXT", "value": "external person",
"defining_code": { "_type": "CODE_PHRASE",
"terminology_id": { "_type": "TERMINOLOGY_ID", "value": "openehr" },
"code_string": "external person" } }],
"withheld": [{ "_type": "DV_CODED_TEXT", "value": "accessor_party",
"defining_code": { "_type": "CODE_PHRASE",
"terminology_id": { "_type": "TERMINOLOGY_ID", "value": "ferroehr-operations" },
"code_string": "accessor_party" } }],
"legal_grounds": [{ "_type": "DV_CODED_TEXT", "value": "your national provision",
"defining_code": { "_type": "CODE_PHRASE",
"terminology_id": { "_type": "TERMINOLOGY_ID", "value": "urn:example:national-law" },
"code_string": "art-x" } }]
}]
- The subject and their representative get the subject view of an entry whose accessor is of a named kind without the withheld members. A reviewer reads the full entry, and the stored entry never changes.
- A policy write applies on the next request on every replica, with no restart.
- A write that changes the restrictions changes what the log means, so it
writes an access-log entry of its own (operation
admin_access_policy_write), and the policy history keeps every version. Under[audit] fail_mode = "closed", such a write is refused with503while the audit trail cannot take the entry.
# Who accessed my record this month? (the patient portal's token)
curl -H "Authorization: Bearer $PATIENT_TOKEN" \
"https://cdr.example.org/ferroehr/rest/extensions/v1/ehr/$EHR_ID/access_log?from=2026-11-01T00:00:00Z"
The same entries are queryable with AQL as the top-level class
ACCESS_LOG_ENTRY, under the same rules of who reads which view, and each such
query writes its own entry (Querying the access log).
Sinks
Records fan out to independently configured sinks ([audit] in
ferroehr.toml; see the
configuration reference):
| Sink | Default | What it does |
|---|---|---|
[audit.store] | on | The local Audit Record Repository: records persist in the dedicated audit PostgreSQL schema (append-only and tamper-evident, strictly outside the EHR content), served back via the ITI-81 search below. retention prunes old records hourly (0 = keep forever). |
[audit.syslog] | off | The classic ATNA feed: DICOM PS3.15 XML as RFC 5424 syslog over RFC 5425 TLS to an external ARR, per IHE ITI-20. |
[audit.fhir_feed] | off | The RESTful-ATNA feed (ITI-20 ATX: FHIR Feed): each FHIR AuditEvent is POSTed to an external FHIR ARR. With the local store on, delivery is outbox-driven: an ARR outage loses nothing, pending records ship on recovery. The outbox holds the records written while the feed is configured; with the feed off, no record is owed. Records stored before FerroEHR kept an outbox and never delivered ship once a feed runs. |
Emission never blocks the request path: a record is handed to a bounded queue
(queue_capacity) and written by a background drain.
While a composition is held from the person
With the access-delay register on, a new composition can be held from the person under EHDS Art. 3(3) until a professional releases it or its period passes. Only one route honours the hold: the subject-scoped ITI-81 read, the one a patient portal serves the person’s own trail from, leaves out every record that names a held composition. Every other sink and stream is a feed to the controller’s own systems and carries those records and events while the hold is in force:
| Sink or stream | What it carries during a hold | Why it is not filtered |
|---|---|---|
[audit.store], read without the patient scope | every record, the hold’s own included | The unscoped ITI-81 read is the controller’s, under the admin role |
[audit.syslog] | every record, sent as it is written: the commit, each read and the hold’s own record name the composition, the last as access-delay:<vo> beside the patient | An ITI-20 feed goes to an Audit Record Repository, which “receives event audit reports and stores them” (IHE ITI TF-1 §9.1.1.3) |
[audit.fhir_feed] | the same records as FHIR AuditEvent resources, POSTed as they are written, the hold’s own record naming the same access-delay:<vo> | The same ITI-20 repository, over ATX: FHIR Feed; the reader of a BALP AuditEvent is an Audit Consumer (BALP §1:52.1) |
Change events ([record.change_feed]) | the commit of the held composition: its vo_id, kind, change type and template | The feed serves the deployment’s own readers; it withholds what binds them, a restriction or objection (GDPR Art. 18 and 21, EHDS Art. 8), and the Art. 3(3) hold binds only the person’s access |
EHDS Art. 9(2) gives the person the access information “through electronic health data access services”, which are yours to run. A repository, a feed reader or anything built on them never reaches the person from FerroEHR, so none of them filters the hold: a filter there would also hide the record from the controller who answers for it. What you must not do, while a hold is in force:
- Serve the person’s trail from the external Audit Record Repository the syslog or FHIR feed writes to, for example through that repository’s own ITI-81 query. Serve it from FerroEHR’s subject-scoped read instead.
- Send the person a notification, under Art. 9(1) or otherwise, from a record on either feed or from a change event that names a held composition. Ask the hold first: a request in the person’s context reads the composition as absent (404) until the hold ends.
The shared-responsibility page puts the same duty on the deployment’s side.
The local store is the durability anchor. Under fail_mode = "closed", an
operation whose audit record cannot be recorded answers
503 Service Unavailable: the deployment demanded an audit trail it cannot
currently deliver, so no un-audited PHI access happens, and the same holds for
the domain-level records the subject resolutions and the EHR-Extract
transfers write. open, the default, drops-and-meters instead,
and every loss path is metered (the atna_audit_* counters in
Operations); the server announces that default at boot and on
the readiness indicator as a stated caution, because a metered loss is still a
loss. Login and rejection records never gate a response in either mode.
Tamper evidence
An audit trail that anything with the application’s database password can quietly rewrite is a log, not an accountability record. The local store is therefore tamper-evident: every record is linked into a SHA-256 hash chain maintained inside PostgreSQL, so each record commits to its predecessor and to its own content. The chain is built by the database itself, not by the server, which means it covers every writer: the per-event insert, the batched drain, and any statement typed by hand.
Each record’s digest covers every column of the record except the digest
itself (row_hash) and the two per-sink forwarding stamps
(delivered_syslog_at, delivered_fhir_feed_at). A column added by a later
release joins the digest in the same release.
The store keeps a record’s facts in columns and renders its FHIR AuditEvent
from them when the record is read (ITI-81) or delivered (the FHIR feed). What
the rendering takes from the configuration (source_id, enterprise_site_id,
server_host, value_if_missing, the store horizon, the audit category register and
emergency_purpose_codes) is kept once per distinct configuration in
audit.audit_render_policy, keyed by the SHA-256 of its text, and every record
names the policy it was written under. A record therefore renders the same
document after the configuration changes, and the verification below reports a
policy whose text no longer matches its digest, as it reports a changed record.
Release 5.6.0 starts on an empty audit store: its migration refuses a store
that holds records written by an earlier release, and names the remedy.
Four controls sit on top of it, and they are separate on purpose:
-
The table refuses the ordinary rewrite paths outright. The only permitted change to a stored record is the per-sink forwarding stamp; an
UPDATEof any other column, aDELETE, and aTRUNCATEare refused by the database. Retention pruning goes through the one sanctioned deletion path, which records which records it removed and what the surviving chain must link back to, so reaping does not look like tampering, and tampering does not look like reaping. -
The privileges are narrow. The runtime role may record an event, stamp it forwarded, and read the trail back. It holds nothing that can rewrite a record, remove one, or alter the chain’s own bookkeeping. That posture is only fully in force with
database.migrations = "verify"; see Operations, because a self-migrating server owns the schema and can therefore turn the enforcement off. -
Verification is a query you can run yourself. It recomputes every digest, re-walks every link, and checks both ends of the chain:
SELECT * FROM audit.verify_audit_chain();An empty result means the trail is intact. Any row names one record (its chain position, its id, when it was recorded) and what is wrong with it: content modified after it was written, a render policy changed or missing, records deleted with no retention record for the removal, or records removed from the end of the chain where no successor would have noticed.
-
The server runs the check itself, on a schedule. With the local store on, the check runs one minute after boot and then every
[audit.store] verify_interval(default3600, one hour;0turns it off). Each run verifies the records written since the newest link an earlier run found intact, and the chain head, so its cost follows the records written since rather than the size of the trail (audit.verify_audit_chain_incremental()). A full pass runs every[audit.store] full_verify_interval(default604800, one week;0leaves it to the query above) and after every run that found damage, so damage to an older record stays reported. A run that finds damage logs atERROR, one summary line with the finding count and one line per finding (the first 20), and adds the count to theatna_audit_chain_findingscounter withkind = "damage". A run that cannot verify at all counts askind = "unverifiable", because a trail that cannot be checked is never a pass. The latest result is theaudit_chainindicator onGET /health/readiness:UPwhile intact andDEGRADEDwhen damaged or unverifiable; its detail onGET /management/healthnames the first finding. It never flips readiness, because the trail keeps recording while the damage is investigated. Alert on the counter or on that component, and use the query above to see every finding. Each replica runs its own check.
Important
This is detection, not prevention, and the boundary is worth stating plainly. The chain is unkeyed, so a party with unrestricted write access to the
auditschema (the database owner, or a superuser) can delete a record and recompute every hash after it. What closes that case is keeping the trail somewhere that party does not control. Enable[audit.syslog]or[audit.fhir_feed]so records leave the box as they are written, and give the server an app-role-only DSN so it is not that party.
Checkpoints and the transfer of a log
The records of the openEHR access log (audit.access_log_record) are chained
with the audit_event records above. A chain proves order and completeness
against someone who cannot rewrite its whole tail. A checkpoint closes
that case: an ACCESS_LOG_CHECKPOINT names the position and digest of the
head of the chain and is signed with the deployment’s OpenPGP key, in the
form an openEHR ATTESTATION carries its proof (RM common, Generic Package
§Attestation). A verifier that holds a checkpoint detects any later rewrite
of the records it covers. No openEHR specification governs log signing; this
is our own design.
- The key is the keyring of version signing:
[record.signing]inpgpmode, with itsretired_key_filesstill verifying what an earlier key signed. With that key every link is signed and the log is sealed; a deployment without it signs nothing, andferroehr access-log checkpointanswers that the keyring holds no key. - Use an Ed25519 key. Each access writes one entry per EHR it reached, and each entry’s link is signed in the audit writer’s transaction while the head of the chain is locked. RSA signing is far slower than Ed25519, and every other audit write waits on it.
- The schedule. The server seals the head every five minutes when the
chain grew since the last checkpoint; a run on a log that did not grow
writes nothing. There is no switch and no interval to set.
ferroehr access-log checkpointandPOST /admin/access-log/checkpointseal one on demand. Keep a copy of a checkpoint somewhere the database owner does not control (a ticket, a timestamping service, the data protection officer’s mailbox): that copy is what makes a rewrite of the whole tail detectable. - Verification.
ferroehr access-log verifyandPOST /admin/access-log/verifyrecompute the whole chain (an entry replaced by its tombstone verifies through the content digest the tombstone keeps), check the checkpoint’s signature and that the link at its position is the one it sealed, and check the signature of every signed link. Each finding is reported; the command exits 1 when the log does not verify, and the route answers200withintact: false. - Signed links. Each link’s digest is signed as the eHDSI Audit Trail
Profile §2.2 asks of a national contact point. The server locks the head
of the chain, computes the links the new records will get, signs them and
writes each signature with its record in one
INSERT; a stored signature never changes. - Moving the log with the EHR. EHDS Annex II 2.6 and Art 9(2) keep the
access information available when an EHR moves to another system.
ferroehr access-log export --ehr-id <id>andGET /admin/access-log/export?ehr_id=write the EHR’s records with their links, every link from the first of them to the checkpoint they verify against, and that checkpoint, sealing one when none covers them. The receiving system runsferroehr access-log import --input <file>: it verifies the export against its checkpoint and the certificates in[audit.access_log] trusted_key_files, keeps the records with theirsystem_id, links andretain_untilapart from its own chain, and records the import as animportentry of its own log, built like every other entry and naming the system as its accessor. An import repeated stores nothing twice. An access to EHR data is stored as its entry alone, so a span holds anaudit_eventrecord only where an access outside the access log (an authentication, a template or party operation, an application activity) was recorded between the EHR’s entries, or where the span reaches records written before entries were the record. Such an export is refused, since only the database that wrote those records can recompute their links.
Retrieving audit records (ITI-81)
The RESTful-ATNA ITI-81 Retrieve ATNA Audit Event transaction is a FHIR
search on AuditEvent, so it is served at FerroEHR’s FHIR R4 base,
/ferroehr/rest/fhir/r4, beside the openEHR API rather than under it, where a
FHIR client or an IHE Audit Consumer expects [base]/AuditEvent. It is the one
FHIR route FerroEHR serves:
GET /ferroehr/rest/fhir/r4/AuditEvent
It returns a FHIR searchset Bundle of the matching records’ AuditEvent
documents, rendered from the store, newest first, with the full match total, a self link and a next link
while more pages follow. The query is read by ihe-atna, the family’s audit
crate. At least one date parameter is required (RESTful ATNA
§3.81.4.1.2.1): a query without one is a 400. Every search parameter
§3.81.4.1.2.2 says the repository shall support is applied. A parameter
with several comma-separated values matches any of them, and every
parameter of the query must match. A token takes the three forms of FHIR R4
Search §3.1.1.4.10: code, |code (recorded without a system) and
system|code (or system| for any code of that system). FerroEHR records
identifiers without a system, except the object of an access record, whose
system is urn:openehr:object-id: entity.identifier=urn:openehr:object-id|<uid>
and entity.identifier=<uid> find it, and a query that names another system
for an identifier matches nothing. Every parameter answers through an index. A
parameter on an element of the document (address and the .identifier,
entity-type, entity-role, type and subtype parameters) matches the
search tokens the store takes from the record’s rendered document when it
writes the record (audit.audit_search_token, audit.audit_search_set and
the record’s search_tokens, for an entry its row in
audit.access_log_search, which goes with the entry’s content when a
tombstone replaces it), so the search finds what the served document
says and renders only the page it serves. An entity.identifier that carries
the record’s request id or the object it names (the version uid of a create)
is read from the record’s own column instead, so a request adds no row to
audit.audit_search_token. Retention deletes the tokens that no remaining
record names, and never one a kept record names.
| Parameter | Matches |
|---|---|
date | required, repeatable: a FHIR date value with a prefix (eq when none, gt, lt, ge, le, sa, eb); a day such as 2026-07-12 covers the whole day, read in UTC |
patient | the recorded patient (EHR subject) id |
patient.identifier | entity.what.identifier of the entity whose role is Patient |
agent | the authenticated principal |
agent.identifier | agent.who.identifier |
entity | the touched resource id |
entity.identifier | entity.what.identifier of any entity |
entity-type | entity.type |
entity-role | entity.role |
source.identifier | source.observer.identifier, the audit source id |
type | type |
subtype | subtype (the REST interaction and the openEHR operation) |
address | a part of agent.network.address, compared without regard to case |
outcome | the outcome indicator: 0, 4, 8 or 12 (FerroEHR records 0, 4 and 8) |
action | the action code: C, R, U, D or E |
_count / _offset | paging; page size defaults to 50, capped at 1000; _count=0 returns the total alone |
A malformed value is a 400 carrying a FHIR OperationOutcome with
invalid; another FHIR R4 AuditEvent parameter, which §3.81.4.1.2.2 does
not ask for, is a 400 with not-supported; a parameter the crate does not
know is ignored
(§3.81.4.1.3). Under RBAC the
unscoped retrieval is admin-only; a caller holding a
read_subject_audit grant, a patient portal acting for the people it
serves, reads it scoped to one subject: one
patient or patient.identifier with one value is required, and the caller
is refused with a 403 that names the parameter when it omits
it. Reading a subject’s log is itself recorded as an access naming that
subject and the record count served. An
emergency access in the subject’s log
carries its mark as the ehds-emergency-access entity. The surface answers 404 when the local
store is disabled.
The subject-scoped ITI-81 read stays beside the access-log
resources. It serves the ATNA records
as FHIR AuditEvents to a portal that holds a read_subject_audit grant and
names the subject itself; GET /ehr/{ehr_id}/access_log serves the openEHR
access-log entries of the same accesses to the person, or their
representative, under the person’s own credential.
# Who accessed patient-42's data this month?
curl -u admin:pw \
"https://cdr.example.org/ferroehr/rest/fhir/r4/AuditEvent?patient=patient-42&date=ge2026-07-01T00:00:00Z"
This is also the openEHR “record demerging” instrument: when data lands in the wrong EHR, the patient-filtered audit search shows exactly who read it.
Note
Audit records are themselves sensitive (they name patients, subjects and actions) so this endpoint is a PHI-disclosure surface and is authorized like any other.
Node authentication (ITI-19, mutual TLS)
ATNA’s second half is node authentication. [server.tls] terminates TLS
natively and can demand a verified client certificate:
[server.tls]
certificate_file = "/etc/ferroehr/server.pem"
key_file = "/etc/ferroehr/server.key"
min_version = "1.3" # 1.3 (default) | 1.2
client_auth = "required" # none | optional | required
client_ca_file = "/etc/ferroehr/client-ca.pem"
The protocol floor is TLS 1.3 only by default, as RFC 9325 §3.1.1 has it
supported. Setting min_version = "1.2" enables
1.2 alongside 1.3, never instead of it, for a client that genuinely cannot
do 1.3, such as an older integration engine or a pinned Java runtime. TLS 1.1
and 1.0 are refused when the configuration is read (RFC 8996).
With client_auth = "required", only clients presenting a certificate
chaining to your explicit trust anchor complete the handshake: the IHE
mutually-authenticated-node posture. Deployments terminating TLS at an
ingress leave [server.tls] unset and enforce mTLS there instead.
Warning
The separate-port management listener (
management.listen) stays plain HTTP even with[server.tls]set, and it binds all interfaces. Treat it as an internal surface and keep it off any publicly routed port. Underdeployment.profile = "production"setting it opens theplaintext_listenergap, so the server refuses to start unless the gap is accepted by name.
Complete the posture with time synchronisation (IHE Consistent Time): run NTP/chrony on every node so audit timestamps align across systems.
Against independent ATNA implementations
The transactions above are tested by FerroEHR’s own suites, which read the
profiles the way FerroEHR’s authors read them. EHDS Annex II 1.4 asks that a
component meant to work with other products does so reliably, so
scripts/interop/atna.sh
runs the quickstart against software FerroEHR’s authors did not write, each
from a published image:
| Transaction | Independent implementation | What the run requires |
|---|---|---|
| ITI-20 FHIR feed | HAPI FHIR, an open-source FHIR R4 server, as the Audit Record Repository, with IHE BALP 1.1.4 loaded | It accepts every record, and its validator finds no error against base R4 and the BALP profile each record names |
| ITI-20 syslog | syslog-ng over RFC 5425 TLS | Every message parses as RFC 5424, and its payload is a well-formed DICOM PS3.15 A.5.1 AuditMessage (libxml2) |
| ITI-81 | HAPI FHIR’s AuditEvent search over the records the feed delivered | The same searches answer the same records on both |
cargo build --release -p loadtest
bash scripts/interop/atna.sh ghcr.io/ferrohealth/ferroehr:<tag> \
ghcr.io/ferrohealth/ferroehr-postgres:<tag> atna-out
It prints every disagreement and exits non-zero on any. A disagreement is either FerroEHR’s or a shared crate’s defect, filed and fixed, or the other side’s, recorded with the profile text that shows it.
The run of 2026-10-29 found no disagreement: HAPI FHIR accepted and validated all 71 records of the window, syslog-ng parsed all 72 messages, and the ten ITI-81 searches answered the same records on both repositories (the record).
Configuration summary
Auditing defaults to on with the local store only; see the
configuration reference for every
[audit] key and its FERROEHR__AUDIT__* environment form. The syslog sink’s
own keys are host and port under [audit.syslog], with its TLS material
under [audit.syslog.tls]; the
switches shared by every sink stay directly under [audit].
Note
There are no alternative spellings for any of these: an unrecognized
FERROEHR_*variable or an unknown TOML key is a boot error naming the spelling it should have had, never a silently ignored setting. Validate a deployment’s configuration up front withferroehr config check.