This specification defines how FHIR canonical resources and packages are:
- Authored (i.e., created and maintained in Implementation Guides (IGs))
- Assembled (Configured) into final systems by users
- Executed (Runtime) to provide functionality
It focuses on versioning, dependency resolution, canonical references, and package management to ensure consistency, maintainability, and clarity in the ecosystem of FHIR artifacts.
-
Canonical Resource
A FHIR resource with aurl
(canonical URL) andversion
element. Examples:StructureDefinition
,ValueSet
,CodeSystem
,ConceptMap
. -
Canonical URL
The unique, resolvable (or at least logically unique) URI for a resource; typically used as a global identifier. -
Versioning
- Exact version:
MAJOR.MINOR.PATCH
(e.g.,3.1.0
). - Partial/Range version: A constraint allowing multiple versions, e.g.,
3.1.*
,3.*
, or none (*
).
- Exact version:
-
Packages
Bundles of FHIR resources that follow Semantic Versioning (semver). Each package may declare dependencies on other packages. -
Phases
- Authoring: Creating IGs and resources.
- Configuration (Assembling): Combining multiple packages or unpackaged resources into a final system.
- Runtime: Executing or interpreting resources (e.g., validating data, expanding terminologies).
-
End User / Administrator
The actor responsible for assembling final systems and resolving conflicts (e.g., version clashes, overlapping definitions).
Purpose
- Develop reusable FHIR Implementation Guides (IGs).
- Ensure references and version constraints are clear and compatible.
Scope
- Authors produce resources that reference each other and external dependencies.
- Authors decide how strictly or loosely to version dependencies.
Primary Tasks
- Create or Update Canonical Resources: Define or refine
StructureDefinition
,ValueSet
, etc. - Declare Dependencies: Reference external resources or packages, specifying version constraints.
- Ensure Compatibility: Strive for backward/forward compatibility via semver.
- Release: Publish a new package version with properly incremented
MAJOR.MINOR.PATCH
.
Outputs
- A package (or IG) containing canonical resources, plus a manifest of dependencies and recommended version constraints.
Purpose
- Combine multiple packages and possibly unpackaged resources into a coherent final system.
Scope
- The user or administrator decides which package versions to include, resolves any conflicts, and overrides any references as needed.
Primary Tasks
- Collect Packages/Resources: Gather all dependencies, possibly from various repositories.
- Resolve Versions: Apply version constraints (exact, partial, unversioned) to obtain a consistent set of canonical resources.
- Handle Conflicts: Detect duplicates, select a preferred version, or override references if necessary.
- Produce Final Artifact: A single, consistent environment (could be a folder, server, or knowledge base) with resolved resources.
Outputs
- Final set of canonical resources with fully resolved versions and references.
- Configuration logs or metadata describing how conflicts and overrides were resolved.
Purpose
- Execute or interpret the assembled FHIR canonicals for validation, terminology expansion, data exchange, etc.
Scope
- Canonical resources are accessible in a global namespace.
- Runtime systems typically do not need to know about packages—only canonical URLs and resolved versions.
Primary Tasks
- Interpret Canonical Resources: e.g., validate incoming data against
StructureDefinition
. - Reference Resolution: If a resource references
<URL>|x.y.z
, the runtime uses that specific version or, if unversioned, a “latest” or configured version. - Optional Dynamic Re-configuration: Some systems may allow loading or switching versions on the fly.
Outputs
- Executed or interpreted behavior (e.g., validation results, expansions).
- Potential log messages indicating unresolvable references (if a resource is missing).
-
Exact Version Reference:
<url>|3.1.0
- Locks to a specific version.
- Changes require explicit upgrade by the user.
-
Partial Version Reference:
<url>|3.1.*
,<url>|3.*
, or<url>|*
- Allows a version range.
- System resolves to the “latest” matching version.
-
Unversioned (Implied
|*
):<url>
- Commonly used to reference general resources (e.g., external code systems like SNOMED).
- System picks the latest available version.
- Strict: For critical dependencies, authors may choose exact versions to avoid unexpected changes.
- Flexible: For code systems or minor references, authors can use partial/unversioned references for up-to-date expansions.
- Placeholders:
"reference": "http://example.org/fhir/StructureDefinition/Patient|@"
- A build tool replaces
|@
with a chosen semver range (e.g.,|1.2.*
) at build time.
- A build tool replaces
A package is a named library of FHIR resources with a package.json
-like manifest. It includes:
- Name
- Version (MAJOR.MINOR.PATCH)
- Dependencies (with version ranges)
- List of Canonical Resources
- Authoring: IG authors publish or update packages when new or revised resources are available.
- Configuration: Users fetch or install packages, resolving dependencies.
- Runtime: Packages effectively “disappear.” Only resolved resources remain relevant.
- Exact Version:
[email protected]
- Partial Version:
[email protected].*
- Wildcard:
fhir.core.r4@*
Resolution: The system fetches the highest available version that fits a partial or wildcard constraint; exact references remain pinned.
Problem: Two or more packages may contain the same canonical URL and version, or slightly different versions of the same resource.
Recommendations:
- Single Authoritative Source: Ideally, one canonical belongs to exactly one package.
- Automatic Comparison: Systems can compare duplicates:
- If they are identical, keep one copy.
- If they differ, warn the user to select which version is “preferred.”
- User Override: If conflict remains unresolved, the final user decision prevails.
Scenario: A package references a canonical that is not in its declared dependencies.
- Warn: The build or configuration tool notifies the author/user.
- User Action: They may add or fix a dependency, or override the missing reference with a known local resource.
Definition: Breaking changes occur when a canonical resource changes in an incompatible way (e.g., removing required elements, constraints, or entire resources).
- Recommendation: Increment the MAJOR version per semver rules.
- Configuration Tools: Must alert users that a major upgrade may break existing references.
Overview: Semver uses MAJOR.MINOR.PATCH
:
- MAJOR: Incompatible or breaking changes (or new resources that break older assumptions).
- MINOR: Backward-compatible additions (e.g., new extensions or resources).
- PATCH: Backward-compatible bug fixes or minor enhancements.
Example progression: 1.0.0 → 1.0.1 → 1.1.0 → 2.0.0
Optionally, authors may add:
- Pre-release:
1.2.3-alpha
- Build Metadata:
1.2.3+20230201
Use these to indicate unstable releases or internal builds.
- Package authors cannot anticipate all contexts.
- Administrators may have system-wide constraints or specialized local resources.
- Package Version Override: Force a newer (or older) version if needed.
- Canonical Resource Override: Replace a resource from the package with a local variant (a “monkey patch”).
- Reference Override: Change a reference from
|3.1.*
to a pinned|3.1.2
or vice versa.
- Systems should log overrides to allow transparency and repeatable builds.
- Tools should warn administrators to revisit overrides at each package update.
-
Consistent Use of Semver
- Increment MAJOR for truly breaking changes.
- Keep patch increments for smaller fixes.
-
Clear Reference Types
- Use partial versions only when it is safe to retrieve the “latest.”
- Use pinned versions for critical dependencies.
-
Avoid Duplicate Canonicals
- Maintain a single canonical resource in one package.
- If multiple packages provide the same resource, unify them or coordinate with authors.
-
Validate References Early
- Automated tools to check that all referenced canonicals exist in the declared dependencies.
-
Leverage Tooling
- Use build tools (e.g., FHIR publisher, custom scripts) to inject version placeholders, detect duplicates, and generate warnings.
-
User-Centric Conflict Resolution
- Provide an interface or script to let users pick the “preferred” version in a conflict.
- Log final decisions.
- Initialize Package:
[email protected]
- Declare Dependencies:
{ "dependencies": { "fhir.core.r4": "4.0.*", "hl7.fhir.us.core": "3.*" } }
- Create Resources:
StructureDefinition/my-pediatrics-patient
, referencing:http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient|*
- Release: Publish
1.0.0
.
- Fetch Packages:
[email protected]
[email protected]
(matches3.*
)[email protected]
(matches4.0.*
)
- Detect Conflicts: Suppose
[email protected]
also references[email protected]
. - Resolve: The system tries to pick
[email protected]
if it satisfies3.*
. - User Override (Optional): If
[email protected]
specifically pinned3.1.0
, user must decide to:- Force
3.1.0
, or - Switch to
3.2.0
.
- Force
- Deploy: The final set includes:
- Load: The final system has a global store of canonical resources from above.
- Evaluate: A new
Patient
instance is validated againstmy-pediatrics-patient
→ which referencesus-core-patient|3.2.0
(latest in store). - Dynamic Update: Administrator decides to bring in
[email protected]
next month:- The system sees partial references
3.*
and automatically updates references to3.3.0
if approved.
- The system sees partial references
This specification outlines a unified approach to authoring, configuring, and running FHIR canonical resources and packages. By consistently applying semantic versioning, carefully managing dependencies and references, and enabling the end user to resolve conflicts, the FHIR ecosystem can maintain compatibility, reuse, and clarity over time.
- Major Goals: Avoid version conflicts, duplicates, and silent breakages.
- Core Principle: The final user has ultimate control (overrides) while authors provide best-practice constraints.
- Semver: Strictly followed for stable and predictable upgrades.
- Tools: Rely on build/configuration systems to detect warnings and manage references automatically.
End of Specification