SUSHI 0.11.1 contains the following enhancements and bug fixes:
- BREAKING CHANGE: Changes fixed value rules to enable usage of
(exactly)keyword (details below) (#218, #187) - Adds support for Mixins and RuleSets (details below)
- Adds support for Mappings (details below)
- Adds
Usagekeyword on Instances (details below) - Adds support for contained Instances (details below) (#224)
- Adds support for one sided cardinality statements (details below) (#258)
- Improves error reporting when applying rules to a sliced element which conflict with slices of that element (#227)
- Adds an optional
unitskeyword that has no effect, but can be used to clarify setting values and binding on quantity types:* {Quantity type} units = {system}#{code} "{display text}"(#246) - Adds support for setting standards status to "Normative", "Trial Use", or "Draft" using the
N,TU, andDflags, respectively - Updates the
updatePublisherandgenoncescripts based on the updates in the sample-ig: https://github.com/FHIR/sample-ig - Generates a path-history parameter when being run on an HL7 IG (#286)
- Logs an error if a Profile defines itself as its own Parent
- Fixes bug with adding slices of a primitive on an Instance
- Fixes bug with failing to find slices of slices
- Fixes bug that would cause an error when using
systemin a path (#274) - Fixes bug that caused
obeysto fail when applied toid(#298) - Fixes bug with local templates in ig.ini (#299)
- Fixes bug with line indentation on multiline strings (#306)
NOTE: We skipped directly to SUSHI 0.11.1 since a small bug was found and fixed in SUSHI 0.11.0 at the very end of the publishing process.
BREAKING CHANGE: New (exactly) keyword
In previous versions of SUSHI, a value was fixed on an element using either fixed[x] or pattern[x] depending on the type of the element. Primitive types were set using fixed[x] and complex types were set using pattern[x]. When a value is fixed using pattern[x], an Instance of that Profile must include at least the values indicated by pattern[x], but may contain additional values. When a value is fixed using fixed[x], an Instance of that Profile must include exactly the values indicated, and no additional values. Now, in SUSHI 0.11.1, all values will be fixed by default using pattern[x]. If users want to fix a value using fixed[x], they should use the (exactly) keyword, as shown below:
* {path} = {value} (exactly)
This change will not cause new errors when running SUSHI, but it could change the output of SUSHI. All primitive values that were previously being fixed by fixed[x] will now be set by pattern[x], unless the (exactly) keyword is added. The practical difference for primitives is that now, using pattern[x], instances are allowed to supply an id and/or extensions\ on the primitive values, whereas formerly this was not allowed since fixed[x]` was used. IG authors should consider this difference and check their fixed value rules to ensure they are fixing values as desired.
Mixins and RuleSets
A RuleSet is an entity that can be used in FSH to define a chunk of rules that can then be applied to Profiles, Extensions, or Instances. RuleSets are defined as follows:
RuleSet: {RuleSetName}
* {rule1}
* {rule2}
// More rules
The defined RuleSet can then be applied to a Profile, Extension, or Instance using the Mixins keyword:
Profile: MyPatientProfile
Parent: Patient
Mixins: {RuleSet1}, {RuleSet2}
All RuleSets are applied before applying rules from the Profile, Extension or Instance, in the order that they are listed. Rules from a RuleSet should be compatible with the item they are being mixed into, and errors will be thrown if this is not the case.
Mappings
A Mapping is an entity that can be used in FSH to map a Profile or Extension to another standard. Mapping definitions use the following keywords, which map to the FHIR StructureDefinition mapping properties as follows:
| FSH Mapping Keyword | FHIR Mapping Property |
|---|---|
| Mapping | n/a (provides unique name) |
| Source | n/a (name of the profile to apply this to) |
| Target | mapping.uri |
| Id | mapping.identity |
| Title | mapping.name |
| Description | mapping.comment |
Once a mapping is defined using these keywords, rules can be added to map individual elements using the syntax:
* {path} -> "{map}" "{comment}" {mime-type}
The "{comment}" and {mime-type} are optional. Each rule maps to the FHIR ElementDefinition mapping properties as follows:
| Mapping Rule Part | FHIR Mapping Property |
|---|---|
| {path} | n/a (selects element to apply mapping on) |
| "{map}" | mapping.map |
| "{comment}" | mapping.comment |
| {mime-type} | mapping.language |
An example of a mapping on USCorePatient to Argonaut is shown below:
Mapping: USCorePatientToArgonaut
Source: USCorePatient
Target: "http://unknown.org/Argonaut-DQ-DSTU2"
Title: "Argonaut DSTU2"
Description: "This is a mapping of US Core Patient to Argonaut"
Id: argonaut-dq-dstu2
* identifier -> "Patient.identifier" "optional comment" #optionalCode
* identifier.system -> "Patient.identifier.system"
Usage keyword on Instances
Previously, all Instances were treated as examples. Now, the user has the power to specify the usage of an instance using the Usage keyword. The Usage can be specified as one of three values:
#examplemeans the instance is intended as an illustration of a profile, and will be presented on the Examples tab for the corresponding profile.#definitionmeans the instance is a conformance item that is an instance of a resource such as a search parameter, operation definition, or questionnaire. These items will each be presented on their own IG page.#inlinemeans the instance should not be instantiated as an independent resource, but appears as part of another instance (for example, in a composition or bundle).
When no Usage is specified, the default value is #example. See below for an example of how usage can be used:
Instance: MyPerson
InstanceOf: MyPatientProfile
Usage: #example
// some rules
Instance: MySearchParameter
InstanceOf: SearchParameter
Usage: #definition
// some rules
Contained Instances
Often, FHIR resources have elements of type Resource. Examples include the contained element, or fields on the Bundle resource. Previously, there was no way to set values to elements of this type on an Instance. SUSHI 0.11.1 introduces a syntax for setting elements of type Resource to another Instance defined in FSH. The syntax works as shown below:
Instance: MyPatient
InstanceOf: Patient
* name[0].family = "InstanceMan"
Instance: MyBundle
InstanceOf: Bundle
* entry[0].resource = MyPatient
In the example, we create an Instance of Patient, and then we set the resource field on the first element of the entry array to that Instance. The MyBundle Instance will now contain a copy of the MyPatient Instance at the indicated path. This syntax can be combined with the Usage keyword described above. If the Usage on MyPatient is set to #inline, then no independent JSON file will be generated for the MyPatient Instance. That Instance will only exist in the context of MyBundle. This can help reduce cluttered output when adding many contained Instances.
One Sided Cardinality
SUSHI 0.11.1 introduces the ability to only specify one side of a cardinality. Users can now specify * path 1.., or * path ..1. If one side of the cardinality is left off, the element's current cardinality will be used for that side. This is not a requirement, two sided cardinality statements are still allowed, but this allows users to avoid specifying information that is not being changed.
Full Documentation
For additional documentation, refer to the FSH language reference.
Install or Update
To install or update to the latest version, run the following command:
$ npm install -g fsh-sushi