Canonical Resource Management Infrastructure Implementation Guide
2.0.0-ballot - STU 2 - Ballot International flag

This page is part of the Canonical Resource Management Infrastructure Implementation Guide (v2.0.0-ballot: STU 2 Ballot) based on FHIR (HL7® FHIR® Standard) R4. This version is a pre-release. The current official version is 1.0.0. For a full list of available versions, see the Directory of published versions

Publishing and Downloading FHIR (NPM) Packages

Page standards status: Informative

Publishing packages: Authoring client system

An authoring client creates a tarball, and the either uses an npm client, or the NPM APIs to upload the package to a Knowledge Artifact Repository as follows:

1. Create a package tarball

This tarball must contain at least:

  • package.json
  • ImplementationGuide representing the package

And then additional FHIR Resources as part of the packagte.

NOTE: This is compatiable with the generated ./output/package.tgz generated by IGPublisher

2. Use NPM API to publish

A simple way is to use an npm client:

npm --registry=http://registry publish package.tgz

Or using the npm APIs directly:

PUT /{packageId}
Host: registry
Content-Type: application/json

{MULTILE-VERSION-PACKAGE-MANIFEST}

Where MULTILE-VERSION-PACKAGE-MANIFEST is the NPM form of a multiple-version package manifest:

{
    "_id": "packge.id",
    "name": "packge.id",
    "dist-tags": [ "current", "1.1" ],
    "versions": {
        "1.1": {
            "name": "package.id",
            "version": "1.1",
            // The rest of package.json from package.tgz
            "dist": {
                "integrity": "sha512-xxxx",
                "shasum" "4c4dxxxx",
                "tarball": "http://127.0.0.1/package.id-1.1.tgz"
            }
        }
    },
    "_attachments": {
        "package.id-1.1.tgz": {
            "content-type": "appliation/octet-stream",
            "data": "H4sIAHe" // Base64 encoded package.tgz
        }
    }
}

Publishing packages: Knowledge artifact repository server

The server keeps a copy of the multiple-version package manifest for each package, as shown in the previous section. Upon receiving the PUT request from the client, the server should create-or-append the published version to the multiple-version manifest, including the attachments.

NOTE: It might be convienent to extract, decode, and store the actual tarball data in the attachment in a blob store or file system. And a server MAY rewrite the tarball location in the versions section to match implementation details.

If the version of the package already exists, the sever returns error 422, otherwise the server returns 201.

Download packages: Authoring client system

A client system can use npm pack command to download a FHIR package from a Knowledge Artifact Repository:

npm --registry=http://registry pack package.id[@version]

A client system could also use the NPM APIs directly, as shown in the next section.

Download packages: Knowledge artifact repository server

To implement dowloading a NPM FHIR Package, the knowledge artifact repository must implement 3 endpoints:

  • GET http://regsitry/{packageId} => Multiple-version Pacakge Manifest
  • GET http://registry/{packageId}/{version} => Package Manifest (version specific)
  • GET http://registry/{tarball-location-from-package-manifest}.tgz => Package tarball