View raw Markdown
type: docsource: source/packages.html

[%settitle Directory of all Versions of FHIR%] [%file newheader%] [%file newnavbar%]

FHIR NPM Packages

Responsible Owner: [[%wgt fhir%]]([%wg fhir%]) Work GroupStandards Status:Normative

FHIR Specifications are published in HTML format for human consumption, and as NPM packages for machine consumption.

Some important packages for FHIR Implementers:

FHIR NPM Package Structure

Each FHIR package is a tarball (tar in gzip) that contains a package folder that contains:

Packages may contain additional folders below the package folder and files but their use is not defined by this specification.

Note that this specification is published as a package, and each Implementation Guide is published as a package, but this is not the only use for package, and other packages exist.

Package composition

In theory, packages can contain an unlimited number of artifacts with unlimited size. However, in practice, real-world tools will struggle or even fail if packages are too large. Authors should consider this when deciding how they package. Ways to help manage this issue include:

NPM FHIR Packages SHOULD contain an ImplementationGuide resource with the url: {package-canonical}/ImplementationGuide/{packageId} and the version to match the package version.

It is reasonable for tooling to resolve a canonical reference to an implementation guide resource as the NPM FHIR Package matching that definition (e.g., per the dependsOn element of the implementation guide.

package.json

The format of the package.json file is defined by the NPM Package Specification. This specification makes some rules about use of the properties as defined in the NPM specification, and defines some additional FHIR specific properties.

namerequiredEach package SHALL have globally unique identifier for the package in the NPM System. A package name consists of two or more namespaces separated by a dot. Each namespace starts with a lowercase alphabet character followed by zero-or-more lowercase alphanumeric characters or dashes. The first part of the namespace should identify the publisher for the package. <br/> Note: HL7 manages all the packages that start with hl7.
versionrequiredAll packages SHALL have a version that conforms to Semantic Versioning. See FHIR Versioning for how semantic versioning works with standards.
dependenciesrequiredAny dependencies SHALL be listed here - that is, any other package that contains resources referred to by the resources in the package.

Packages SHOULD be referred to by the whole package version number and not use wildcards, except for the patch version in a SemVer version reference. The x in the following example means that a package resolver should accept the package with the highest found patch number: "dependencies": { "hl7.fhir.r6.core": "6.0.x" }

A dependency on a core package is required, and this dependency defines the FHIR version used to resolve the contents of this dependency tree. If multiple core package dependencies are listed, the first instance is the version used.

Development packages may use a local path for the package version (see Local Paths in the NPM documentation) | | author | required | Each package SHALL contain the name of the author - an individual or organization who created and/or published the pacakge | | description | required | Each package SHALL have a human language description of the contents of the package | | canonical | conditionally required | The canonical URL for the Implementation guide represented by the package, if this package represents a single Implementation Guide. This SHALL be present if the package is for an Implementation Guide and is optional for other packages. | | url | recommended | The URL at which the specification that the package represents may be found | | type | recommended | The type of resources that the package contains. The type may be one of the following values:

This value is provided to help users find and choose the correct package; it has no meaning to tools using the packages. | | jurisdiction | optional | A URL with the syntax {system}#{code}, from the Jurisdiction ValueSet. This value is provided to help users find the right package in the package registry | | languages | optional | An array of strings, where each value is an IETF language code from AllLanguages ValueSet, and indicates that the package contains content suitable for the specified language | | fhirVersions | optional | An array of the FHIR Versions used by the package. Most packages only use one version. In some older packages, this was named fhir-version-list. The value of this property can be determined by inspecting the package |

Note: bolded items are introduced by this specification, while other items are those defined by NPM itself.

Example Package File

This is the package.json file to the US Core Implementation Guide.

{ "name": "hl7.fhir.us.core", "version": "5.0.1", "type": "IG", "date": "20220622194452", "license": "CC0-1.0", "canonical": "http://hl7.org/fhir/us/core", "url": "http://hl7.org/fhir/us/core/STU5.0.1", "title": "US Core Implementation Guide", "description": "The US Core Implementation Guide...", "dependencies": { "hl7.fhir.r4.core": "4.0.1", "hl7.terminology.r4": "3.1.0", "hl7.fhir.uv.bulkdata": "2.0.0", "hl7.fhir.uv.smart-app-launch": "2.0.0", "us.nlm.vsac": "0.7.0", "hl7.fhir.uv.sdc": "3.0.0" }, "author": "HL7 International - Cross-Group Projects", "jurisdiction": "urn:iso:std:iso:3166#US" }

.index.json

This optional file contains information from the resources in the package folder. The intention of this file is to save tools from loading every resource in the package; they can read the .index.json file and know what resources are in the package and load only the ones they need.

Note that there is no independent information in the .index.json file; all the information is derived from the resources, and tools can rebuild it at any time (or built it and add it if it is not present).

{ "index-version": 2, "files": [ ] }

The index version is a fixed value that may change if this file format is changed. Tools should rebuild the file if they do not recognize the version. The files array contains an object for each resource in the package with the following properties:

These properties are populated if there is a string property with the same name in the resource identified by the filename, irrespective of resource type.

FHIR Package Composition

In theory, packages can contain an unlimited number of artifacts with unlimited size. However, in practice, real-world tools will struggle or even fail if packages are too large. Authors should consider this when deciding how they create packages. Ways to help manage this issue include:

FHIR Package Caching

For user convenience, tools may choose to use a common local cache.

FHIR NPM Package Registry

The FHIR packages are all hosted on the registry http://packages.fhir.org. Users can search for packages and download them manually, but the main users of the registry are tools that access the registry using the package API. A secondary package registry may be found at http://packages2.fhir.org.

To load a package onto the package servers:

[%file newfooter%]