From ca1aa4e8b6a44dfac700e14bcc01f513638327c2 Mon Sep 17 00:00:00 2001 From: John Grimes Date: Tue, 28 Apr 2026 20:37:33 +1000 Subject: [PATCH] Publish ViewDefinition as a resource type with R4 variant 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. --- input/fsh/models.fsh | 30 +++++++++++++++++-- ...tructureDefinition-ViewDefinition-notes.md | 4 +-- sushi-config.yaml | 11 +++++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/input/fsh/models.fsh b/input/fsh/models.fsh index e89f51d6..ba32bda4 100644 --- a/input/fsh/models.fsh +++ b/input/fsh/models.fsh @@ -20,12 +20,36 @@ Expression: "(forEach.exists().toInteger() + forEachOrNull.exists().toInteger() // NOTE: Using RuleSet with LogicalModels where you pass parameters seems to be broken Logical: ViewDefinition Title: "View Definition" -Parent: CanonicalResource +Parent: DomainResource Description: """ -A ViewDefinition represents a tabular projection of a FHIR resource, where the columns and inclusion -criteria are defined by FHIRPath expressions. +A ViewDefinition represents a tabular projection of a FHIR resource, where the columns and inclusion +criteria are defined by FHIRPath expressions. """ +// Canonical resource metadata. ViewDefinition was previously parented on +// CanonicalResource to inherit these fields, but CanonicalResource is only +// defined as an abstract type from R5 onward. Defining the fields directly +// keeps the on-wire shape consistent with other canonical resources while +// allowing the IG publisher to emit version-specific packages back to R4. +* url 0..1 uri "Canonical identifier for this view definition" """ + An absolute URI that is used to identify this view definition when it is referenced in a specification, + model, design or an instance; also called its canonical identifier. +""" +* identifier 0..* Identifier "Additional identifier for the view definition" +* version 0..1 string "Business version of the view definition" +* name 0..1 string "Name for this view definition (machine friendly)" * name obeys sql-name +* title 0..1 string "Name for this view definition (human friendly)" +* status 1..1 code "draft | active | retired | unknown" +* status from http://hl7.org/fhir/ValueSet/publication-status (required) +* experimental 0..1 boolean "For testing purposes, not real usage" +* date 0..1 dateTime "Date last changed" +* publisher 0..1 string "Name of the publisher/steward (organization or individual)" +* contact 0..* ContactDetail "Contact details for the publisher" +* description 0..1 markdown "Natural language description of the view definition" +* useContext 0..* UsageContext "The context that the content is intended to support" +* jurisdiction 0..* CodeableConcept "Intended jurisdiction for view definition (if applicable)" +* purpose 0..1 markdown "Why this view definition is defined" +* copyright 0..1 markdown "Use and/or publishing restrictions" * resource 1..1 code "FHIR resource for the ViewDefinition" """ The FHIR resource that the view is based upon, e.g. 'Patient' or 'Observation'. """ diff --git a/input/pagecontent/StructureDefinition-ViewDefinition-notes.md b/input/pagecontent/StructureDefinition-ViewDefinition-notes.md index 82d4101c..683edb09 100644 --- a/input/pagecontent/StructureDefinition-ViewDefinition-notes.md +++ b/input/pagecontent/StructureDefinition-ViewDefinition-notes.md @@ -89,7 +89,7 @@ For instance, each Patient resource can have multiple addresses, which users can expand into a separate `patient_addresses` table with one row per address. Each row would still have a `patient_id` field to know which patient that address row is associated with. You can see this in -the [PatientAddresses example](Binary-PatientAddresses.html), which unrolls +the [PatientAddresses example](ViewDefinition-PatientAddresses.html), which unrolls addresses as described above. [forEach](StructureDefinition-ViewDefinition-definitions.html#diff_ViewDefinition.select.forEach) @@ -319,7 +319,7 @@ produce the same columns including their specified names and FHIR types. The above example uses `forEach` to select different data elements from the resources to be included in the union. For other use cases, it is possible to define the columns directly in the `select`. See -the [PatientAndContactAddressUnion example](Binary-PatientAndContactAddressUnion.html) +the [PatientAndContactAddressUnion example](ViewDefinition-PatientAndContactAddressUnion.html) for a complete version of the above. The columns produced from the `unionAll` list are effectively added to the diff --git a/sushi-config.yaml b/sushi-config.yaml index 1416ce62..bf8eaeb1 100644 --- a/sushi-config.yaml +++ b/sushi-config.yaml @@ -52,6 +52,17 @@ dependencies: parameters: excludettl: true path-test: tests + # Promote the ViewDefinition logical model to a published resource type so + # FHIR servers can store and serve view definitions through the standard + # REST API. The IG publisher auto-promotes kind=logical to kind=resource + # when a StructureDefinition is loaded as a custom resource. This IG is + # listed in https://fhir.github.io/ig-registry/igs-approved-for-custom-resource.json. + custom-resource: fsh-generated/resources/StructureDefinition-ViewDefinition.json + # Emit a sibling R4 package (org.sql-on-fhir.ig.r4.tgz) alongside the + # primary R5 package, so R4-based servers can load the IG without + # rewriting its dependencies. The publisher rewrites *.r5 dependencies to + # *.r4 in the variant package. + generate-version: r4 # validation: [allow-any-extensions, no-broken-links] #