This page is part of the FHIR Shorthand (v0.12.0: STU 1 Ballot 1) based on FHIR R4. The current version which supercedes this version is 2.0.0. For a full list of available versions, see the Directory of published versions
FHIR Shorthand (FSH) is a specially-designed language for defining the content of FHIR Implementation Guides (IGs). It is simple and compact, with tools to produce Fast Healthcare Interoperability Resources (FHIR) profiles, extensions and IGs. FSH is compiled from text files to FHIR artifacts using SUSHI. To get started using FSH, you need to install and run SUSHI using the steps below.
Platform notes:
Symbol | Explanation |
---|---|
đ» | Indicates information or command specific to Windows. A command window can be launched by typing cmd at the Search Windows tool. |
đ | Indicates information or command specific to OS X. Commands can be run within the Terminal application. |
$ | Represents command prompt (may vary depending on platform) |
SUSHI requires Node.js. To install Node.js, go to https://nodejs.org/ and you should see links to download an installer for your operating system. Download the installer for the LTS version. If you do not see a download appropriate for your operating system, click the âother downloadsâ link and look there. Once the installer is downloaded, run the installer. It is fine to select default options during installation.
Ensure that Node.js is correctly installed by opening a command window and typing the following two commands. Each command should return a version number.
$ node --version
$ npm --version
To install SUSHI, return to the command prompt, and issue this command:
$ npm install -g fsh-sushi
Check the installation by typing the following command:
$ sushi -h
If the command outputs instructions on using SUSHI command line interface (CLI), youâre ready to run SUSHI.
To start with some working examples of FSH files and a skeleton FSH tank, download the fsh-tutorial-master.zip file and unzip it into a directory of your choice. The zip file is also available from the Downloads menus, directly above.
After the file is unzipped, you should see two subdirectories:
Change the working directory to FishExample. There are two FSH files:
In addition, there is a package.json file and a subdirectory, /ig-data, containing some inputs for building the IG.
Now that you have SUSHI installed and a minimal FSH tank, open up a command window, and navigate to the FishExample directory. Run SUSHI on those FSH files by executing:
$ sushi .
Note: The dot (.) represents âthis directory,â the location of the FSH files. You can also specify the location explicitly by replacing the dot with a directory path.
Running SUSHI will create a FishExample/build/input/resources directory, and populate it with the files needed to create the IG using the HL7 FHIR IG Publisher tool.
While running SUSHI, there will be a series of informational message. When SUSHI completes, you should see a summary output similar this:
info
Profiles: 2
Extensions: 0
Instances: 0
ValueSets: 0
CodeSystems: 0
Errors: 0
Warnings: 0
The files generated by SUSHI are located in the FishExample/build directory. Check that the build/input/profiles subdirectory contains two generated structure definitions.
Now change working directory of the command window to the build directory. At the command prompt, enter:
đ» $ _updatePublisher
đ $ ./_updatePublisher.sh
This will download the latest version of the HL7 FHIR IG Publisher tool into ./build/input-cache. This step can be skipped if you already have run the command recently, and have the latest version of the IG Publisher tool.
Note: If you have never run the IG Publisher, you may need to install Jekyll first. See Installing the IG Publisher for details.
Note: If you are blocked by a firewall, or if for any reason
_updatePublisher
fails to execute, download the current IG Publisher jar file here. When the file has downloaded, move it into the directory /FishExample/build/input-cache (create the directory if necessary.)
Now run:
đ» $ _genonce
đ $ ./_genonce.sh
This will run the HL7 FHIR IG generator, which may take several minutes to complete.
After the publisher is finished, open the file /FishExample/build/output/index.html to see the resulting IG.
If you click on the Artifacts Summary item in the menu, you will see that the IG contains two profiles, FishPatient and Veterinarian. If you look at each of them, you will notice that they have minimal differentials. The only way in which they differ from their base resource is that they require at least one name.
It is not widely known, but FHIR is designed to be used for veterinary medicine as well as human. For a non-human patient, we need to record the species. The Patients in this Tutorial are going to be various species of fish đ.
Since fish donât get legally married (although some species do pair bond) and they donât communicate in a human language, the first thing weâll do in the FishPatient profile is eliminate these elements. To do this, open the file FishPatient.fsh in your favorite plain-text editor, and add the following rules after the last non-blank line in the file:
* maritalStatus 0..0
* communication 0..0
Note that rules start with *
. FSH expresses cardinality as, {min}..{max}
, the same as FHIR.
To specify the species of our aquatic patients, weâll need an extension.
We have a choice of whether to make the extension inline or standalone. Inline extensions do not result in a separate StructureDefinition, and cannot be reused in other profiles. Standalone extensions are the opposite: they have independent StructureDefinitions, and can be reused. For this example, letâs make a standalone extension.
Extensions are created using the contains
keyword. To add a standalone species extension, add the following rule after the cardinality rules:
* extension contains FishSpecies named species 0..1
Note: You must be running SUSHI version 0.10.0 or higher for this to not generate a parsing error
This rule states that the extension
array of the Patient resource will incorporate the FishSpecies
extension with the local name species
.
To define the FishSpecies
extension, add the following lines to the end of the FishPatient.fsh file:
Extension: FishSpecies
Id: fish-species
Title: "Fish Species"
Description: "The species of the fish."
NOTE: FSH ignores extra whitespace, so authors can choose to use whitespace for improved visual alignment, as in the extension definition above.
Run SUSHI again ($ sushi .
). The count of Extensions should now be 1.
The FishSpecies extension doesnât quite do its job yet, because we havenât specified what type of values it might accept. To add this information, enter these lines following the description of FishSpecies:
* value[x] only CodeableConcept
* valueCodeableConcept from FishSpeciesValueSet (extensible)
The first rule restricts the value[x] (a built-in element of every FHIR extension) to a CodeableConcept using the only
keyword. The second binds it to a value set (yet to be defined) using the from
keyword. The binding strength will be extensible
.
To define FishSpeciesValueSet, add the following lines to the same file:
ValueSet: FishSpeciesValueSet
Title: "Fish Species Value Set"
Id: fish-species-value-set
Description: "Codes describing various species of fish, taken from SNOMED-CT."
* codes from system http://snomed.info/sct where concept is-a SCT#90580008 "Fish (organism)"
The rule in the value set definition selects all codes from SNOMED-CT that are children of the concept âFish (organism)â.
Run SUSHI again. The count of ValueSets should now be 1. Try generating the IG by changing directories to build and running _genonce
again. Open the file /FishExample/build/output/index.html to see the resulting IG.
An Alias
is a way to define a shorthand for a URL or OID. For example, in the extension definition above, we could have defined an Alias
to make referencing the http://snomed.info/sct
URL easier, as shown below. Aliases are conventionally defined at the top of the file.
Add this line at the top of the FishPatient.fsh file:
Alias: SCT = http://snomed.info/sct
and then replace the last line with:
* codes from system SCT where concept is-a #90580008 "Fish (organism)"
Using aliases has no effect on the IG; it simply makes the FSH code a bit neater.
Every IG should provide examples of its profiles. We should provide an example instance of FishPatient. Our patient example is Shorty. Create this example instance using the Instance
keyword, with InstanceOf
set to FishPatient
and Usage
set to Example
.
Include the following information about Shorty in the instance:
If you need help with this, you can reference the Defining Instances section of the specification. If you still need help, you can peek at the FSH files in the FishExampleComplete directory.
Run SUSHI again, and re-generate the IG.
Now, add constraints and/or extensions to the Veterinarian profile:
Add qualifications consistent with a Veterinary practice. Qualifications are taken from code system http://hl7.org/fhir/sid/ca-hc-npn, and the code is 174MM1900N âOther Service Providers; Veterinarian; Medical Researchâ.
In addition, slice the identifier
array, making a license number required. The code system is http://terminology.hl7.org/CodeSystem/v2-0203 and the code is LN, for âLicense numberâ.
If you need help with this, you can reference the Fixed Value Rules and Slicing Rules sections of the specification. If you still need help, you can peek at the FSH files in the FishExampleComplete directory.
Run SUSHI again, and re-generate the IG.
Congratulations! Youâve completed the FSH tutorial. It might be time to feast on some sushi!