Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Care relationships and episodes of care

The European Health Data Space Regulation gives a health professional access to “the relevant and necessary personal electronic health data of natural persons under their treatment” (Regulation (EU) 2025/327, Art. 11(1)), through a health professional access service, “a service, supported by an EHR system, that enables health professionals to access data of natural persons under their treatment” (Art. 2(2)(i)). The Regulation does not say how a system knows who is under whose treatment. openEHR answers that the care delivery environment knows: the evaluation of “care deliverer” into identities “must be done in each care delivery environment, not in the EHR” (BASE Architecture Overview, Security, The Problem of Roles).

FerroEHR therefore stores the outcome as a fact, the care relationship, and decides every access and every query on it. This page explains the model. The fields, the policy attributes and the refusals are in Caller facts: roles and care relationships and Care relationship facts.

The caseload

Your caseload is the patients reachable through your care relationships, narrowed to your episodes when they name one.

  • Reachable means a live care relationship names you: your PERSON or a ROLE you perform (the direct path), or a care team or unit you are a member of (the team path). A relationship is live from its start date to its end date, plus the access policy’s relationship_grace, for a provider you act for. A relationship you wrote naming yourself never counts, and neither does a self-declared one.
  • Narrowed to your episodes means that a relationship that names an episode of care reaches only the data of that episode, the data placed in no episode and the data the access policy’s episode_shared names. A relationship that names no episode reaches the whole record.

The access decision reads your caseload for every named read, export and write of a patient’s data. A query reads it inside its one SQL statement, so COUNT, LIMIT, offset and fetch only ever see data in your caseload. A query can narrow the caseload further with the caseload, caseload_roles and caseload_episodes members (Narrowing a query to your caseload), and a SMART on openEHR session launched in an episode reads that episode alone (SMART App Launch). A worklist screen built on the caseload is your application’s (What the CDR leaves to the application).

Episodes of care

A patient admitted to cardiology and seen by dermatology has two episodes. The openEHR specifications name the episode of care (“the current episode of care, and for some reasonable, limited time afterward”, BASE Architecture Overview, Security Policy) and leave which data belong to it, and who may read them, open. FerroEHR fills that gap as follows. No openEHR specification defines these rules: they are FerroEHR’s own design, written as an addition to the draft access control package.

PartWhat FerroEHR does
The episodeA DV_IDENTIFIER the care delivery environment gives the episode, compared by issuer and id, such as a FHIR EpisodeOfCare.identifier or an HL7 v2 visit number. FerroEHR adds no party or RM object for it. An episode is open for a carer while the carer’s relationship to it is live.
The episode relationshipA care relationship with an episode element. Its dates, grace, role, path, provider and cover work as for any care relationship.
PlacementA COMPOSITION names its episodes with episode elements in context.other_context. A composition with none, an EHR_STATUS, a FOLDER and an EHR_ACCESS are placed in no episode.
Persistent compositionsA persistent composition, such as the problem list, is never placed: one that names an episode is refused 422.
Declared episodesA composition placed in an episode that no care relationship of its subject names, live or ended, is refused 422. Write the relationship first.
CoverageA relationship covers a datum when it names no episode, the datum is unplaced, the datum is in its episode, or episode_shared names it. For an access service caller it also covers the EHDS priority categories (Art. 14(1)), since Art. 11(3) makes the access “include at least the priority categories”.
RefusalWhere care is what would admit you, a named read of a datum no relationship of yours covers is refused 403 with refused-outside-episode, at step 7 of the access record. A query, a count and a page leave it out.
Access recordThe record of an admitted access names the episode of the relationship it rested on, in its ACCESS_STORED_CARE_GROUND. A refusal outside your episodes is recorded with its code.
UnchangedThe patient, an emergency, a permit directive and a gate-keeper decide as they do without episodes. An episode only narrows what the same relationship without one admits.
The patient’s choicesA directive, a controller rule, a classification or a delegation names an episode’s data with episodes in its data scope, so a patient can restrict one episode and nothing else (EHDS Art. 8, “all or parts”).

Closing an episode is ending its relationships: the carer keeps access for the policy’s relationship_grace after the end, as for any relationship. An access policy can require an episode on the relationships of named roles and provider types with episode_required on a relationship_validity entry.

What it costs

FerroEHR holds care relationships on every replica beside the grants and confirms them against the party store with one indexed read per request, so episodes add no round trip. A caller who holds no relationship scoped to an episode runs the same SQL statements, byte for byte, as before episodes existed.

Statements per request

Measured by the statement_budget::care test, each figure the mean over ten requests, after three warm-up requests, in the hospital scenario of the test suite. A round trip is one exchange with PostgreSQL; a nested statement is one a function runs inside another.

RequestRound tripsNested statementsWAL of its rows
A care-gated read200 B
The same read of a datum in your episode200 B
The same read in a SMART session launched in an episode200 B
A query narrowed to your caseload400 B
The same query under an episode relationship400 B
A care relationship commit by the ADT system262about 7.1 kB

An episode costs no statement: the read and the query under an episode relationship send exactly the statements of their plain forms.

Plans at practice scale

Measured by the care_caseload_plans test, which holds the plan shapes of these queries. Three care teams hold caseloads of 100 patients (a small practice), 1,600 (a ward) and 50,000 (a large practice list). Each query runs through the service under a policy that requires a care relationship, with the access decision applied to every row.

Measured by cargo nextest run -p ferroehr --no-capture -j 1 -E 'test(the_caseload_plans_hold_at_practice_scale)' on a developer laptop (Apple silicon, macOS), PostgreSQL 19 in a Podman VM, one session, warm cache, a debug build of FerroEHR, at commit dfb39c4fdc7c, in a store of 151,700 EHRs with 2 compositions each.

CaseloadCheck of one EHRCaseload page of 50COUNT of the caseload’s compositionsPage under an episodeCOUNT under an episode
1000.05 ms10 ms7.1 ms5 ms6.8 ms
1,6000.04 ms6.4 ms43 ms8.1 ms42 ms
50,0000.04 ms25 ms1.2 s31 ms1.2 s

With every relationship of the three teams scoped to one episode the figures are the same within the run’s noise. The check is one probe of the projection’s subject index at every size. A page starts from your own rows of the caseload index, so its cost follows the size of your caseload and not the size of the store. A count reads every composition it counts, here 100,000 at the largest caseload, so it grows with the caseload; page your worklist queries rather than counting a whole practice list.

These are local, single-session figures that show the shape of the work. Throughput and tail latency under load are measured on the reference host (Capacity, Benchmarks).