GoFSH Tutorial

An end-to-end tutorial showing how to run GoFSH using a sample set of FHIR resources

This tutorial will walk you through an example of using GoFSH to turn FHIR artifacts into FSH definitions. This tutorial assumes you have already installed GoFSH.

Step 1: Download Sample FHIR Artifacts

To start with some example FHIR artifacts, download the GoFSH Tutorial and unzip it into a directory of your choice.

After the file is unzipped, you should see two FHIR artifacts:

  • StructureDefinition-mcode-genetic-specimen.json
  • StructureDefinition-mcode-laterality.json

Step 2: Run GoFSH

Now that you have GoFSH installed and sample FHIR artifacts, open up a command window, and navigate to the directory containing the artifacts you downloaded. Run GoFSH on those files by executing:

 gofsh .

Running GoFSH will create a gofsh directory, and populate it with input/fsh, a directory containing several files which define the original input files. Within input/fsh, there will be two subdirectories, profiles and extensions. If you open up profiles/GeneticSpecimen.fsh, you should see a FSH definition for a Profile called “GeneticSpecimen”, and if you open up extensions/Laterality.fsh, you should see an Extension called “Laterality”.

Step 3: Run SUSHI (Optional)

Now that you have generated FSH definitions, you can run SUSHI on those definitions to recreate your original input to GoFSH. First, ensure you have SUSHI installed. Then, navigate the command line to the gofsh/ directory, and run:

 sushi build .

This command will run SUSHI on the contents of input/fsh, and generate the output of that FSH into a directory called fsh-generated/resources. You can then compare the output from running GoFSH and then SUSHI to the original StructureDefinition-mcode-genetic-specimen.json and StructureDefinition-mcode-laterality.json files.

Alternatively, you can automatically run SUSHI on the output of GoFSH using the -f option. The following command:

 gofsh . -f

will run SUSHI on the output of GoFSH, and generate a comparison file in gofsh/fshing-trip-comparison.html which displays differences between the original input, and the output of SUSHI.