Merge branch 'fix/share-viewer-leaves' into release/v1.37.28

This commit is contained in:
Marc-André Bombeck committed 2026-08-24 02:57:12 +02:00
commit 5808f8f91a
25 files changed
+2673 -85

No files matched your search

+68 -1
View File
@@ -36,7 +36,7 @@ import {
const createShareLinkRequest = createShareLinkSchema.meta({
id: "CreateShareLinkRequest",
description:
"v1.11.0 — owner request to mint a clinician share link to their own health record. `expiresAt` is required (absolute ISO instant) and capped at 90 days. `rangeStart`/`rangeEnd` freeze the reporting window (rangeEnd null = rolling). `selection` freezes which record leaves the link may serve, and omitting it means an empty scope rather than a default one. `documentIds` freezes the documents the link carries; `documentOnly` mints a share that serves those documents and no record scope at all. A share link serves the rendered page and the documents frozen onto it — there is no FHIR or other machine-readable face behind a share token. Strict: unknown keys 422.",
"v1.11.0 — owner request to mint a clinician share link to their own health record. `expiresAt` is required (absolute ISO instant) and capped at 90 days. `rangeStart`/`rangeEnd` freeze the reporting window (rangeEnd null = rolling). `selection` freezes which record leaves the link may serve, and omitting it means an empty scope rather than a default one. The `INSURANCE` leaf is refused outright (422, naming it): the share view has never decrypted the insurance number, and refusing it here makes that structural. `documentIds` freezes the documents the link carries; `documentOnly` mints a share that serves those documents and no record scope at all. A share link serves the rendered page, the documents frozen onto it, and the same record as a PDF or FHIR Bundle download under the token (`/c/{token}/report.pdf`, `/c/{token}/fhir`) — all behind the same gate and the same frozen selection. A share token is not a Bearer credential and reaches no other route. Strict: unknown keys 422.",
});
const healthRecordExportRequest = exportSelectionSchema.meta({
@@ -281,6 +281,73 @@ export const healthRecordPaths: NonNullable<ZodOpenApiObject["paths"]> = {
},
},
},
"/c/{token}/report.pdf": {
get: {
tags: ["Export"],
summary: "Download a share link's record as the clinical PDF (public)",
description:
"Anonymous, no-session download of exactly the record the page at `/c/{token}` renders — the same frozen selection, resolved through the same `selectionFromStoredBlob`, so the file can never be wider than the page above it. The raw `hls_` share token in the path is the ONLY credential; a passphrase-protected link additionally requires the short-lived, token-scoped unlock cookie the browser already holds after unlocking. Unknown / revoked / expired token, a locked gate, and a documents-only link (which carries no record at all) all collapse to the same flat 404. Charts are embedded. Dates print in the OWNER's timezone and clock preference, not the reader's, so a practice west of the record's own zone files a document dated the way the page it came from was. The insurance number is never carried: the `INSURANCE` leaf is refused at share-link creation. Rate-limited per link at 20/h — its own bucket, because generating a report is far more expensive than serving a stored blob.",
requestParams: {
path: z.object({
token: z.string().describe("Raw `hls_` share token."),
}),
},
responses: {
"200": {
description:
"The report as `application/pdf`, `Content-Disposition: attachment`.",
content: {
"application/pdf": {
schema: z.string().meta({ format: "binary" }),
},
},
},
"404": {
description:
"Flat 404 for every miss class (unknown / revoked / expired token, locked passphrase gate, or a documents-only link with no record behind it).",
content: { "application/json": { schema: errorEnvelope } },
},
"429": {
description: "Per-link report-download rate limit exceeded (20/h).",
content: { "application/json": { schema: errorEnvelope } },
},
},
},
},
"/c/{token}/fhir": {
get: {
tags: ["Export"],
summary:
"Download a share link's record as an HL7 FHIR R4 Bundle (public)",
description:
"The machine-readable twin of `/c/{token}/report.pdf`: the same gate, the same frozen selection, the same flat 404 for every miss class, the same 20/h per-link bucket. Returns an HL7 FHIR R4 **document** Bundle as a download. This is a DOWNLOAD, not a FHIR REST face — a share token authenticates nothing beyond these three routes and `/c/{token}/d/{id}`, and it never becomes a Bearer credential against `/api/fhir/*`. Allergies and family history are deliberately absent from the bundle: they reach the owner's own export through a read this surface does not perform, so the bundle carries the aggregated payload the page renders and nothing beside it. No insurance number, for the same structural reason as the PDF.",
requestParams: {
path: z.object({
token: z.string().describe("Raw `hls_` share token."),
}),
},
responses: {
"200": {
description:
"FHIR R4 document Bundle (`application/fhir+json`), `Content-Disposition: attachment`.",
content: {
"application/fhir+json": {
schema: z.string().meta({ format: "binary" }),
},
},
},
"404": {
description:
"Flat 404 for every miss class (unknown / revoked / expired token, locked passphrase gate, or a documents-only link with no record behind it).",
content: { "application/json": { schema: errorEnvelope } },
},
"429": {
description: "Per-link report-download rate limit exceeded (20/h).",
content: { "application/json": { schema: errorEnvelope } },
},
},
},
},
"/api/fhir/metadata": {
get: {
tags: ["FHIR"],