feat(capabilities): advertise the FHIR REST face and share-link surface

Add a single canonical FHIR_REST_RESOURCE_TYPES catalogue (plus the
$everything operation and honoured search params) to fhir/rest.ts; the
metadata CapabilityStatement and the share-link resource-type enum now
derive from it so the advertised set can never drift from what is routed.

Extend GET /api/meta/capabilities with the FHIR REST descriptor
(restBaseUrl, readScope, resourceTypes, operations, searchParams) and a
clinician-share descriptor (supported, maxDays, resourceTypes, scopeable
sections) — every list sourced from its canonical registry, guarded by
the existing drift assertions. Grow the OpenAPI CapabilitiesResponse to
match.

Fill the clinician test-matrix gap: assert the clinician view never
requests a KVNR / identifier opt-in from the aggregator (default-OFF by
construction) and resolves a rolling window without reaching data older
than the frozen start.
This commit is contained in:
Marc-André Bombeck committed 2026-06-04 02:34:33 +02:00
1 parent 93694cacd0
commit d4686ea2a6
7 files changed
+240 -24

No files matched your search

+8 -10
View File
@@ -13,23 +13,21 @@
*/
import { z } from "zod/v4";
import { FHIR_REST_RESOURCE_TYPES } from "@/lib/fhir/rest";
import { exportSectionsSchema } from "@/lib/validations/health-record-export";
/** Maximum lifetime of a share link, in days. No never-expiring share. */
export const SHARE_LINK_MAX_DAYS = 90;
/**
* The FHIR resource types a share link may be scoped to serve — the read-only
* catalogue the REST face exposes. A create request may select any subset;
* an empty array means "no FHIR resources" (view-only, when `allowFhirApi` is
* off this is moot).
* The FHIR resource types a share link may be scoped to serve — exactly the
* read-only catalogue the REST face exposes. Derived from the single canonical
* `FHIR_REST_RESOURCE_TYPES` so a share can never be scoped to a type the REST
* face does not actually route. A create request may select any subset; an
* empty array means "no FHIR resources" (view-only, moot when `allowFhirApi`
* is off).
*/
export const SHARE_LINK_RESOURCE_TYPES = [
"Patient",
"Observation",
"MedicationStatement",
"MedicationAdministration",
] as const;
export const SHARE_LINK_RESOURCE_TYPES = FHIR_REST_RESOURCE_TYPES;
export const shareLinkResourceTypeEnum = z.enum(SHARE_LINK_RESOURCE_TYPES);