Skip to content

Wire history read endpoints and vread#117

Merged
smunini merged 1 commit into
mainfrom
feat/history-read-endpoints
Jun 2, 2026
Merged

Wire history read endpoints and vread#117
smunini merged 1 commit into
mainfrom
feat/history-read-endpoints

Conversation

@smunini
Copy link
Copy Markdown
Contributor

@smunini smunini commented Jun 1, 2026

Summary

The history storage layer was fully implemented (versioned resource_history table + InstanceHistoryProvider/TypeHistoryProvider/SystemHistoryProvider traits), but the REST read handlers returned 501 Not Implemented even though the CapabilityStatement advertised the interactions. This PR wires them up so advertised capability matches runtime behavior.

Changes

  • handlers/history.rs — instance/type/system history handlers now call the providers and build type: history Bundles. Each entry carries request (method+url), response (status, weak ETag, lastModified), and the resource body for non-delete versions. Supports _count (capped at max page size) and _since (RFC3339; malformed → 400). Instance history returns 404 only when the result is empty and unfiltered (an existing resource always has ≥1 version), so a _since that excludes everything still yields an empty Bundle.
  • handlers/vread.rs — calls VersionedStorage::vread, mirrors the read handler response (ETag, Content-Type with fhirVersion), and 404s an unknown version.
  • composite/storage.rsCompositeStorage only delegated up to InstanceHistoryProvider. Added a DynSystemHistoryProvider field, implemented TypeHistoryProvider + SystemHistoryProvider (delegating to the primary), and raised the with_full_primary bound so type/system history work on the -elasticsearch composite variants.
  • lib.rs + routing/fhir_routes.rs — raised router/app-builder trait bounds to require TypeHistoryProvider + SystemHistoryProvider. All four base backends already implement these; CompositeStorage now does too.

Endpoints now Live

Endpoint Method Status
/{type}/{id}/_history GET instance history Bundle (404 if resource never existed)
/{type}/_history GET type history Bundle
/_history GET system history Bundle
/{type}/{id}/_history/{vid} GET vread (404 if version unknown)

(The R6 Trial Use DELETE history/version endpoints were already Live.)

Testing

  • Added mod history_reads to rest_conformance.rs (8 tests): instance/type/system history, _count limiting, malformed _since → 400, vread of specific versions, and not-found cases.
  • Full helios-rest suite green (194 unit + all integration binaries); composite tests green (--features R4).
  • Builds verified with default features and --features postgres,elasticsearch,s3,mongodb.
  • cargo fmt + clippy (CI flags) clean.

The history storage layer was fully implemented (versioned resource_history
table + InstanceHistoryProvider/TypeHistoryProvider/SystemHistoryProvider
traits), but the REST read handlers returned 501 Not Implemented even though
the CapabilityStatement advertised the interactions. Wire them up:

- history.rs: instance/type/system history handlers now call the providers and
  build `type: history` Bundles. Each entry carries request (method+url),
  response (status, weak ETag, lastModified), and the resource body for
  non-delete versions. Supports `_count` (capped at max page size) and `_since`
  (RFC3339; malformed value -> 400). Instance history returns 404 only when the
  result is empty *and* unfiltered (an existing resource always has >= 1
  version), so a `_since` that excludes everything still yields an empty Bundle.
- vread.rs: calls VersionedStorage::vread, mirrors the read handler response
  (ETag, Content-Type with fhirVersion), and 404s an unknown version.
- composite/storage.rs: CompositeStorage only delegated up to
  InstanceHistoryProvider. Add a DynSystemHistoryProvider field, implement
  TypeHistoryProvider + SystemHistoryProvider (delegating to the primary), and
  raise the with_full_primary bound so type/system history work on the
  -elasticsearch composite variants.
- Raise router (fhir_routes.rs) and app-builder (lib.rs) trait bounds to require
  TypeHistoryProvider + SystemHistoryProvider. All four base backends already
  implement these; CompositeStorage now does too.

Tests: add `mod history_reads` to rest_conformance.rs (8 tests) covering
instance/type/system history, _count, malformed _since, vread of specific
versions, and not-found cases.
@smunini smunini merged commit 16e57a7 into main Jun 2, 2026
17 checks passed
@smunini smunini deleted the feat/history-read-endpoints branch June 3, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant