Skip to main content

Implementation Features

Spec: FHIR Versioning, Version-aware Updates

Version Management

Sequential Integer Versions

Ferrum uses sequential integer versions starting at 1 for each resource:

Version Lifecycle

Each CRUD operation affects versioning differently:

Database Storage

Ferrum stores versions in two tables:
  • resources: All resource versions with metadata
  • resource_versions: Version counter per resource

Versioned Read (vread)

Spec: vread Read a specific version of a resource:

Response Behavior

Successful vread (200 OK):
Version not found (404 Not Found):
Deleted version (410 Gone):

HEAD Support

Check version existence without fetching body:

Caching Headers

vread responses include immutable caching headers since versions never change:

History Operations

Instance History

Spec: Instance History Get all versions of a specific resource:
Response (Bundle with type=“history”):

Type History

Get history for all resources of a specific type:

System History

Get history across all resource types:

History Parameters

All history endpoints support standard parameters:

History Entry Methods

Ferrum automatically determines the HTTP method for each history entry:

Version-Aware Operations

Optimistic Locking with If-Match

Spec: Version-aware Updates Always use If-Match for safe updates:

Version Conflict Handling

Successful update (200 OK):
Version conflict (412 Precondition Failed):

Recovery from Conflicts

When version conflicts occur:
  1. Refetch the current version
  2. Merge your changes with current state
  3. Retry with new version

Delete and History

Soft Delete (Default)

With soft delete (hard_delete: false):
Behavior:
  • Creates new version marked as deleted
  • History remains accessible
  • GET /Patient/123410 Gone
  • GET /Patient/123/_history200 OK (full history)
  • GET /Patient/123/_history/3410 Gone (deletion version)

Hard Delete

With hard delete (hard_delete: true):
Behavior:
  • Physically removes all versions from database
  • History becomes inaccessible
  • GET /Patient/123404 Not Found
  • GET /Patient/123/_history404 Not Found
  • Enables history deletion endpoints

History Deletion (Hard Delete Only)

When hard delete is enabled, you can delete specific versions or entire history:
Irreversible Operation: Hard delete permanently removes all data and history. This cannot be undone. Use with extreme caution in production.

History Bundles (Replication)

Spec: Bundle.type=history Ferrum supports history bundle replication for data synchronization:

History Bundle Processing

Ferrum processes history bundles with these rules:
  1. Sequential Processing: Entries processed in order (not atomic)
  2. ID Preservation: Resource IDs preserved from bundle
  3. Version Checking: Older/duplicate versions ignored
  4. Create or Update: Creates if resource doesn’t exist, updates if newer
  5. Delete Handling: Entries with response.status="410 Gone" trigger deletion

Version Conflict Resolution

Performance Considerations

Indexing Strategy

Ferrum indexes key version-related columns:

History Query Optimization

For large history sets, use pagination:

Version Cleanup

Configure version limits to manage storage:
Version Cleanup: When enabled, Ferrum automatically removes old versions beyond the configured limit, keeping the most recent versions.

Configuration

Key configuration options for versioning and history:

Error Handling

Common versioning-related errors:

Error Response Examples

Version not found:
Version conflict:

Testing Your Implementation

Use the interactive API playground to test versioning operations:

Versioned Read

Test vread operations

Instance History

Browse resource history

Type History

Query type-level history

System History

Access system-wide history

Next Steps

CRUD Operations

Learn about create, read, update, delete

Search Operations

Query resources efficiently

Batch & Transaction

Perform multiple operations atomically

Configuration

Configure versioning behavior