By: Amos (Kippi) Bordowitz
FHIR Dependencies
All FHIR® projects require certain dependencies. The basic one is a dependency on the basic HL7® FHIR® package, whichever FHIR version you are working with. Thankfully, if that is all you require, there is no need to do anything: whatever your environment is, this dependency is automatically handled.
In this article we will discuss two environments in which you might find yourself requiring other dependencies: Simplifier and SUSHI (if you are working with FHIR Shorthand - FSH). Together, we will explore how to go about creating dependencies in these environments.
Dependencies are important because they allow you to make sure the files that you are dependent on are always up to date, while making it unnecessary to actually add those files to your project, keeping it as lean as it can and should be, without extra clutter. It also looks more professional, which is a bonus.
FHIR® dependencies are usually package specific. It is important to know exactly which project contains the files your project will require.
Simplifier:
Most FHIR projects around the world are hosted on Simplifier.net. Simplifier is a great site on which to host and display all your FHIR resources. If you wish to add a dependency, you will first go to the project you wish to add the dependency to. Then you will head to the “Dependencies” tab. If you haven’t done so yet, you will be required to add a Package.json.
- If you feel confident editing the package.json file (otherwise, skip to the next section), the fastest way to add dependency is by doing the following:
you will click on the arrow next to the “Manage” button, and then on “Edit package.json (advanced)”
Once inside, you can edit any information pertaining to the package, including the dependencies. At first, this is what will be automatically populated in the file:
{
"dependencies": {
"hl7.fhir.r4.core": "4.0.1"
},
"fhirVersions": [
"4.0.1"
]
}
If we want add the US-Core package, version 4.1.0 as a dependency, this is what it would look like:
{
"dependencies": {
"hl7.fhir.us.core": "4.1.0",
"hl7.fhir.r4.core": "4.0.1"
},
"fhirVersions": [
"4.0.1"
]
}
Click on the blue “Save” button and this is what you will see (the extra dependencies are automatically added):
- If you know the package name but but are hesitant to manually change the package.json file, click on Manage. You will then see the following screen:
This screen allows you to look for any package hosted on simplifier.net. Although it is also possible to search for it here, it is not intuitive, and you might not find what you are looking for. The best practice would be to first find the package by yourself by looking for the project and copying its name. Once you have it, you paste it in the Search box. Choose the package from the automatically produced drop box, then click Add.
The new dependency should appear in your project. Congratulations!
FSH:
Here’s how to add dependencies to your FSH-SUSHI projects.
First, you must edit your sushi-config.yaml file. Add the following:
dependencies:
<package name>: <package version>
For example:
dependencies:
il.core.fhir.r4: 0.6.0
Next, if you require snapshots from that package, there are two ways to achieve this.
1. Go to the package page in simplifier, click on Download -> Download snapshots. Once you’ve done this you will have a Tar.gz file. Create the dependency's folder in your FHIR cache. This means creating the following folder, depending on your system:
- Apple or linux: ~/.fhir/packages/
- Windows: c:users<username>.fhirpackages
The folder you want to create will be <package name>#<package version>. For example - il.core.fhir.r4#0.6.0. Extract the files to this folder.
If the folder already exists, just delete its contents and extract the files into it.
2. A better option would be to use the “firely” terminal and the bake command, as it automates the process. Run the command: fhir bake --package <packagename>, substituting the dependency package ID for <packagename>. E.g.:
fhir bake --package de.basisprofil.r4
If you do not have the firely terminal installed, please visit this link for information on how to get it.
We hope this helped you get your dependencies in order. Feel free to contact us with any questions regarding the process!
Follow us on LinkedIn and check out our academy page for information on courses and workshops!