Create FHIR Package
The create-package
command assembles FHIR resources into an NPM package following the FHIR NPM Package Spec. This specification is used to create packages that can be loaded into the Smile CDR Package Registry. Packages can also be used to supply Pre-Seed Resources to be automatically installed into a FHIR Repository.
The generated package will be in the format [packageName]-[packageVersion].tgz
and contain:
package/
folder with all resources specified via --include-package
example/
folder with all resources specified via --include-example
package.json
manifest file containing metadata including:
--dependency
bin/smileutil create-package --fhir-version R4 --name com.example.ig --version 1.0.1 --include-package "/path/to/resources/*.json"
In the example above, a package is being created with the name com.example.ig
and the version 1.0.1
. The package includes all files matching path /path/to/resources/*.json
. Note that we enclose the path in quotes so that the command-line tool will correctly handle the wildcard (i.e. *
).
--fhir-version [version]
– This is the FHIR version that will be stored as metadata in the package manifest. Valid values include DSTU3, R4, R5, etc.--name [package name]
– This is the NPM name for the package. In NPM packages, the name is used as a unique identifier and should be machine processable. By convension, reverse domain name style is used.--version [version]
– The version for the package. FHIR Packages use SemVer versioning.--include-package [pathspec]
– (optional/repeating) If set, this option specifies a path specification for resources to include in the package folder. This argument may be repeated to specify multiple paths. The path can include wildcard patterns supported by the Java WildcardFileFilter, such as *.json
, *-profile.json
, etc.--include-example [pathspec]
– (optional/repeating) If set, this option specifies a path specification for resources to include in the example folder. Example resources are included in the package but will not be made accessible to the validator when the package is installed. This argument may be repeated to specify multiple paths. The path can include wildcard patterns supported by the Java WildcardFileFilter, such as *.json
, *-example.json
, etc.--dependency [name:version]
– (optional/repeating) If set, this option specified the Package Name and Version of a package that the package being created is dependant on. Specifying dependencies adds them as an entry in the package manifest. The value should be in the form name:version
.This section will show how to create a package from start to finish. This package will include one Organization resource.
Create a folder called resources
inside of your smilecdr folder. Note that this does not need to be in this particular location, and is only chosen for convenience.
cd smilecdr/
mkdir -p resources/
in that folder, create a file called organization.json
with the following contents:
{
"resourceType": "Organization",
"id": "my-special-organization",
"identifier": [ {
"system": "www.mysystem.gov/identifiers",
"value": "im-an-identifier!"
} ]
}
At this point, your structure should look like this:
├── resources
├── organization.json
bin/smileutil create-package --fhir-version R4 --name com.example.ig --version 1.0.0 --include-package "./resources/*.json"
You will now see that a file called com.example.ig-1.0.0.tgz
has been created. This is the package, which is now ready for ingestion into Smile CDR.
The first way to get this package into Smile CDR is by using pre-seeding. To pre-seed a package, we need to write up a package installation spec file, and then set that filename as the value of the Package Pre-Seed Installation Spec Files property.
Create a file called package-spec.json
and place it in the smilecdr/config_seeding
directory.
{
"name" : "com.example.my-resources",
"version" : "1.0",
"packageUrl" : "classpath:/com.example.ig-1.0.0.tgz",
"installMode" : "STORE_AND_INSTALL",
"installResourceTypes" : [ "Organization" ],
"reloadExisting" : true,
"fetchDependencies" : false
}
Then, in your properties file (or in the web admin console), set the following configuration in the Persistence module:
module.[MODULE_ID].config.package_registry.startup_installation_specs = classpath:/config_seeding/package-spec.json
The other way to load a package into SmileCDR is by using the Package Registry module's endpoints. Specifically, we can install this package by calling the Install By Spec operation. See the documentation there for example invocations.
You are about to leave the Smile Digital Health documentation and navigate to the Open Source HAPI-FHIR Documentation.