How to create FHIR npm package
In this tutorial, you will learn how to create a FHIR NPM package and import it into Aidbox.
A FHIR package groups a coherent collection of conformance resources, like StructureDefinitions, SearchParameters, etc., into an easily distributed NPM package.
1. Create a new package folder
Create a new folder for the package.
mkdir -p package
2. Prepare the package manifest file
To start, we need to describe the package manifest file for our NPM package. A package manifest is a JSON file called package.json.
3. Write Package Content
A package contains a set of FHIR resources in the JSON format. Let's describe a few resources for the package.
3.1 StructureDefinition resource
Let's describe a profile of the US Core Patient in the file my-patient-profile.json.
We have described a profile that inherits from the US Core Patient and adds a required field for address.
3.2 SearchParameter resource
Let's describe a custom search parameter on the Patient resource in the file my-patient-search.json.
3.3 Create .index.json file
The .index.json contains information from the resources in the package folder.
{
"index-version": 2,
"files": [
{
"filename": "my-patient-profile.json",
"resourceType": "StructureDefinition",
"url": "http://custom-url/my-patient-profile",
"kind": "resource",
"type": "Patient",
"derivation": "constraint"
},
{
"filename": "my-patient-search.json",
"resourceType": "SearchParameter",
"url": "http://hl7.org/fhir/SearchParameter/Patient-myname"
}
]
}
4. Build NPM package
The resulting npm package has the following structure:
package
├── .index.json
├── my-patient-profile.json
├── my-patient-search.json
└── package.json
We need to build the artifacts of the npm package into an archive in the TAR (.tar.gz) format.
tar -czvf package.tar.gz package
Following the guide below, upload the archive to Aidbox.