The FHIR facade
The FHIR side of FerroBRIDGE is a REST facade in front of an openEHR CDR. A FHIR client sees one FHIR server; behind it, every request becomes CDR operations driven by FHIRconnect mappings. The facade stores no clinical data of its own.
The facade runs. It is off until [facade] enabled turns it on, and a disabled
facade mounts no route, so a request answers 404 rather than 403. What this
page describes is what the server answers today: conformance, create, read,
vread, update, search, transaction, batch, $validate and
Composition/$document.
- Why a facade
- The surface
- Security
- Media types and bodies
- Program selection
- Identity
- A read is a valid instance
- Provenance
- Writes
- Party resources
- Consent and access directives
- SMART App State
- SMART launch Tasks
Composition/$documentassembles a document$validateis a dry run of this server- Status mapping
- Paths are written as well as read
- Terminology
- Search
- What the facade does not do
Why a facade
FHIRconnect defines the mapping language and leaves the server surface to the implementer. Two shapes exist in the prior art: publish a facade, or leave both the facade and the CDR to the integrator. No standard prefers either. FerroBRIDGE publishes the facade so that a FHIR client needs to know about one server and one base URL, and so that the mapping direction, the terminology calls, and the CDR commit happen in one place that can refuse a request as a whole.
The surface
FHIR R4 (4.0.1), because that is the only version the FHIRconnect schemas admit
for spec.version. The service base is /fhir.
| Request | What it does |
|---|---|
GET /fhir/metadata | The CapabilityStatement of the loaded mapping set |
POST /fhir/{type} | Create, conditional through If-None-Exist |
GET /fhir/{type}?… | Search the type over the AQL its search declaration states |
POST /fhir/{type}/_search | The same search, its parameters in a form body |
POST /fhir/{type}/$validate | The dry run that commits nothing |
GET /fhir/Composition/{id}/$document | The document Bundle of one Composition; also GET /fhir/Composition/$document?id={id} |
GET /fhir/{type}/{id} | Read one resource back out of its composition |
GET /fhir/{type}/{id}/_history/{vid} | Vread: read the version a write’s Location named |
PUT /fhir/{type}/{id} | Update, with If-Match |
POST /fhir | A transaction Bundle, all or nothing, or a batch Bundle, each entry on its own |
GET /fhir/{type}/{id}/_history | The history of a party resource |
DELETE /fhir/{type}/{id} | Delete a party resource |
GET /fhir/.well-known/smart-configuration | The SMART discovery document, with [auth] on |
POST, PUT, DELETE and GET /fhir/Basic | SMART App State, with [facade.app_state] on (SMART App State) |
POST and GET /fhir/Task, GET /fhir/Task/{id} | SMART launch Tasks, with [facade.launch_task] on (SMART launch Tasks) |
A type no loaded program maps is absent from the CapabilityStatement and
answers 404 with a not-supported OperationOutcome on the wire. A search on a type no search
declaration answers is a 404 with not-supported, and a _count that is not
a non-negative integer is a 400 with invalid, so a client never reads a
page it did not ask for.
The CapabilityStatement names exactly the resource types the loaded programs
map, with create, read, vread and update per type, transaction and
batch at system level, the $validate operation, $document on
Composition, updateCreate: false,
conditionalCreate true, conditionalUpdate false (no PUT [type]?[search]
is served; If-Match on an update is the version-aware update),
versioning: versioned-update and readHistory: true per type, and
fhirVersion: 4.0.1. A type a search
declaration answers also names search-type and, in searchParam, exactly
_id and the parameters the declaration states; every other type names no
search parameter. A type no program maps and a reference mapping of a
loaded program creates is listed with read and vread alone (see
Resources the mapping creates).
A type a party context serves is listed with read, vread,
history-instance, create, update and delete and no search (see
Party resources).
When the FHIRconnect operations lane is served under the same base,
rest.operation also names $tofhir and $toopenehr; their direct forms are
never declared (The FHIRconnect operations says why).
With [auth] on, rest.security names the SMART-on-FHIR service and
carries the oauth-uris extension with the authorization server’s
endpoints, for clients that discover SMART through the statement (see
Security).
Security
With [auth] on, the default, the facade
is a SMART App Launch 2.x resource server for the authorization servers the
deployment trusts, each a named [auth.issuer.<name>] table fixed by its
issuer. A token is for the facade when its aud names [facade] base_url, or
one of the audiences the issuer table lists in its place.
The check is ferrohealth-smart’s, the resource server every FerroHEALTH
product runs. With [auth] off, the
facade authenticates nobody and serves every request it receives.
Every request under /fhir carries Authorization: Bearer <access token>,
or the Basic credential of a user [[auth.basic.users]] lists, except GET /fhir/metadata and the SMART discovery document at
GET /fhir/.well-known/smart-configuration (also served at
/.well-known/smart-configuration), which a client reads before it holds a
token. The health routes stay open too. The token is a JWT signed by a key
in the issuer’s key set, with an iss equal to the issuer, an aud naming
the facade, and an exp, nbf and iat that hold within the configured
clock skew. Under the default rfc9068 preset it also carries typ: at+jwt,
sub, client_id, iat and jti (RFC 9068). The issuer’s kind and
profile (its preset with the keys of its profile table over it) decide who the caller is: a person through one of the deployment’s
own clients, a patient, a machine’s client credentials token, or another
party’s person on a federation issuer. A Basic credential is always a
person’s; a machine never authenticates with one.
| Answer | When | WWW-Authenticate |
|---|---|---|
401 | No credential, or one in a scheme the server does not admit | Bearer, and a Basic realm="", charset="UTF-8" challenge beside it when Basic users are configured |
400 | Two credentials, or an Authorization value that is no credential | Bearer error="invalid_request" |
401 | A token that does not hold, whatever the reason, including a token of another issuer or for another audience, and a valid token that names no caller its issuer’s kind admits | Bearer error="invalid_token", error_description="<reason>" |
401 | A Basic credential that does not hold, whatever the reason | Basic realm="", charset="UTF-8" |
403 | A valid token whose scopes do not permit the request | Bearer error="insufficient_scope", error_description="scope-not-granted" |
403 | Any request to a route under /fhir the guard does not classify, before the token is read | none |
503 | A token naming a key the server cannot fetch because the key set does not answer | none |
Each refusal carries an OperationOutcome, login for a 401, invalid for
a 400 and forbidden for a 403. A configured realm is named on every
challenge. A Bearer challenge with an error code carries the stable reason
code of the check that refused the token as its error_description (RFC 6750
§3), such as expired, audience-mismatch, issuer-unknown,
signature-invalid or scope-not-granted; the ferrohealth-smart book lists
every code. The bridge logs the code with the token’s issuer, client and key
id, never the token. Neither the challenge nor the body names the claim that
failed or the scope that was missing.
The guard classifies every route it admits by name: the interactions in the
table below, the two FHIRconnect operations and their direct forms, the
CapabilityStatement and the discovery document. A route under /fhir that
it does not name fails closed with 403 and reaches no handler and no CDR,
so a route added without a classification is refused rather than open to any
token. A test reads every route the server mounts under /fhir and fails
when one has no classification. With [auth] off the facade stays open.
The permission each interaction needs follows the SMART v2 cruds letters,
on the resource type in the path or in the entry:
| Interaction | Needs |
|---|---|
| create | c, and u too when the create revises a resource the facade already holds (a new meta.versionId of a known id); a replay that changes nothing needs c only |
| read, vread, history (a party resource) | r |
Composition/$document | r on Composition and on every type the document carries |
| delete (a party resource) | d |
search (GET [base]/{type}, POST [base]/{type}/_search) | s |
| update | u |
$validate | c or u, or the operator scope ([auth] product_scope): the dry run commits nothing, so an operator console needs no clinical write scope |
| transaction | the permission of each entry’s request.method: c for POST, u for PUT, r for GET, d for DELETE |
| batch | per entry, the permission of the interaction its request names: c for a create, u for an update, r for a read or vread, s for a search |
$tofhir, $toopenehr | a valid token, no clinical scope, the operator scope included: they transform the request body and reach no CDR |
A scope reads patient/, user/ or system/, then a resource type or *,
then the letters in the order cruds, such as system/*.crs or
patient/Condition.rs. The SMART v1 suffixes are read as the spec maps them:
.read as rs, .write as cud and .* as cruds. A scope with letters
out of order, an unknown resource type, or a ? search constraint grants
nothing; the facade does not evaluate the constraint, so it does not grant
more than the scope says. A user/ scope reaches every resource of its type,
because the facade has no per-user access model of its own, and so does a
system/ scope. A token with no clinical scope at all gets system-wide
access only when its sub is in scopeless_subjects.
A patient/ scope reaches only the patient in the token’s patient claim,
which the facade reads as the launch context only from an issuer whose
profile sets patient_context (SMART App Launch 2.2.0, Scopes and Launch
Context, launch/patient: the authorization server sets it). The
ferrosmart preset sets it; every other preset leaves it off, so a
patient claim of such an issuer is ignored unless its
[auth.issuer.<name>.profile] table sets patient_context = true. This is the rule FerroEHR reads too.
The facade reads a patient’s data as the EHR it resolves for the subject
Patient/<id>: a create or update must name subject (or patient) as
the literal reference Patient/<id>, and a read reaches a resource only
when the EHR holding its composition belongs to that subject. A search under
a patient/ token is held to that patient’s EHR, whatever subject parameters
it names, and answers an empty searchset when the identity map binds the
patient no EHR. A resource
whose subject is named by identifier cannot be shown to be the patient’s, so
a patient-scoped token is refused for it. A patient/ scope without a
patient claim grants nothing.
A transaction is authorised entry by entry before anything is mapped, and one
entry the token does not cover refuses the whole Bundle with 403, because a
transaction succeeds or fails as one unit. A batch is authorised entry by
entry too, and an entry the token does not cover, or one outside a
patient/ token’s compartment, answers 403 Forbidden inside the
batch-response while the other entries run.
Every request under /fhir but the discovery document leaves one audit line
on the ferrohealth_smart::audit log target, the record every FerroHEALTH
product writes: the time, the token’s sub or the Basic user as
principal, the token’s client_id and issuer, the caller’s kind
(person, patient, system, delegated and the other kinds
ferrohealth-smart names; a Basic user is always person), the scheme the
credential arrived with as via (bearer or basic), what the login
resolved to as binding and party (- while the bridge binds no party),
the method, the matched route,
what was addressed (Condition/c-1, or the type alone), the interaction,
the status and the duration. Beside the log envelope its fields are exactly
at, request_id (the X-Request-Id that ties the line to the request
log), principal, client, kind, via, issuer, binding, party,
method, route, addressed, interaction, status and duration_ms. A refused
credential is recorded as unauthenticated with via none, and with
[auth] off the principal reads - with via open. A batch leaves one
line per entry, carrying the entry’s interaction, what it addressed and its
status and its position in the Bundle as entry, then the request’s own
line with the interaction batch. The line
never carries the token, another claim, a query value or a body.
The bridge never forwards the caller’s token to the CDR, because an access
token is bound to the audience it was issued for. By default it reaches the
CDR with its own credential
([cdr.endpoint.credentials.oauth]),
so the CDR records the bridge as the actor and the caller’s identity lives in
the bridge’s audit line. With
[cdr.endpoint.credentials.onward]
it exchanges the caller’s token per request for a token of the CDR’s issuer
that names the same person (RFC 8693 token exchange, or the Entra ID
on-behalf-of grant), so the CDR records the clinician too; a machine keeps the
bridge’s own token, and a caller the exchange cannot carry is refused. The
audit line still names the caller.
Browser apps (CORS)
A purely browser-based SMART app calls the facade from another origin, so the browser asks the facade, through cross-origin resource sharing (CORS), whether the page may read each answer. SMART App Launch 2.2.0 (App Launch, Considerations for Cross-Origin Resource Sharing support) says a server that supports such apps “SHALL enable” CORS for any origin on the public discovery endpoints and for a client’s registered origins on the FHIR REST API, and FHIR R4 (Security, Communications) asks the same of a server with browser clients. The facade answers both:
| Route | Origins | Access-Control-Allow-Origin |
|---|---|---|
GET /fhir/metadata, GET /fhir/.well-known/smart-configuration, GET /.well-known/smart-configuration | Any | * |
Every other route under /fhir | Those [facade.cors] allowed_origins lists | The request’s Origin, with Vary: Origin |
The facade holds no client registry, so the registered origins are the list
you configure. With the list empty, the default, the REST routes answer no
origin and a browser withholds every answer from a page on another origin.
No answer ever carries Access-Control-Allow-Credentials: an app sends its
token in the Authorization header, never in a cookie.
The facade answers the preflight (OPTIONS with
Access-Control-Request-Method) of an admitted origin itself, before the
token check, because a browser sends a preflight without the token. The
answer is 204 with the methods the facade mounts (GET on the discovery
endpoints; GET, POST, PUT and DELETE on the REST routes), the request
headers it reads (Authorization, Content-Type, Accept, Prefer, the
conditional headers and X-Request-Id) and a ten-minute Access-Control-Max-Age.
A preflight from an origin the list does not name runs as any OPTIONS does:
the guard refuses it with 403, and the browser blocks the request it
announced. An admitted origin also reads a refusal, such as the 401 of a
missing token, with Location, ETag, Last-Modified, Content-Location,
WWW-Authenticate and X-Request-Id exposed to the page.
Media types and bodies
The facade reads application/fhir+json and application/json, which R4 names
as the JSON media type and its alias, and answers 415 for anything else. Every
response carries application/fhir+json. An Accept header that admits neither
is a 406.
A body is parsed through the strict codec of the generated fhir-types crate,
so an unknown property is a 400 with structure rather than a value that is
silently dropped. Prefer: return=minimal, return=representation and
return=OperationOutcome are honoured on a write, and the default is the
resource itself. With return=OperationOutcome the outcome names the committed
version and then each loss the mapping declared: a field the engine filled is
an information issue, an element it could not carry an incomplete
warning, each with the FHIRPath of the element in expression and the
openEHR path in details.
Everything the facade authors is an OperationOutcome with an issue.code
from the R4 value set. An openEHR error body never reaches the wire as its own
document: the CDR’s message and every validationErrors entry travel
verbatim inside issue.diagnostics, which keeps one error vocabulary on the
wire while losing nothing the CDR said. A CDR that answers RFC 9457 problem
details (application/problem+json) is read the same way: its title, its
detail, each errors violation as path: detail, and its problem type.
The bridge’s composition and contribution writes send
Prefer: return=representation, so a CDR that lists violations only for such
a write lists them.
Program selection
A request is mapped by the program whose context claims the profiles the
resource declares in meta.profile. Every declared profile is considered, as
set membership, and the templateId pin of the FHIRconnect operations surface
selects among candidates when a deployment sends one.
Two refusals are distinct on the wire, and both are 422. When no program
claims the resource, the outcome names the profiles it saw and answers
not-supported. When several programs claim it and nothing pins the template,
the outcome names the candidates, so the fix is a pin rather than a guess.
Identity
A FHIR resource id has to be stable across composition versions, because R4
fixes that “once assigned, this value never changes”. The facade gives each
resource the deterministic id the FHIRconnect engine chapter recommends, a hash
of the composition uid and the entry path, the same id $tofhir answers for
the same occurrence. The composition uid is the version container, the part of
the OBJECT_VERSION_ID that stays the same across versions. The entry path
names one occurrence of the context’s start archetype wherever the template
places it: a content item, an item of a SECTION at any depth, or an instance
repeating below another entry, with a later occurrence named by its place in
its container, as in /content[openEHR-EHR-SECTION.adhoc.v1]/items[2]. Each
occurrence is a resource of its own. The hash is SHA-256, written as 52
lowercase base32 characters. meta.versionId carries the openEHR
version_tree_id and never enters the derivation, so a new version of a
composition reads back under the same id with a new meta.versionId.
meta.source names the openEHR version uid the answer was read from.
The identity map is a redb file with seven tables: a patient identifier to its
ehr_id and each ehr_id back to the first person recorded for it, an
external resource id to the internal one, an internal id to the
composition version container with the entry path and split occurrence, and the
source resource id with its meta.versionId to the mapping that consumed
them, beside the contribution each source was committed in and each
Resource.identifier of a committed resource. The map wins once written. The
store file records its schema, and a file an earlier schema wrote is refused at
boot with its path named: the ids this release derives differ from the ids the
facade served before 0.0.14, so the reset is to remove the file, which the
bridge then creates anew. The store keeps identifiers and nothing else:
no clinical content is written into it, and a test greps the file for a mapped
value to prove it.
That last table is what makes create idempotent. A resource re-sent with the
same id and meta.versionId commits nothing and answers 200 OK with the
composition it already produced. A resource with a known id and a new
meta.versionId commits a later version of that composition. A resource with a
known id and no meta.versionId is a replay when it maps to the content the
composition holds now, and a later version otherwise. A transaction entry with
a known id and a new meta.versionId commits that later version inside the
Bundle’s contribution. The Operate page on failure and identity states the
full rule.
Resources the mapping creates
Going out of openEHR, a hierarchy.split with create: resource creates one
resource per further occurrence of its node, and a reference mapping
creates the resource it names. R4 says a contained resource “does not have an
independent existence apart from the resource that contains it”, so the
facade contains none of them. Each one gets a binding of its own the first
time the facade answers the resource whose mapping creates it (its parent), on
a read, a vread, a search or a write under Prefer: return=representation.
Its id is a SHA-256 over the parent’s entry key, the creating mapping, the
openEHR occurrence positions and the split’s unique values, rendered as 52
lowercase base32 characters, so a re-run and a later composition version
derive the same id, and the map wins once written. The parent references a
created resource as <Type>/<id>. A split’s further occurrence is a sibling
of the parent, and the parent names no reference to it.
GET /fhir/{type}/{id} and the vread answer a created resource: the facade
maps the parent’s entry again and returns the created resource of that id,
with the parent’s meta.versionId and meta.source and no meta.profile.
A version that no longer creates it answers 404. A PUT of a created
resource answers 405 Method Not Allowed with not-supported, because its
content is the parent’s entry: update the parent. A search of the parent’s
type lists every split occurrence beside the entry’s own resource, each
once: a page holds at most _count resources and may end between two
occurrences of one entry, Bundle.total counts every resource, and an
_id that names a created resource answers that resource alone. A type
only a reference creates declares no search. No specification governs the
identity of a created resource or how a search reaches it: it is
FerroBRIDGE’s own design.
A read is a valid instance
Every resource the facade answers, on a read, a vread or a write under
Prefer: return=representation, is a valid R4 instance: each element the R4
element table marks min 1 is present, at the top of the resource and inside
every element and contained resource it carries (a resource the mapping
creates is answered on its own, never contained). A mapping often has no
outbound row for the subject, because the ingest reads the subject to find the
EHR and the composition does not hold it. When the rendered resource has no
subject (or patient, on a type that names its subject so), the facade
writes it from the identity map: the person the map recorded for the
composition’s EHR, as a literal reference when the person was keyed by one in
subject_namespace (Patient/<id> again under every subject_id_form), and
otherwise as a logical reference with type: Patient
and the person’s identifier. That is the form a create reads back into the
same EHR, so you can send a read body back as an update unchanged. A subject
the mapping wrote is kept. The log line of the request counts the elements the
facade filled and names their paths, never a value. When a required element
stays absent, the facade answers 500 exception with the element path in
issue.location rather than an invalid resource. No specification governs the
fill: it is FerroBRIDGE’s own design.
Provenance
Every composition the facade commits carries a FEEDER_AUDIT, which is the
reference model’s own element for data transformed into openEHR form: the
source resource’s id and type as an originating_system_item_ids entry, its
meta.versionId as originating_system_audit.version_id, and the configured
system_id naming the bridge. When a machine (a client credentials token)
made the request, its client is the originating system
(originating_system_audit.system_id) and the bridge the feeder system
(feeder_system_audit.system_id), which RM FEEDER_AUDIT records for a
feeder “different from the originating system”. A source resource that carries no id is
recorded as unknown, never given one. So a reader of the CDR can tell which
FHIR resource a composition came from without asking the bridge.
The CDR writes who committed each version, from the credential it
authenticated. A single write states the change type and system_id, which
names the bridge, in openehr-audit-details, and no committer: ITS-REST
1.1.0 leaves every member of the header optional, and a CDR that writes the
committer itself refuses one that says more than its own. A transaction’s
CONTRIBUTION must carry a committer in its audit and in every version’s
commit_audit, so there the facade names the party the CDR authenticated,
and nothing more:
- under the bridge’s own client credentials grant, a
PARTY_IDENTIFIEDnamed by its client id; - as a Basic user with
[cdr] committer_issuerset, the placeholder{"_type": "PARTY_IDENTIFIED", "identifiers": [{"_type": "DV_IDENTIFIER", "issuer": "<committer_issuer>", "id": "<user>"}]}; - under
[cdr.endpoint.credentials.onward], where the request reaches the CDR under the token the caller’s was exchanged for, the same placeholder with the exchanged token’sissandsub; - otherwise, a
PARTY_IDENTIFIEDnamed bysystem_id.
The caller the facade authenticated is recorded in the bridge’s own access record, and a machine caller as the originating system above. The facade sends no attestation.
Writes
A create resolves the subject to an EHR: the identity map first, then the CDR
by subject id and namespace, and only then the configured policy. With
ehr_policy = "existing" an unknown subject is refused; with
create_on_first_write the facade creates the EHR and records it.
If-None-Exist behaves as R4 defines it: no match creates, one match answers
200 with the resource that already exists, and several matches answer 412.
The search it runs is over the identity map, so the parameters it answers are
_id and identifier, each in the comma-separated OR form. identifier
matches the Resource.identifier of every resource the facade committed, in
the token forms [code], |[code] and [system]|[code]; the [system]|
form is refused. Any other parameter is refused, because a silently narrowed
search would turn a duplicate into a second composition.
A create answers 201 with Location naming the FHIR resource under the
configured base URL and ETag carrying the version.
That Location is [base]/{type}/{id}/_history/{vid}, and a GET of it is
the R4 vread. The {vid} is the version tree id of the composition version
the write committed. The facade finds that version in the CDR’s revision
history of the composition, reads it, and answers it with its ETag. A
{vid} the history does not list answers 404, and a version the CDR reports
deleted answers 410. An earlier version stays readable after the latest one
was deleted.
A read and a vread also answer Last-Modified: the commit time the revision
history records for the version, as an HTTP-date. That costs one more CDR
call per read. A commit time with no UTC offset names no instant, so that
answer carries no Last-Modified.
An update needs If-Match when the map knows the id. Without one, the facade
reads the CDR’s current ETag and answers 412 with it on a mismatch rather
than overwriting a version the client never saw. Send back the ETag a read
or write answered, If-Match: W/"1": the facade completes that versionId to
the current composition version and answers 412 with the current ETag
when it is stale. A value that names no version is 400. The body must
name the id the URL names: a body with no id, or another one, is 400. A PUT to an id the map does
not know is a 404: this milestone does not upsert, and the
CapabilityStatement says updateCreate: false.
A transaction Bundle maps every entry first and commits the lot through one
ITS-REST contribution so the CDR makes it atomic. The facade uses fullUrl
in two places. It names each entry by its fullUrl in every refusal, or by
its position when it has none. And a subject or
patient reference whose value is another entry’s fullUrl is read through
that entry: the person is that entry’s first identifier with a value, or under subject_id_form logical_id and
uuid its logical id when the entry carries one. The
facade resolves no other reference. A reference is mapped as the resource
carries it, and the facade never fetches a referenced resource from anywhere.
Any failure answers one OperationOutcome naming every failing entry, and
nothing is committed.
A committed transaction answers 200 with a transaction-response Bundle,
one entry per request entry in the same order. Each entry’s response carries
201 Created, the location [base]/[type]/[id]/_history/[vid] and the
etag W/"[vid]", the values a single create answers, and an
outcome naming each loss the entry’s mapping declared, as a single write
answers it under return=OperationOutcome. Send the same Bundle
again and nothing is committed: each entry answers 200 OK with the location
of the resource the first delivery created. A Bundle only some of whose
entries an earlier delivery consumed is refused with 409, naming those
entries, and a Bundle that carries one resource twice is refused with 422.
A delivery that arrives while another delivery of the same Bundle or resource
is still in flight is refused with 409 and commits nothing; retry it after
the first one answers. The redelivery rule is on the
failure and identity page.
An entry whose mapping links a resource as a composition of its own (a
FHIRconnect linked mapping) is refused with 422 and not-supported: the
linked composition’s id exists only once the CDR commits it, so it cannot
share the transaction’s one contribution. Send that resource on its own, or as
an entry of a batch, whose entries commit one at a time.
A batch Bundle runs each entry as the single interaction its request
names, and answers 200 with a batch-response Bundle, one entry per request
entry in the same order (R4 http.html §3.1.0.11). The entries run in the order
R4 gives for a transaction, every POST before every PUT and every GET
last, and the answer keeps the Bundle’s order.
Entry request | Runs as |
|---|---|
GET [type]/[id] | read |
GET [type]/[id]/_history/[vid] | vread |
GET [type]?… | search |
POST [type] | create, with ifNoneExist as its If-None-Exist |
PUT [type]/[id] | update, with ifMatch as its If-Match |
Each entry’s response carries the status the single interaction answers,
with its location and etag. A successful entry carries its resource, or
none under Prefer: return=minimal, which reaches every entry, and a failed
entry carries its OperationOutcome in response.outcome. A CDR refusal of
one entry is that entry’s status through the status table, and the other
entries still run. A DELETE, PATCH or HEAD entry answers 405, a
request.url the facade routes no interaction for answers 404, and an
absolute request.url under another server’s base answers 400. An entry
whose resource references another entry’s fullUrl answers 400 invalid,
because R4 calls such a batch non-conformant; the other entries run. A Bundle
with an entry that carries no request, or a POST or PUT entry with no
resource, is refused whole with 400, naming each such entry, and nothing
runs.
An HL7 v2 message that the HL7 v2 face receives
goes through this same path as a transaction of its Bundle’s entries, so the
same identity and replay rules apply to it. Its entries are keyed by the
message’s MSH-10 and message type and their position in the Bundle, so a
message sent again commits nothing and is answered AA, as its first delivery
was. A message whose delivery overlaps another of the same message is refused
and commits nothing. Each composition’s FEEDER_AUDIT names the sending
application, the order numbers and the message (see the HL7 v2 face page)
where a resource would be named here. A subject reference to another entry of the
Bundle is read through that entry: the person is the referenced resource’s
first identifier, the same pair a subject.identifier names.
References the request does not carry
A reference mapping reads the resource a reference points at. FHIRconnect
says that when the resource is not in the request, “the engine should attempt
to GET it from the sending site. If not possible, the engine proceeds with the
mapping”, and that it should stop at a level or track what it resolved. The
facade’s policy beyond that is FerroBRIDGE’s own design:
- In a transaction Bundle, an entry answers a reference to it first: by its
fullUrl, or by<Type>/<id>when it carries an id. Such a reference is never read from this server or fetched. - A relative reference (
Observation/abc), or an absolute one under[facade] base_url, names a resource this server committed. The facade reads it through the identity map and the CDR, as a read of it answers. - An absolute reference to another server is fetched with
Accept: application/fhir+jsononly when its base is listed in[facade.references] fetch_bases, and a redirect is not followed. The list is empty by default, so by default the facade fetches nothing, and a client cannot make the bridge call a URL it names. - References are followed to
max_depthlevels (default 2: the request’s own, then those of each resolved resource), and each literal is resolved once, so a cycle ends. - A reference the facade does not resolve, because its base is not listed,
the server answered a status other than
200, the fetch timed out, the body is not the referenced resource, or this server holds no such resource, is a declared skip: the write proceeds without it. The log line names the reference, the base and the upstream status, never a body, and$validateanswers it as awarningissue naming the reference and the reason.
Only a reference whose type some loaded reference mapping names is
followed, because no other is read. The keys are on the Operate page under
[facade.references].
Demographic references
A reference a mapping writes as a party (a recorder as the composer or as
ENTRY.provider, a participant) is never dropped. FHIRconnect sends it to a
demographics service, and with none “a FHIRconnect engine should use the IDs
maintained by the FHIRconnect engine’s FHIR-server” (engine/demographics.adoc).
The facade is that server, so a relative reference, or one under
[facade] base_url, becomes an identity issued by that base:
- in
PARTY_IDENTIFIED.identifiersas aDV_IDENTIFIERwhoseissueris the base, whoseidis<Type>/<id>and whosetypeisfhir-reference, where the FLAT format carries identifiers (ENTRY.provider); - in
PARTY_PROXY.external_refas aPARTY_REFin the base’s namespace with aGENERIC_IDof schemefhir-reference, on the composer and on a participation’s performer, whose FLAT keys carry only the reference.
A read turns either back into the same Reference.reference. A reference to
another server keeps that server as its issuer, and a urn: reference to an
entry of the request is refused. The identity shapes are FerroBRIDGE’s own
design. A CDR that refuses identified parties in clinical content answers
422, and the facade passes its words through in issue.diagnostics.
Party resources
A party context (a FHIRconnect context whose template is rooted at a PERSON,
ORGANISATION or ROLE) serves its resource type from the CDR’s demographic
store over the ITS-REST 1.1.0 Demographic API, DEVELOPMENT, which the release
marks x-status: DEVELOPMENT. It loads only with [cdr] demographic on: a
party context with the gate off is a boot refusal, and one resource type is
served by one party context. The correspondences live in the mapping files,
for example Patient and Practitioner onto a PERSON, PractitionerRole
onto a ROLE, and Organization onto an ORGANISATION.
- Identity. The id is the party’s
versioned_object_uidandmeta.versionIdits version tree id; the identity map holds no entry for it. OnePERSONreads as aPatientand as aPractitionerunder the same id, because FHIR scopes an id to its type. - Interactions.
read,vread,history-instance,create,update(over the versionIf-Matchnames, or the latest) anddelete(the latest version). The Demographic API has no search or list operation, so a party type offers no search, and theCapabilityStatementdocuments that on the type. With[facade.party_search]a configured type is searched byidentifierornamethrough the Cadasto experimental AQL demographic extension, or by_id, and the statement declaressearch-typeand exactly those parameters on that type. A CDR that does not serve the extension answers the search with501 not-supported. - The patient’s EHR. With
ehr_policy = "create_on_first_write", aPatientcreate also gives the new party its EHR: the facade looks the party’s id up through the subject link (subject_namespace,subject_id_form,subject_type) and creates the EHR when the CDR holds none, so the clinical resources that namePatient/<id>find it. Underexistingthe create sends no EHR call, and aPractitionernever gets one. When the EHR call fails after the party committed, the answer is the EHR refusal with a warning that names the storedPatient. - Template. A party built against another template than the context’s
answers
404. The template may be an ADL 1.4 OPT or an ADL 2 operational template, the one a CDR serves only on itsadl2route included. ADL 2.4 admits two node identifier coding systems (§4.2.5): an at-coded template names its nodes[at0001], an id-coded one[id3], and the paths of the model mapping name the codes the template and its data carry, because a path predicate is a shortcut for[@archetype_node_id = …](BASE 1.2.0, Architecture Overview, Paths and Locators). FerroEHR’s professionalPERSON,openEHR-DEMOGRAPHIC-PERSON.healthcare_professional.v1.0.0, is id-coded: its identifier isdetails[id2]/items[id3]and its full nameidentities[id4]/details[id5]/items[id6]. The header names the archetype’s interface id and pins its release as the revision (archetype: openEHR-DEMOGRAPHIC-PERSON.healthcare_professional.v1,revision: 1.0.0), as the FHIRconnect header does for any archetype; the context names the full template id. An at-coded path names no node of an id-coded template, and the load refuses it as a path the template does not have. - Status. A Demographic API
400is a500;404,409,412and422reach the caller as themselves, with the CDR’s words inissue.diagnostics. - Authorization. A
patient/token reaches the onePatientits launch context names and no other party resource. - Bound professionals. A
PERSONthat carries a binding key, an identifier of an issuerbinding_identifier_issuersnames, is bound to a login at the CDR and provisioned through the CDR’s SCIM service. The facade refuses a create, update or delete of such a party (aPractitioner, typically) with403 forbiddenbefore it writes to the CDR, and the CDR refuses the same write from any client but an administrator or that SCIM client.
A PractitionerRole maps practitioner onto the ROLE’s mandatory
performer. The reference must name a Practitioner this facade serves,
relative (Practitioner/<id>) or under the facade’s base, and carry nothing
beside reference; the facade answers any other reference, and a role with
no practitioner, with an error rather than dropping it. These rules are FerroBRIDGE’s own design: no
specification defines a FHIRconnect mapping rooted at a party.
Consent and access directives
With [facade.consent] on, the facade exchanges a patient’s openEHR access
directives, the draft ACCESS_DIRECTIVE_SETTINGS of the EHR’s EHR_ACCESS,
as HL7 FHIR Consent, as IHE BPPC acknowledgements and as IHE APPC Privacy
Consent Documents. The CDR commits and checks the directives; the bridge
translates. It reads the current EHR_ACCESS with the CDR’s extension
GET /ehr/{ehr_id}/ehr_access under extensions_url (its ETag names the
version), appends the
imported directives to the ones in force, and commits the whole settings as
the next version in a CONTRIBUTION whose preceding_version_uid is the
version it read, so the CDR refuses a stale write with 409, which the
facade answers as 409 Conflict. Both calls go out under the token the
onward lane exchanges for the caller, so the CDR decides for the patient or
the gate-keeper who asked: a 404 or 403 the CDR answers that caller is
the facade’s answer, never an empty result, and a directive naming a party
the CDR’s demographic store does not hold is refused with 422. The catalogue
of the controller’s ACCESS_POLICY is read under the bridge’s own token with
GET /admin/access_policy under extensions_url.
| Interaction | Route | Answer |
|---|---|---|
| create | POST [base]/Consent | 201 with the Location of the first directive created |
| read | GET [base]/Consent/{id} | the Consent of one directive in force |
| search | GET [base]/Consent?patient=Patient/{id} | a searchset of every directive in force |
$bppc import | POST [base]/Consent/$bppc?patient=…&evidence=… | 201 with an OperationOutcome naming each Consent created |
$bppc export | GET [base]/Consent/$bppc?patient=… | a collection Bundle of Binary documents |
$appc import | POST [base]/Consent/$appc?patient=… | 201 with an OperationOutcome naming each Consent created |
$appc export | GET [base]/Consent/$appc?patient=… | a collection Bundle holding one Binary document |
The CapabilityStatement lists Consent with create, read and
search-type, the patient parameter, and the two operations. A Consent is
R4 unless the media type names R5, application/fhir+json; fhirVersion=5.0
in Content-Type for a create or in Accept for a read or a search (FHIR R4
versioning.html, version negotiation); the answer carries the same media
type. The IHE documents are posted as text/xml or application/xml; BPPC
takes evidence, the DV_EHR_URI of the composition the caller stored the
document in. Under the guard a BPPC or APPC import needs Consent create and
an export Consent search, and a patient/ token reaches only its own
patient.
One directive is one Consent. A Consent id is the 32 hex digits of the
EHR’s UUID followed by the 32 of the directive’s key, its uid (which the
bridge stamps on every directive it imports) or, for a directive another
client wrote with no UUID uid, the v5 UUID of its canonical JSON. A read
therefore needs no identity map entry, and an EHR whose id is no UUID has no
Consent ids. A construct with no openEHR form is refused with 422, naming
the element: nesting deeper than one level of exceptions, a
provision.data.meaning other than instance, R5 provision.expression
and resourceType, an actor role other than v3 PRCP or IRCP, a status
other than active, a modifier extension, and an extension the mapping does
not read. A foreign provision.action code is translated to an operation
class through the [terminology] server with ConceptMap/$translate; with
no server, or no translation, the Consent is refused naming the coding.
Attributes with no core element are written in extensions under
https://ferrobridge.eu/fhir/StructureDefinition/: emergency-override,
role, relationship, organisation-type, caller-kind, archetype, origin, object-ref,
time-validity, base-undecided and access-directive.
BPPC maps an acknowledgement of a policy the domain publishes by OID to
the catalogue entry with that identifier (ITI TF-3 5.1); an OID the catalogue
does not hold is refused. An export writes one document per distinct
time_validity and names each directive an acknowledgement cannot state in an
OperationOutcome entry. APPC maps each XACML policy to one directive and
a policy set under deny-overrides whole (APPC TF-3 5.6, XACML 2.0 Appendix C);
another combining algorithm, or a condition over another attribute, is
refused with the element named. The routes, the id and the extension set
are FerroBRIDGE’s own design: no specification defines a FHIR operation for
BPPC or APPC, or how a Consent maps onto openEHR access directives.
SMART App State
With [facade.app_state] on, Basic at the facade’s base is the SMART App
State endpoint of SMART App Launch 2.2.0, Persisting App State: an app keeps
a small amount of its own state at the EHR, such as display preferences or
the keys to an external data set. The CDR holds no Basic, so the facade
keeps these resources in a store of its own, apart from the identity map. The
discovery document lists smart-app-state, and the CapabilityStatement
instantiates smart-app-state-server and lists Basic with the
smart-app-state-basic profile.
| Interaction | Route | Answer |
|---|---|---|
| create | POST [base]/Basic | 201 with Location, ETag: W/"1" and the resource with its id and meta.versionId |
| update | PUT [base]/Basic/{id} with If-Match | 200 with the next ETag |
| delete | DELETE [base]/Basic/{id} with If-Match | 204 |
| search | GET [base]/Basic?code={system}|{code}&subject={reference} | a searchset of the matching state |
| search, global | GET [base]/Basic?code={system}|{code}&subject:missing=true | a searchset of the state with no subject |
The facade refuses with 400 a body that breaks the profile or the page’s
rules: an id or meta.versionId on a create, a Basic.code with other than
exactly one coding naming a system and a code, an extension with a value other
than valueString or with nested extensions, a modifier extension, and a
subject that is no absolute reference under the facade’s base to a Patient,
Practitioner, PractitionerRole, RelatedPerson or Person. A body over
256 KiB is a 413. An update or a delete without If-Match, with a stale
version, for an id already deleted, or an update that changes subject or
code, is a 412; an id never issued is a 404. A search takes code
once, as system|code, and subject or subject:missing once; another
parameter is a 400.
Under the guard every App State request needs a token, and the facade decides
the Basic permission against the state itself: c to create, u to update,
d to delete, s to search. A granular scope counts when it names only
code with this state’s system|code, so
patient/Basic.cuds?code=https://myapp.example.org|encrypted-phr-access-keys
reaches that one state code. A patient/ scope reaches only state whose
subject is [base]/Patient/{patient} of the launch context, and never global
state; a user/ or system/ scope reaches every subject and global state. A
search with no subject answers the state the token reaches. The store and
these access rules are FerroBRIDGE’s own design within the page’s
§Security and Access controls.
SMART launch Tasks
With [facade.launch_task] on, Task at the facade’s base serves the two
launch profiles of SMART App Launch 2.2.0, Task profile for requesting a SMART
launch: task-ehr-launch asks the EHR to launch an app with an optional
appContext, and task-standalone-launch asks for a standalone launch. An
EHR viewer lists the Tasks for the patient in view and acts on one; for an
EHR launch it registers the launch at the authorization server’s launch API
with the Task’s for, encounter and appContext. The CDR holds no
Task, so the facade keeps them in a store of its own.
| Interaction | Route | Answer |
|---|---|---|
| create | POST [base]/Task | 201 with Location, ETag: W/"1" and the Task under a new id |
| read | GET [base]/Task/{id} | the Task |
| search | GET [base]/Task?patient=…&status=…&code=… | a searchset of the matching Tasks |
A Task conforms to one profile or is refused with 422 naming the element:
Task.code carries launch-app-ehr or launch-app-standalone of
http://hl7.org/fhir/smart-app-launch/CodeSystem/smart-codes, exactly one
input of type smartonfhir-application carries the app’s URL as valueUrl,
and at most one input of type smartonfhir-appcontext carries a
valueString; other inputs stand. A body that is no R4 Task, or carries a
modifier extension, is a 400, and the id a create carries is ignored, as
FHIR R4 http.html says. patient takes Patient/{id}, a bare id, or an
absolute reference, matched against Task.for with this server’s base taken
as relative; status and code are tokens; each takes a comma-separated
list, and another parameter is a 400. The CapabilityStatement lists Task
with both profiles. Under the guard each interaction needs its Task
permission, and a patient/ scope reaches only the Tasks whose for is the
patient of its launch context. The store and these rules are FerroBRIDGE’s own
design.
Composition/$document assembles a document
FHIR R4 defines Composition/$document
(https://hl7.org/fhir/R4/composition-operation-document.html) and leaves the
assembly to the server. For a Composition a loaded context maps, such as
Composition-eu-lab, the facade reads the Composition as a read would and
answers a Bundle of type document:
- its
identifieris a name-based UUID of the composition version the content came from, so one version always names one document, and itstimestampis the moment of assembly; - entry 0 is the Composition, and every resource the context’s outbound run
creates follows it, in the order the run creates them, each with the URL a
read answers it at as its
fullUrl.
How the Bundle is assembled is FerroBRIDGE’s own design. The server stores no
document and reads no GraphDefinition, so persist=true and any graph are
refused with a 400 OperationOutcome rather than ignored; persist=false
is honoured. A Composition named by the URL of another server is refused the
same way. The operation is declared on Composition in the
CapabilityStatement. The R4 OperationDefinition describes the document as
wrapped inside a search Bundle; the facade answers the document Bundle itself.
$validate is a dry run of this server
POST /fhir/{type}/$validate runs the whole inbound path up to the commit and
commits nothing, which a test proves by counting EHRs and versions before and
after. It answers 200 for both verdicts: information issues when the
resource would commit, and an error issue carrying the validator’s message
verbatim when it would not. The operation-level statuses mirror the create
path, so a 415, a 422 for an unmapped profile or a 404 for an unknown
type reads the same on both routes.
The validator is this server, not the CDR. openEHR ITS-REST 1.1.0 documents no
composition-validation route, and a commit the bridge never finalises would
still write a version, so what runs is the mapping engine, the Web Template
validation the composition build performs, and the strict RM reader. Every
outcome says so in issue.details, so you can read what a verdict covers. A
CDR that refuses a composition this validator accepts still answers 422 on
the create.
Status mapping
No specification governs what a CDR answer becomes on the FHIR wire, so the mapping is FerroBRIDGE’s own design. It lives in one table, each row citing both sides, and one wire test asserts each row.
| The CDR answers | The facade answers |
|---|---|
422, template validation | 422 with validationErrors verbatim in issue.diagnostics |
412 | 412 carrying the current ETag |
204 on a read, the composition is deleted | 410 |
404 | 404 |
401 | 401, propagating WWW-Authenticate, never 403 |
400, 405 or 415 | 500: the bridge chose a call the CDR does not offer |
any 5xx | 502 carrying the upstream status |
400 on a search query | 500: the bridge wrote the AQL the CDR refused |
408 on a search query | 502 carrying the upstream status |
| no answer: a connect failure or a timeout | 502 |
| no call: the token endpoint for the CDR credential fails or refuses | 502 naming the token endpoint’s refusal, never the secret |
401, and the token endpoint refuses the one renewal | 502 naming the token endpoint’s refusal, never the secret |
Two answers come from the server itself, before or around the handler, and
under /fhir both are an OperationOutcome: a body over
body_limit answers 413 with the too-long issue, and a request that
outlasts request_timeout answers 504 with the timeout issue. The
504 replaces the plain 408 other routes answer, because a 408 tells a
client it may resend a write the CDR may already have committed. A handler
that fails unexpectedly answers 500 with the exception issue and the
request id in diagnostics; the cause stays in the server log.
Paths are written as well as read
The engine is a bidirectional path model over FHIR JSON, because a mapping has
to construct a resource as well as read one. The model is guided by the element
table of the generated fhir-types crate, so it knows which elements repeat,
which are choice types, and which alternatives a choice admits. The three
read-side FHIRPath forms the published mappings use (ofType() and as(),
extension(url), resolve()) are path-model operations; no FHIRPath evaluator
is embedded. FHIRconnect’s ^ parent operator and $fhirRoot are not FHIRPath,
and the path model resolves them when the mapping is compiled.
Terminology
The facade calls a configured FHIR terminology server for three operations:
$lookup to resolve a code’s display, $translate for a conceptmap
reference, and $validate-code. The $lookup case is the common one, because
openEHR requires DV_CODED_TEXT.value while FHIR leaves display optional. A
terminology failure is an error, never a coding with a missing display.
A mapping that names a conceptmap is translated through $translate on
every read, write, search and $validate, and on the HL7 v2 face. The map is
read as authored from openEHR to FHIR: a composition going out as FHIR is
translated forward with the map’s url, and a resource coming in is
translated with reverse=true. Every code is resolved before the composition
or resource is built, so a terminology refusal costs no CDR write. Only an
equivalent or equal match counts. An untranslated optional element is
reported as a loss, and an untranslated required one refuses the resource.
With no [terminology] section, a conceptmap mapping refuses with “no
terminology server is configured to translate through”.
A coding with no display that goes into a DV_CODED_TEXT, or into a
DV_TEXT whose value would otherwise fall back to the coding’s code (the
concept carries no text either), is looked up through CodeSystem/$lookup
on every run into openEHR (a write, $validate, $toopenehr and the HL7 v2
face): the display the server names becomes the value. A code the server does
not know refuses the resource unless
[terminology] display_fallback is true, which writes the code instead; a
failed call refuses either way. With no [terminology] section the code
stands as the value, and the run reports the fallback as a loss. An
DV_CODED_TEXT code of an archetype-local terminology (local or openehr)
is never looked up.
Search
FHIRconnect states that it “does not focus specifically on AQL and FHIRsearch”, so no specification governs FHIR search over an openEHR CDR. The surface below is FerroBRIDGE’s own design, built on the R4 search page for everything the client sees.
Declaring search beside a context
A context answers search only when a search declaration names it. The
declaration is a YAML file in the mapping directory whose name ends in
.search.yml or .search.yaml; the FHIRconnect loader skips those files, and
the facade reads them at boot after the mapping set compiles.
context: condition.problem-list # metadata.name of the context mapping
patient:
parameters: [patient, subject] # the names that address the EHR's subject
required: true # a search without one is a 400
order: # the total order every page is read in
- v/commit_audit/time_committed/value
- v/uid/value
parameters:
code:
type: token
node: { class: EVALUATION, archetype: openEHR-EHR-EVALUATION.problem_diagnosis.v1 }
path: data[at0001]/items[at0002]/value # the coded text, relative to the node
systems:
"http://snomed.info/sct": SNOMED-CT
onset-date:
type: date
node: { class: EVALUATION, archetype: openEHR-EHR-EVALUATION.problem_diagnosis.v1 }
path: data[at0001]/items[at0077]/value/value
recorded:
type: date
path: context/start_time/value # no node: read under the composition
A parameter names the node it is read under with node, the RM class and
the archetype id of an archetype root, and gives its path relative to that
node. A parameter with no node is read under the composition. A token
names the coded value itself, a DV_CODED_TEXT, a DV_TEXT or a
CODE_PHRASE, and the facade reads its code and its system from that one
value, so [system]|[code] never pairs the system of one diagnosis with the
code of another. A string or a date names a data value, with any
attribute below it.
The facade writes the query itself:
SELECT e/ehr_id/value, v/uid/value, c FROM EHR e CONTAINS VERSION v[LATEST_VERSION] CONTAINS COMPOSITION c,
restricted to the context’s template through
c/archetype_details/template_id/value. Each occurrence of a parameter read
under a node binds that node in the FROM, as
CONTAINS EVALUATION n0[openEHR-EHR-EVALUATION.problem_diagnosis.v1], so
the conditions of one occurrence read one node, while a repeated parameter
(an AND) may match a node of its own. Every search value travels as a bound
AQL parameter and never as query text.
The declaration is checked when the server starts, against the template the
context maps, and any of these refuses the start with the file named: an
unknown key, a context no loaded mapping compiles, a parameter type other
than token, string or date, a name under the _ prefix R4 reserves, a
node the template does not hold, a path the template does not hold, a path
that crosses a node which may occur more than once below the bound one (bind
that node instead), a token over a value that is not coded, a path that is not
one AQL path, a query that does not parse as AQL, two declarations of one
resource type over one template, two declarations of one type that state
different parameters, and a parameter that takes the code of a standard R4
search parameter of the resource type with another type (code on a
Condition is a token; patient and subject are references). R4 says
“standard parameters cannot be redefined”. A parameter that takes a standard
code names that parameter’s canonical as definition in the
CapabilityStatement, and a code R4 does not define for the type carries
none. order defaults to the commit time and then the version
uid; set it when your CDR orders better by something else, and end it with a
key that is unique per composition.
What a search answers
| Parameter | What it does |
|---|---|
a declared token | [code], [system]|[code], |[code] and [system]|; systems translates a FHIR system URI into the openEHR terminology id, and an unlisted system compares as written |
a declared string | starts-with by default, :contains and :exact |
a declared date | the range of the value’s precision, with the prefixes eq, ne, gt, lt, ge, le, sa and eb |
patient, subject (as declared) | [id], Patient/[id], an absolute URL on this server, or the :Patient modifier, resolved through the identity map to the EHR |
patient:identifier, subject:identifier | [system]|[value], the identifier a resource’s subject reference carries: the identity map’s subject keyed by that system and value, which the facade renders with that identifier; a subject rendered as a literal reference carries none and matches nothing, |[value] matches nothing, and [value] alone or [system]| is a 400 |
patient.identifier, subject.identifier, subject:Patient.identifier | with [facade.identifier_search] on: [value], or [system]|[value] where a system query is configured; the identifier is resolved to every demographic party that carries it and each party’s EHR, so a bare value two patients carry matches the resources of both (R4 search §3.1.1.4.10) |
_id | a logical id, resolved through the identity map to its composition |
_count | the page size, capped at [facade] search_count_max; 0 answers the total alone |
_sort | declared parameters read under the composition, - for descending, ahead of the declared order; a parameter read under a node is refused, because it has a value per node |
_summary | count answers the total alone; false is the default |
_total | none, estimate or accurate |
A comma inside a value is an OR and a repeated parameter an AND. An empty
parameter is ignored. A subject or an id the identity map does not know
matches nothing, so the answer is an empty searchset, never a 404, and no
query reaches the CDR. A subject is read from the map and never echoed from
the request.
A parameter the type does not declare is a 400 with not-supported naming
it. Send Prefer: handling=lenient and the facade ignores it instead, leaves it
out of the self link and reports it in an OperationOutcome entry with
search.mode = outcome. A modifier the facade does not support is a 400 in
both modes, because R4 makes that a SHALL. So are a malformed value, the ap
date prefix, and a string pattern carrying * or ?, which AQL LIKE reads
as wildcards with no escape (search it with :exact). The one supported
chain is identifier on a subject parameter: any other chain is a parameter
this server does not support. A modifier on the chain is a 400, and a
subject:Group.identifier names a target that is never an EHR subject, so it
matches nothing. The CapabilityStatement states the chain in the
documentation of each subject parameter, and only while it is on.
The searchset
The answer is a searchset Bundle with an id and meta.lastUpdated. Each
entry is one composition, with a unique fullUrl under the configured base and
search.mode = match, mapped back through the context’s program as a read
maps it. link[self] names the parameters the search used with the page size,
and link[next] appears when another page follows. Its _cursor is opaque:
follow the link as answered, because a cursor pasted onto another search is a
400.
Each entry of the context’s archetype in a composition is a resource of its
own. A query that binds a node answers a row per matching node, and the
search answers the entries that hold the matched nodes; a search that binds
no node, such as patient alone, answers every entry of each matching
composition. The rows of one composition sit together under the order, and
an entry the page already holds is passed over. Each page reads one row past
its room through the CDR’s offset and fetch, and a next link is written
only when another entry is left, its cursor at the first row of that entry’s
composition with the number of its entries already answered. Bundle.total
counts matching entries, never the page and never the nodes: a first page
that holds every match carries it at no cost, and _total=accurate on a
paged search costs one AQL count of the entries, which reads no composition.
The count binds the entry as CONTAINS <class> x[<archetype>], and AQL
CONTAINS also finds an entry nested in a SECTION, so a search that binds
a node or an _id, or a template that nests the entry, reads the rows and
counts each entry once instead. _total=estimate always answers from one
count query, and _total=none leaves the total out. _count=0 and _summary=count answer the total
alone, with no entries and no next link.
A search never answers an empty Bundle for a failed call. A CDR refusal reaches
the wire through the status table above: a 5xx or a 408 on the query is a
502 carrying the upstream status, and a 400 on it is a 500, because the
bridge wrote the AQL. A row the facade cannot read is a 502 naming the column,
never the value.
What the facade does not do
It does not materialise a FHIR store, it does not implement Subscriptions, and it does not send demographics to an external endpoint. Each of those is recorded as outside the current design, with its reasoning, on the tracker.