The access policy and the admin registers
The controller’s ACCESS_POLICY and the two admin registers hold the policy that has no
home in the demographic model. How they take part in a decision is on
How FerroEHR decides access.
The admin registers
Two kinds of operational policy have no home in the openEHR demographic model, so each is an admin register:
| Register | What it holds | Default, before anyone writes it |
|---|---|---|
audit-categories | The EHDS category map every access is classified through (the audit category register) | The category map FerroEHR ships |
access-delay | The EHDS Art. 3(3) delay of the person’s own access (the access-delay register) | Off |
You read and write them under {ext}/admin/registers/{register} with a token
or Basic user holding admin_role, with [api] admin = true; the routes are
on Admin & messaging APIs.
- Versioned. Every write appends a version that names its committer and when it was committed, and never overwrites one; the history route lists them all. Version 0 is the default no one committed.
- Whole, over a version. A write replaces the whole document and names the
version it replaces in
If-Match. A write over a version that is no longer the newest is refused with412, so two operators never overwrite each other’s change unseen. - Checked when written. A document that does not hold is refused whole with
400and never reaches a request: a category map that does not compile or a delay with an unusable limit. The register keeps its version in force. - Effective without a restart. Each replica keeps the registers in
memory and is told of every write through PostgreSQL
LISTEN/NOTIFYwhen the write commits; its next request after that reads the new version. The replica that took the write applies it to its own next request. While a replica’s listener is not connected, that replica reads the registers on every request, so it never serves an outdated policy. A database that cannot answer that read fails the request with503; it is never served under a guess. - Audited. Every read and write of a register is an access record.
A deployment provides its registers once the server runs, through the admin
API; neither has a key in ferroehr.toml.
A worked example: turning the access delay on
Read the register, then write the new document over the version it answered:
curl -s -u admin:… https://cdr.example/ferroehr/rest/extensions/v1/admin/registers/access-delay
# ETag: "0"
# {"register":"access-delay","version":0,"committer":null,"committed_at":null,
# "document":{"enabled":false,"categories":[],"max_delay":null}}
curl -s -u admin:… -X PUT \
-H 'Content-Type: application/json' -H 'If-Match: "0"' \
-d '{"enabled": true, "categories": ["Laboratory-Reports"], "max_delay": "72h"}' \
https://cdr.example/ferroehr/rest/extensions/v1/admin/registers/access-delay
# ETag: "1"
The next laboratory report committed on any replica is held from the person for up to 72 hours.
The security floor that stays in ferroehr.toml
A floor that must hold before a register can be read stays configuration. With
deployment.profile = "production" and auditing on, the audit category
register refuses a map that classifies nothing (no template, no archetype and
shipped_map = false) as the no_category_map gap, unless
deployment.accepts names it.
The access policy
The controller’s access policy states what holds for every EHR this FerroEHR
keeps: which kinds of data carry which sensitivity (classifications),
whether a professional’s clinical access needs a care relationship
(care_relationship_required, with a relationship_grace) and a declared
purpose (purpose_required), the controller’s own rules on which callers
may do what with which kinds of data (each an ACCESS_DIRECTIVE of kind
controller_rule, EHDS Art. 11(3)), the catalogue of named directives a
patient can accept by reference, such as an IHE BPPC policy, and the
log_restrictions of the access log’s subject view your Member State’s law
lays down under EHDS Art. 9(3) (Audit).
It is an ACCESS_POLICY of FerroEHR’s draft access control package, written
against the default archetype openEHR-EHR-ACCESS_POLICY.controller.v1,
which every boot stores, or against one of your own. The default floor
([authz.rbac] ehr_access_default) stays in ferroehr.toml, and the policy
can only tighten it. Emergency access is one of the policy’s
justifications. Until you write
one, nothing is tightened.
- Versioned. Every write is a new version in its own contribution, with you as committer; the history route lists them all.
- Whole, over a version. Name the version you replace in
If-Match, or create the first withIf-None-Match: *. A stale condition is412. - Checked when written. A body that is no canonical-JSON
ACCESS_POLICYis refused whole with400. A policy that reads but breaks a rule is refused whole with422, naming the rule or the attribute: an invariant of the draft model, a rule of another kind thancontroller_rule, a catalogue entry of that kind, a rule naming a role, purpose, sensitivity, category or legal ground inopenehr_access, the template itsarchetype_details.template_idnames, or a code outside a value set it binds. - Effective without a restart, as the registers above.
- Read by the access evaluator on every request:
purpose_requiredis step 4, checked before any rule, the rules are step 5, a classification gives the data it covers its sensitivities (step 6), andcare_relationship_requiredis step 7 of the decision procedure. Arelationship_gracethat is no ISO 8601 duration admits nothing after a care relationship ends.
The routes are on
Admin & messaging APIs. A write
needs admin_role and a policy grant of write_access_policy.
Care relationship facts
The policy also states how care relationships are read. Each attribute you leave out reads as its strictest default, so a policy that sets none admits least.
| Attribute | What it says | Left out |
|---|---|---|
self_declared_care | The longest period of a care relationship a professional states for themself | no self-declared relationship |
attested_care | The agreements under which a caller’s verified credential may attest a care relationship | no attested relationship |
caseload | Whether a query may be narrowed to the caller’s caseload | true |
episode_shared | The data every live care relationship covers whatever episode it or the data name, such as the patient summary, each an ACCESS_DATA_SCOPE (Care relationships and episodes of care) | none |
conflict_rules | The conflicts of interest (self, related, with the kinships) allowed through the professional path, and for whom | none: a professional who is the patient, or is related to them, is refused |
concealed_confidentialities | The HL7_Confidentiality levels whose refused records answer as absent | every refused record answers as forbidden |
value_sets | The value set on your terminology server that each coded attribute (care_role, representation_basis, kinship, organisation_type, care_purpose, emergency_purpose) is bound to | the package’s default code system |
relationship_validity | The default and maximum period of a care relationship, by its care_role and the type of its provider | every care relationship is written with an end |
relationship_writers | The writers that may write a care relationship to a record marked R or V | none |
team_targets | The ORGANISATION units a care relationship may name as its target | none: a care team is a GROUP |
FerroEHR ships no value set and no country content. A code of a bound
attribute is checked against its value set on the
terminology server when you write the policy;
with no terminology server configured, a policy that binds a value set the
check needs is refused. An unbound kinship is a code of the openEHR
subject relationship group. An organisation type has no default code
system, so a rule, an exception or a conflict rule that names an
organisation_type is refused 422, naming it, until the policy binds an
organisation_type value set. A template of the default archetype that
fixes some of these attributes for many controllers is a profile: write the
policy with its template_id, and FerroEHR validates it against the
template.
Two more attributes say when a relationship is a ground at all:
| Attribute | What it says | Left out |
|---|---|---|
care_purposes | The purposes of use for which a care relationship is a ground: an access declaring another purpose, such as research, rests on no relationship and matches no rule scope naming care | TREAT, ETREAT and CAREMGT of HL7_ActReason |
time_zone | The IANA time zone in which the dates of a relationship’s time_validity are read, such as Europe/Amsterdam; a name the zone database does not hold is refused 422 | UTC |
The attested care path
A caller from another organisation, admitted under a
federation agreement, can hold a care
relationship that is never stored: its verified credential attests a
treatment context for the patient. This is how a national contact point or a
national infrastructure reaches the record for cross-border care. The path is
off until attested_care names the agreement:
"attested_care": [
{ "_type": "DV_IDENTIFIER",
"issuer": "https://federation.example",
"id": "0190b3a2-5a3e-7c1d-9e2f-3b4c5d6e7f99" }
]
idis the container uid of the agreementROLE(the part of its version uid before::), so a new version of the agreement keeps the reference.issuer, when you set it, must be the federation issuer the partner’s client identifiers are held under. A policy that names another issuer, or names under an issuer an id that is no agreementROLE, is refused422, naming/attested_care/<n>/issuer.
Which claims carry the treatment context is your data, in the issuer’s
[auth.issuer.<name>.federation] table. FerroEHR reads these fields:
| Field | What it carries |
|---|---|
patient.id | The patient, as system|value: the identifier an EHR’s subject names |
trc.id | The id of the assertion that attests the treatment context |
trc.not_on_or_after | The end of its window, in seconds since the epoch |
trc.not_before | The start of its window, when the credential states one |
assertion.issuer | The issuer of the assertion, when the credential states one |
trc.care_role | The care role the treatment relationship attests for the professional, one code with its code system |
A credential that lacks patient.id, trc.id or trc.not_on_or_after
attests nothing. On every access FerroEHR checks that the policy names the
agreement, that the window holds the moment of the access, and that the
record’s subject is the attested patient. The caller then holds a live care
relationship for the care step, the default disposition and any rule whose
actor scope names relationship: care. The relationship is never stored and
never in a caseload. The access log names it as a treatment relationship
ground whose reference is the assertion (id and issuer) and whose
name and version are the agreement’s.
The attested relationship holds the role PART unless the credential
attests a role in trc.care_role of the care_role value set the policy
binds (unbound, a code of HL7_ParticipationType). The code system of the
attested role is the terminology its code is read in, so a credential whose
role carries the system HL7_ParticipationType names a code of that
terminology, and a field mapped as { constant = "ATND", system = "HL7_ParticipationType" } attests that role for every credential of the
issuer. A role outside that value set, or one no terminology server could
check, counts as no role, and the relationship keeps PART.
ferrohealth-smart refuses a token whose trc.care_role is not one code
with its system.
A rule limits attested callers like any other: give its actor scope
relationship: care with care_path: attested. A deny rule’s data keeps
attested callers from the templates or categories it names, and on a record
the controller marks R or V an attested caller is refused
refused-confidentiality until a permit rule for that path names the level
in its data confidentialities:
{ "_type": "ACCESS_DIRECTIVE", "kind": "controller_rule", "effect": "permit",
"applies_to": [ { "_type": "ACCESS_ACTOR_SCOPE",
"relationship": "care", "care_path": "attested" } ],
"data": [ { "_type": "ACCESS_DATA_SCOPE", "confidentialities": [ "R" ] } ] }
The codes are shown short here; write each as a DV_CODED_TEXT. A permit
that names R clears R and nothing above it, and one written for the
direct path clears no attested caller.
Writing a care relationship
FerroEHR checks each care relationship against the policy when it is
written, and refuses one that breaks a bound with 422, naming
/time_validity or /target:
- Validity. A relationship written without an end takes the
default_periodof the firstrelationship_validityentry that covers its role and its provider’s type, counted from its start (or from the day of the write when it names no start). One longer than that entry’smax_periodis refused. One that no entry covers, or whose entry has amax_periodand nodefault_period, must be written with an end. An entry with neither period lets the relationship stay open. - Target. An
ORGANISATIONtarget must be a unitteam_targetsnames, and is never the controller or the relationship’s own provider. - Writers. The level is the highest marking of the subject’s records:
every EHR whose subject reference names the relationship’s source
PERSON, directly or through a record subject thePERSONdeclares. FerroEHR reads those markings exactly before the commit takes its connection. AtNevery writer thewrite_care_relationshipgrant admits writes. AtRorVonly a writer arelationship_writersentry names for that level writes, and its access-log record is flagged for review with the level: thereviewdetail (id40) of the entry’s details, thereviewcolumn ofaudit.access_trail, and areviewdetail on the object of the BALPAuditEventand the DICOM audit message. Every other write is refused403, naming the level and the missing entry. The administrator is no exception: a policy that wants the administrator to write such relationships names the administrator’sPERSON(or a role it performs) for the level. An entry forVdoes not coverR; name each level the writer may write. - Self-declared. A relationship whose
basisisself_declaredis refused422unless the policy setsself_declared_care. Its target is the writer’s ownPERSON(403otherwise), and it ends within that period of its start, by its own end or the onedefault_periodgives it. While the policy setsself_declared_care, it admits the professional who wrote it; once the policy no longer sets it, it admits no one.
For example, this relationship_writers lets the admission system’s role
write relationships to records at R, and the administrator’s PERSON
write them at R and V (the role code and the identifiers are your own):
"relationship_writers": [
{ "_type": "ACCESS_RELATIONSHIP_WRITER",
"applies_to": [{ "_type": "ACCESS_ACTOR_SCOPE",
"role": { "_type": "DV_CODED_TEXT", "value": "admission system",
"defining_code": { "terminology_id": { "value": "urn:example:roles" },
"code_string": "adt" } } }],
"confidentialities": [
{ "_type": "DV_CODED_TEXT", "value": "restricted",
"defining_code": { "terminology_id": { "value": "HL7_Confidentiality" },
"code_string": "R" } }] },
{ "_type": "ACCESS_RELATIONSHIP_WRITER",
"applies_to": [{ "_type": "ACCESS_ACTOR_SCOPE",
"party": { "_type": "PARTY_REF", "namespace": "demographic", "type": "PERSON",
"id": { "_type": "HIER_OBJECT_ID", "value": "<the administrator's PERSON>" } } }],
"confidentialities": [
{ "_type": "DV_CODED_TEXT", "value": "restricted",
"defining_code": { "terminology_id": { "value": "HL7_Confidentiality" },
"code_string": "R" } },
{ "_type": "DV_CODED_TEXT", "value": "very restricted",
"defining_code": { "terminology_id": { "value": "HL7_Confidentiality" },
"code_string": "V" } }] }
]
The end a relationship takes from default_period is never written into the
relationship: the version you committed stays exactly as you sent it, with
its digest and signature. FerroEHR computes the end once, in the commit’s
transaction, from the policy version the write read, and keeps it beside the
relationship with the uid of that policy version. Every access decision and
query reads that end. A later policy version does not move it: a changed
period applies to the relationships written after the change. To change the
end of a relationship, write a new version of it.
Each write reads the newest policy version from the store before it takes its connection to the demographic store, because the policy lives in the clinical store. A policy version committed between that read and the commit applies from the next write; the kept end names the version it came from.
An archive load (load_ehrs) carries no kept ends, so it checks each care
relationship it loads against the policy in force on the server it loads
into, counting a missing start from the day the loaded version was
committed. A relationship the policy refuses is reported in the load’s
failure report and is not loaded; the rest of the archive loads. Put the
access policy in place before you load an archive that holds open care
relationships.
Exclusions and conflicts of interest
An exclusion keeps a named person out of one record. It is a deny of
kind exclusion in the exclusions of the EHR’s EHR_ACCESS settings,
naming the parties it keeps out by applies_to (a party, or the
representative relationship), with an optional data scope, validity and
legal grounds. It is decided before step 1: it binds a professional, a
representative and a gate-keeper, never the person, and no permit of the
person or a representative lifts it. A declared emergency lifts it only
where its emergency_override holds and the caller is no representative.
The caller is answered 403 refused-excluded, and the answer names neither
the exclusion nor its reason; the access log names the exclusion and the
EHR_ACCESS version. A law that lets a provider decline to treat a person
as a representative, for example in a case of abuse, is carried by one.
Only the controller (a caller holding admin_role) reads and writes the
exclusions. Every read of an EHR_ACCESS by anyone else, the person and a
gate-keeper included, leaves them out; a version envelope, a contribution
or an AQL row that would carry them reads as absent to such a caller, and
an EHR Extract for the person carries no EHR_ACCESS that ever held one. A
version a gate-keeper or the person commits carries the current exclusions
forward unchanged, and one that names other exclusions is refused 403.
A restriction binds a representative it names. A restriction the
person gives binds a representative whose applies_to names it by party or
by the representative relationship, answered as absent, as it is for a
professional. A controller rule over a label that names representatives
refuses them at step 5.
A conflict of interest refuses the professional path. A professional is
in conflict with the person when it performs a professional ROLE and is
bound to the person’s PERSON (a staff member on their own record), or
when a related_to relationship in force joins its PERSON to the
person’s. It is refused 403 refused-conflict at step 5, in a read and in a
query, unless an entry of the policy’s conflict_rules for that conflict
names it (and, for related, the kinship); an access such an entry admits
is marked in the access log with a conflict allowance ground. A staff
member reads their own record. Kinship refuses
and never grants: a relative passes the other steps as anyone else.
A kinship is a PARTY_RELATIONSHIP of its own named related_to, written at
/demographic/party_relationship under the write_care_relationship grant
or by an administrator, whose source and target are two PERSONs and whose
kinship element is a code of the value set bound for kinship (by default
the openEHR subject relationship group). Your demographic service or
master patient index decides who is kin; FerroEHR stores the fact and
decides on it. A query leaves out the EHRs of every person the caller is in
conflict with; a conflict rule that names the care relationship admits a
conflict in a direct read of a record the caller cares for, and in a query
reads as not admitting it.
Controller rules
Regulation (EU) 2025/327 Art. 11(3) asks each Member State to lay down
which categories of health data different categories of health
professionals may reach. The access policy’s rules hold those rules for
every EHR you keep. Each rule is an ACCESS_DIRECTIVE of kind
controller_rule, with the applies_to, operations, purposes, data,
time_validity, emergency_override, exceptions and legal_grounds a
directive has. The ROLE parties say who holds a role; the rules say what
the role may do.
- A deny rule refuses what it covers with
403 refused-policy-denied, whatever the patient’s directives permit (step 5). It binds every caller but the patient on their own record, representatives included. - A permit rule clears the callers it names for the sensitivities its
datanames (step 6) and decides nothing else. - A rule’s
purposesmatch only a declared purpose. A request that declares none is outside every rule that names purposes. Setpurpose_requiredto refuse such a request: it is refusedrefused-purpose-missingbefore any rule is read, whatever rules you hold. - A deny rule with a permit exception says “only”: the exception carves what it covers out of the deny.
- A scope naming
carecan name care roles and a path. Withrelationshipcare, an actor scope’scare_roleslists the roles a caller’s live care relationship must have, compared by terminology and code, andcare_pathsays how it must reach the caller:direct,team,self_declaredorattested. Left out, any role and the paths the policy turns on. No role implies another:RESPdoes not coverATND. The same scope decides a read and narrows a query inside its one statement, so aCOUNTagrees with the reads. - For a write, the data are the version being committed: its template, root archetype, origins and the sensitivities your classifications give it.
Four rules, as you write them in the policy body (a role code of
urn:example:roles stands for your jurisdiction’s role terminology):
"rules": [
{ "_type": "ACCESS_DIRECTIVE", "name": { "_type": "DV_TEXT", "value": "Nurses do not record diagnoses" },
"archetype_node_id": "id15",
"kind": { "_type": "DV_CODED_TEXT", "value": "controller_rule", "defining_code": { "_type": "CODE_PHRASE", "terminology_id": { "_type": "TERMINOLOGY_ID", "value": "openehr_access" }, "code_string": "controller_rule" } },
"effect": { "_type": "DV_CODED_TEXT", "value": "deny", "defining_code": { "_type": "CODE_PHRASE", "terminology_id": { "_type": "TERMINOLOGY_ID", "value": "HL7_ConsentProvisionType" }, "code_string": "deny" } },
"applies_to": [{ "_type": "ACCESS_ACTOR_SCOPE", "role": { "_type": "DV_CODED_TEXT", "value": "Nurse", "defining_code": { "_type": "CODE_PHRASE", "terminology_id": { "_type": "TERMINOLOGY_ID", "value": "urn:example:roles" }, "code_string": "NURSE" } } }],
"operations": [{ "_type": "DV_CODED_TEXT", "value": "write", "defining_code": { "_type": "CODE_PHRASE", "terminology_id": { "_type": "TERMINOLOGY_ID", "value": "openehr_access" }, "code_string": "write" } }],
"data": [{ "_type": "ACCESS_DATA_SCOPE", "templates": ["Diagnosis"] }],
"emergency_override": false }
]
- A nurse may not record a diagnosis: the rule above.
- Only psychiatry reads mental-health notes: classify the mental-health
templates
PSY(HL7 v3ActCode), and write apermitrule whoseapplies_tonames the psychiatrist role and whosedatanames the sensitivityPSY. A patient’s consent permit naming their GP clears the GP in the same step; everyone else is refusedrefused-sensitivity. - Professionals may declare only treatment or emergency treatment: a
denyrule whoseapplies_tonames the caller kindprofessional, with onepermitexception whosepurposesareTREATandETREAT. A request declaring another purpose is refusedrefused-policy-denied. A request declaring none is refusedrefused-purpose-missingwhere the policy setspurpose_required, and otherwiserefused-policy-denied, since the exception names no request without a purpose. - Only the responsible practitioner, directly, signs the discharge
summary: a
denyrule onwritewhosedatanames the discharge summary template, with onepermitexception whoseapplies_toisrelationshipcare,care_roles[RESP]andcare_pathdirect. A second in chain (SPRF), a consultant (CON) and a team member are refusedrefused-policy-denied; a professional covering for the responsible one holds aRESPrelationship of their own for the period and is admitted. - A system client writes only its laboratory templates: a
denyrule onwritewhoseapplies_tonames the client’sAGENTbyparty, with onepermitexception whosedatalists the templates. - Only care providers reach records through the exchange: a
denyrule whoseapplies_tonames the caller kindaccess_service, with onepermitexception whoseapplies_tolists oneorganisation_typeper care provider type, and the provision in itslegal_grounds. A partner’s professional whose token attests an insurer’s facility type, or none, is refusedrefused-policy-denied. A seconddenyrule naming arole, such as an occupational physician, orpurposes, such as a medical examination, keeps those out too. A rule namingpurposesrefuses only a request that declares one of them, so setpurpose_requiredto refuse a request that declares none. Wabvpz Art. 15f is a rule of this kind: you commit it, FerroEHR holds no copy of it.
A rule whose emergency_override is true is lifted for a caller that
invokes an emergency
justification
with a reason, and the access record names the rule. The access record of a refusal names the
rule by its uid, its first identifier or its position in rules, and a
legal obligation ground carrying the rule’s legal_grounds. The 403
problem body carries them in its legal_grounds member beside refusal,
each with its terminology, code and value, under
Prefer: return=representation.
A federation agreement and the rules. A federation agreement is the
contract with a partner: its template elements say what the partner’s
persons may send. The rules are your own limits, and they hold for a
partner’s persons too: a deny rule refuses a template the agreement allows,
because a deny overrides.
No openEHR specification has a controller rule: the rules, their place as
step 5 after the purpose check, matching a rule’s purposes only on a
declared purpose, reading a role from the coded name of a ROLE and an organisation
type from the coded name of an ORGANISATION, reading a partner’s attested
roles and facility types as the same facts, and naming a refusing rule’s
legal grounds as a legal obligation ground are FerroEHR’s own design,
proposed in the draft access control specification.