Repository navigation
Conversation
In the FHIR R6 JSON format, an instance of an additional resource carries resourceDefinition, the versioned canonical of the resource definition, right after resourceType. SUSHI now sets it when the specialization that the instance is based on has the additional-resource extension. For definitions from the FSH project, which SUSHI exports without a version, it uses the configured version, which the IG Publisher assigns to them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In FHIR R6, an instance of an additional resource carries
resourceDefinitionin JSON, right afterresourceType: the canonical of the resource's definition, always with its version (JSON representation of additional resources, normative):{ "resourceType" : "ViewDefinition", "resourceDefinition" : "http://hl7.org/fhir/uv/sql-on-fhir/StructureDefinition/ViewDefinition|2.0.0-pre", "id": "a-valid-id", // etc }SUSHI does not write
resourceDefinition, so the validator rejects every FSH instance of an additional resource, and the IG Publisher reports it as a QA error.This affects, for example, IGs with instances of
PublicationRecordfromhl7.fhir.uv.ebm-incubator.Example
The full example can be found here: https://github.com/glichtner/additional-resource-definition-example
A dependency package defines
AdditionalRecord, a specialization ofDomainResourcethat setshttp://hl7.org/fhir/tools/StructureDefinition/additional-resourcetotrue. The IG depends on it and contains:Expected:
{ "resourceType": "AdditionalRecord", "resourceDefinition": "http://hl7.org/fhir/StructureDefinition/AdditionalRecord|0.1.0", "id": "example-record", "title": "Example record" }Actual with 3.21.0:
{ "resourceType": "AdditionalRecord", "id": "example-record", "title": "Example record" }The IG Publisher (3.0.2) then reports:
The validator expects exactly the versioned canonical of the specialization, also for instances of a profile on the additional resource (
InstanceValidator.start()). The Java JSON composer writes the property the same way: afterresourceType, from theadditional-resourceextension of the type's StructureDefinition.Reproduce
Example
See https://github.com/glichtner/additional-resource-definition-example.
./reproduce.shbuilds the dependency with SUSHI, installs it into the package cache, and runs SUSHI on the IG. It exits with code 1 with SUSHI 3.21.0 and with code 0 with this branch (./reproduce.sh node /path/to/sushi/dist/app.js). WithPUBLISHER_JARset, it also builds the IG: one QA error with 3.21.0, none with this branch.Tests
New tests in
test/export/InstanceExporter.test.ts(#Additional Resources), each with a FSH-defined additional resource:resourceDefinitionwith the configured version, right afterresourceType;^versionon the resource is used;resourceDefinitionis the url alone;BundlegetsresourceDefinitiontoo;resourceDefinitionwhen the extension isfalse, or for core resources.npx jest test/export/InstanceExporter.test.ts -t "#Additional Resources"Without the change in
src/, the first five fail and the two negative cases pass.npm run checkpasses (104 suites; 3,584 tests passed, 8 skipped, 7 todo).On a real IG with a
PublicationRecordinstance (279 resources), the export differs from 3.21.0 only in that instance, which gains"resourceDefinition": "http://hl7.org/fhir/StructureDefinition/PublicationRecord|0.1.0-snapshot".Fix
exportInstance()already walks from theInstanceOfdefinition to its specialization to check for abstract types. If that specialization has theadditional-resourceextension set totrue, the instance getsresourceDefinition = <url>|<version>.InstanceDefinition.toJSON()orders it afterresourceType.SUSHI exports the definitions of the FSH project without a version, and the IG Publisher gives them the IG version. For those, SUSHI uses the configured version. A definition from a package uses its own version. If no version is known, the url is written alone, as the Java composer does.