Skip to content

maki gofsh

Convert FHIR resources (JSON/XML) back to FSH (GoFSH functionality).

Terminal window
maki gofsh [OPTIONS] <INPUT>
  • --output, -o <PATH> - Output directory for FSH files (default: output)
  • --fhir-version <VERSION> - FHIR version: R4 or R5 (default: R4)
  • --dependency, -d <PKG> - FHIR package dependencies (e.g., hl7.fhir.us.core@5.0.1)
  • --strategy <STRATEGY> - File organization strategy:
    • file - One file per definition (default)
    • type - Group by FSH type (profiles.fsh, valuesets.fsh, etc.)
    • profile - Group by profile
    • single - All definitions in one file
  • --indent-size <N> - Number of spaces for indentation (default: 2)
  • --line-width <N> - Maximum line width (default: 100)
  • --progress - Show progress bar and detailed output
Terminal window
# Convert FHIR resources in a directory
maki gofsh ./fsh-generated
# Specify output directory
maki gofsh ./fsh-generated -o ./input/fsh
# With FHIR dependencies
maki gofsh ./resources -d hl7.fhir.us.core@5.0.1
# Use R5 FHIR version
maki gofsh ./resources --fhir-version R5
# With progress reporting
maki gofsh ./resources --progress
# Group output by FSH type
maki gofsh ./resources --strategy type
# All in one file
maki gofsh ./resources --strategy single
  1. Setup Packages - Installs base FHIR packages and dependencies
  2. Load Resources - Reads FHIR JSON/XML files from input
  3. Process Resources - Extracts FSH definitions:
    • StructureDefinitions → Profiles, Extensions, Logical Models
    • ValueSets → ValueSet definitions
    • CodeSystems → CodeSystem definitions
    • Other resources → Instance definitions
  4. Optimize - Applies rule optimizations:
    • Remove duplicate rules
    • Combine related rules
    • Simplify cardinality expressions
    • Remove implied/redundant rules
  5. Write FSH - Generates formatted FSH files
  6. Generate Config - Creates sushi-config.yaml and .makirc.json

With --strategy file (default):

output/
├── MyProfile.fsh
├── MyExtension.fsh
├── MyValueSet.fsh
├── sushi-config.yaml
└── .makirc.json

With --strategy type:

output/
├── profiles.fsh
├── extensions.fsh
├── valuesets.fsh
├── codesystems.fsh
├── instances.fsh
├── sushi-config.yaml
└── .makirc.json

The following FHIR resource types are converted to FSH:

FHIR ResourceFSH Definition
StructureDefinition (constraint)Profile
StructureDefinition (extension)Extension
StructureDefinition (logical)Logical
StructureDefinition (resource)Resource
ValueSetValueSet
CodeSystemCodeSystem
Other resourcesInstance
  • Complex slicing patterns may not be fully reconstructed
  • Some inline extensions may be expanded unnecessarily
  • Mapping definitions are partially supported
  • Invariants with complex FHIRPath may need manual review