Spike: multi-version IG#347
Draft
johngrimes wants to merge 1 commit into
Draft
Conversation
Reparents ViewDefinition from CanonicalResource to DomainResource so the IG publisher can convert it back to R4, and declares the canonical metadata fields (url, version, name, status, etc.) directly on ViewDefinition to keep the on-wire shape unchanged. Adds two IG publisher parameters: - custom-resource: promotes the ViewDefinition logical model to kind=resource in the published package, so FHIR servers can store and serve view definitions through the standard REST API. - generate-version r4: emits a sibling R4 package (org.sql-on-fhir.ig.r4.tgz) alongside the primary R5 package, with *.r5 dependencies rewritten to *.r4. Also rewrites two Binary-* example links in the View Definition notes to reference the renamed ViewDefinition-* example pages.
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.
A spike against #335 exploring whether the SQL on FHIR IG can publish ViewDefinition as a real FHIR resource type rather than a logical model, and whether multi-version packages can ship for R4 alongside the primary R5 build.
The diff in this PR is small (3 files, +40/-5) and produces R5, R4, and combined
.tgzpackages out of the box. It is offered as a starting point for working group discussion. The broader exploration that produced this commit also surfaced a number of IG publisher gaps the WG may want to be aware of before committing to this direction; those findings are below.Changes
input/fsh/models.fsh: re-parentsViewDefinitionfromCanonicalResourcetoDomainResourceso the IG publisher can convert it back to R4 (R4 has noCanonicalResourceabstract type). The canonical-resource metadata fields (url,identifier,version,name,title,status,experimental,date,publisher,contact,description,useContext,jurisdiction,purpose,copyright) are declared directly on the resource so the on-wire shape is unchanged.sushi-config.yaml: adds two IG parameters.custom-resource: fsh-generated/resources/StructureDefinition-ViewDefinition.jsontells the publisher to promotekind=logicaltokind=resourceand registerViewDefinitionas a custom resource type. This IG is on the approved list at https://fhir.github.io/ig-registry/igs-approved-for-custom-resource.json. The published package now contains akind=resourceSD plus 11 example instances atpackage/custom/ViewDefinition-*.jsonrather than the previousBinary-*.jsonplaceholders.generate-version: r4makes the publisher emit a siblingorg.sql-on-fhir.ig.r4.tgzwith*.r5dependencies rewritten to*.r4(hl7.fhir.uv.extensions.r4,hl7.terminology.r4, etc).input/pagecontent/StructureDefinition-ViewDefinition-notes.md: updates twoBinary-*example links toViewDefinition-*since the publisher renames example files when the resource type is promoted.Build outcome
Errors: 38, Warnings: 66, Info: 54, Broken Links: 17. Three packages produced underoutput/:package.tgz(R5, 144 KB),org.sql-on-fhir.ig.r4.tgz(R4 sibling, 159 KB),package-combined.tgz(89 KB). The errors and broken links are mostly pre-existing markdown / anchor issues unrelated to this change.Findings worth flagging to the WG
The semantically correct flag for this is actually
additional-resource, notcustom-resource. The FHIR Tools IG describes the difference as:custom-resourceis a type the IG uses but does not publish;additional-resourceis a type the IG publishes for others to consume.additional-resourcesets thehttp://hl7.org/fhir/tools/StructureDefinition/additional-resourceextension on the SD, which downstream tooling can use to discover "new resource types this IG introduces".custom-resourcedoes not.We tried switching to
additional-resourceand ran into several integration gaps in the IG publisher (master, 2.2.7 release):The handler only accepts XML files. SUSHI only emits JSON. Workaround requires a post-SUSHI conversion step in the build script.
Every
additional-resourcerequires abundle-<TypeName>-search-params.xmlalongside it (PublisherIGLoader#loadSearchBundle). For new resource types with no search parameters yet, this has to be a hand-written empty Bundle stub.The renderer at
StructureDefinitionRenderer#scanForKeyElementshard-codeshttp://hl7.org/fhir/StructureDefinition/<typeTail>when looking up an element's base type. For SDs whose URL is in the IG canonical namespace, this lookup returns null and rendering profiles of the resource type crashes with a NullPointerException. This is recoverable by giving the SD a URL in the core FHIR namespace (http://hl7.org/fhir/StructureDefinition/ViewDefinition) and addingspecial-url-base: http://hl7.org/fhir, which is the pattern HL7/data-access-policies, HL7/admin-incubator, and HL7/immunization-incubator use.When a hand-written XML SD is placed in
input/resources/<typename>/(the documented location, where SUSHI uses it as a predefined resource for compiling profiles and instances), the publisher'sadditional-resourcehandler caches it atPublisherIGLoader.java:1043and the auto-loader caches it again atloadConformance1/cacheResourceFromPackage(line 4252) with package version metadata applied. This produces "Ambiguous type ViewDefinition" at output-generation time. We could not reproduce this against anfhirVersion: 6.0.0-ballot3IG using the same setup as the working IGs above; switching this IG to R6 produced a clean build (9 broken links, all pre-existing markdown anchors), with the SD properly published carrying theadditional-resource: trueextension. We did not isolate exactly what the version-difference depends on.We also looked at whether IGs can supply cross-version maps (StructureMap) for instances of their custom resource types, so a single IG could ship usable R5 and R4 sibling packages. The publisher's
generate-versiononly auto-converts core FHIR types via hard-coded version converters (VersionConvertorFactory_X_Y.convertResource); it has no hook for IG-supplied conversion maps, and theOtherVersionsslot onFetchedResourceis only populated forStructureDefinitionandSearchParameter(PublisherProcessor#generateOtherVersions). Without an upstream change there is currently no way to ship working R4/R5 sibling packages that include the ViewDefinition type and its instances.Refs #335.