FHIR Chat · HowTo: Recursive element restrictions · shorthand

Stream: shorthand

Topic: HowTo: Recursive element restrictions


view this post on Zulip Jean Duteau (Apr 05 2022 at 17:55):

I'm profiling Composition.section and it contains itself in the resource. I'm trying to figure out how to apply my profile restrictions to the recursive elements without restating them. Since I will essentially support unlimited recursion like the resource itself, I can't just restate them. I can't see in the FSH specification how to support this.

view this post on Zulip David Pyke (Apr 05 2022 at 18:03):

When I gofsh'd a resource that had a recursive (Consent), it gave me:

* provision.provision ^contentReference = "#Consent.provision"

view this post on Zulip Al Pivonka (Apr 05 2022 at 18:23):

moving to logical model mapping

view this post on Zulip Notification Bot (Apr 05 2022 at 18:29):

Al Pivonka has marked this topic as resolved.

view this post on Zulip Notification Bot (Apr 05 2022 at 18:29):

Jean Duteau has marked this topic as unresolved.

view this post on Zulip Jean Duteau (Apr 05 2022 at 18:45):

David Pyke said:

When I gofsh'd a resource that had a recursive (Consent), it gave me:

* provision.provision ^contentReference = "#Consent.provision"

I've done that for logical models, but I'm not sure how to do that for profiles.

I did * section ^contentReference = "#Composition.section.section" and that "works" in that it does do the reference. But it's not a reference to my constraints. I then tried * section ^contentReference = "#ProductSubmissionDocument.section.section" and that doesn't work.

view this post on Zulip Chris Moesel (Apr 06 2022 at 12:58):

Hey @Jean Duteau. Getting constraints to apply recursively w/ contentRefs is a little tricky - and not very intuitive. There is a previous zulip conversation where Grahame suggests that the elementdefinition-profile-element extension should be used for this. Based on that conversation, we built in support to ensure that SUSHI handles this correctly. It's described in the SUSHI 2.0.0 Release Notes:

Extension for Profiling BackboneElements

The profile-element extension can be used to profile a BackboneElement by pointing at another BackboneElement defined elsewhere. This is typically used to indicate that constraints on the target of a contentReference should be applied to all the references as well. For example, the following snippet indicates the all recursive references to Questionnaire.item (e.g., Questionnaire.item.item) should conform to the same constraints as the original Questionnaire.item in this profile:

Profile: MyQuestionnaire
Parent: Questionnaire
* Questionnaire.item ^type.profile = http://example.org/StructureDefinition/MyQuestionnaire
* Questionnaire.item ^type.profile.extension.url = http://hl7.org/fhir/StructureDefinition/elementdefinition-profile-element
* Questionnaire.item ^type.profile.extension.valueString = "Questionnaire.item"
// ...

view this post on Zulip Jean Duteau (Apr 06 2022 at 15:12):

I tried this yesterday because a little bird whispered in my ear about this, but I wasn't sure how to generalize what was in the Release Notes to what I wanted to do...

Profile: ProductSubmissionDocument
Parent: Composition
Description: "A profile that represents a document that is required for Product Submission to the FDA."

* extension contains VersionNumber named versionNumber 1..1 MS
* type MS
* type from SPLDocumentCodes (required)
* title MS
* identifier 1..1 MS
* author 1..1 MS
* author only Reference(IdentifiedLabeler)
* section 1..* MS
  * extension contains SectionIdentifier named sectionID 0..1 MS and SectionEffectiveTime named sectionTime 0..1 MS
  * code 1..1 MS
  * code from SPLSectionCodes (required)
  * title MS
  * text MS
  * entry MS
  * section MS
* Composition.section ^type.profile = http://hl7.org/fhir/us/spl/StructureDefinition/ProductSubmissionDocument
* Composition.section ^type.profile.extension.url = http://hl7.org/fhir/StructureDefinition/elementdefinition-profile-element
* Composition.section ^type.profile.extension.valueString = "Composition.section"
error No element found at path Composition.section for CaretValueRule in ProductSubmissionDocument, skipping rule
  File: /Users/jeanduteau/Documents/DDIWork/Samvit/SPL/fhir-spl/input/fsh/ProductSubmission.fsh
  Line: 38
error No element found at path Composition.section for CaretValueRule in ProductSubmissionDocument, skipping rule
  File: /Users/jeanduteau/Documents/DDIWork/Samvit/SPL/fhir-spl/input/fsh/ProductSubmission.fsh
  Line: 39
error No element found at path Composition.section for CaretValueRule in ProductSubmissionDocument, skipping rule
  File: /Users/jeanduteau/Documents/DDIWork/Samvit/SPL/fhir-spl/input/fsh/ProductSubmission.fsh
  Line: 40

view this post on Zulip Jean Duteau (Apr 06 2022 at 15:13):

And my next question is whether I can make a different set of constraints on Composition.section.section and have those constraints apply recursively.

view this post on Zulip Chris Moesel (Apr 06 2022 at 15:34):

Well, that's embarrassing. The release notes had invalid paths. This is FSH, so you don't prefix the resource name to the path. So for those last three rules, it should be * section ... not * Composition.section .... I've updated the release notes and the comment above so no one else trips up on this.

view this post on Zulip Chris Moesel (Apr 06 2022 at 15:36):

As for your next question, I'm not 100% sure, but maybe this?

* section.section ^type.profile = http://hl7.org/fhir/us/spl/StructureDefinition/ProductSubmissionDocument
* section.section ^type.profile.extension.url = http://hl7.org/fhir/StructureDefinition/elementdefinition-profile-element
* section.section ^type.profile.extension.valueString = "Composition.section.section"

TBH, this was always a little bit of black magic to me, so I can't guarantee that this would work (for recursing constraints in section.section).

view this post on Zulip Jean Duteau (Apr 06 2022 at 15:39):

When I do that (which I did try yesterday), I get IGPublisher errors:

* section 0..* MS
  * extension contains SectionIdentifier named sectionID 0..1 MS and SectionEffectiveTime named sectionTime 0..1 MS
  * code 1..1 MS
  * code from SPLSectionCodes (required)
  * title MS
  * text MS
  * entry MS
* section ^type.profile = http://hl7.org/fhir/us/spl/StructureDefinition/ProductSubmissionDocument
* section ^type.profile.extension.url = http://hl7.org/fhir/StructureDefinition/elementdefinition-profile-element
* section ^type.profile.extension.valueString = "Composition.section"
java.lang.Exception: Error generating snapshot for ProductSubmissionBundle(ProductSubmissionBundle): Unable to generate snapshot for http://hl7.org/fhir/us/spl/StructureDefinition/ProductSubmissionBundle in /Users/jeanduteau/Documents/DDIWork/Samvit/SPL/fhir-spl/fsh-generated/resources/structuredefinition-ProductSubmissionBundle
    at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshots(Publisher.java:5411)
    at org.hl7.fhir.igtools.publisher.Publisher.loadConformance(Publisher.java:4668)
    at org.hl7.fhir.igtools.publisher.Publisher.createIg(Publisher.java:1006)
    at org.hl7.fhir.igtools.publisher.Publisher.execute(Publisher.java:857)
    at org.hl7.fhir.igtools.publisher.Publisher.main(Publisher.java:10033)
Caused by: org.hl7.fhir.exceptions.FHIRException: Unable to generate snapshot for http://hl7.org/fhir/us/spl/StructureDefinition/ProductSubmissionBundle in /Users/jeanduteau/Documents/DDIWork/Samvit/SPL/fhir-spl/fsh-generated/resources/structuredefinition-ProductSubmissionBundle
    at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshot(Publisher.java:5464)
    at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshots(Publisher.java:5409)
    ... 4 more
Caused by: org.hl7.fhir.exceptions.DefinitionException: Unable to find element Composition.section in http://hl7.org/fhir/us/spl/StructureDefinition/ProductSubmissionDocument
    at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:1214)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:1485)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:1109)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.generateSnapshot(ProfileUtilities.java:669)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:1203)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:1548)

view this post on Zulip Chris Moesel (Apr 06 2022 at 17:23):

I see ProductSubmissionBundle and ProductSubmissionDocument in that stack trace. I assume that ProductSubmissionBundle is profiled to have an entry slice with a resource conforming to ProductSubmissionDocument? If you comment out that slice, does the IG Publisher choke on ProductSubmissionDocument when it processes it standalone? Or only in the context of ProductSubmissionBundle?

I actually have no idea what's going on here, but sometimes narrowing it down helps. For example, if we know the IGP generates the ProductSubmissionDocument snapshot fine (which is the profile w/ the recursive magic in it), then it would appear the issue is related to using it in another context. Either way, I think you've likely crossed the line into #IG creation or #conformance at that point, as I think you're doing things as Grahame specified in that original thread.

view this post on Zulip Jean Duteau (Apr 06 2022 at 17:26):

ah, I hadn't noticed the two profiles. let me go try that...

view this post on Zulip Jean Duteau (Apr 06 2022 at 17:28):

no beans. when I comment out the slice in the bundle, the error just shifts to the document:

java.lang.Exception: Error generating snapshot for ProductSubmissionDocument(ProductSubmissionDocument): Unable to generate snapshot for http://hl7.org/fhir/us/spl/StructureDefinition/ProductSubmissionDocument in /Users/jeanduteau/Documents/DDIWork/Samvit/SPL/fhir-spl/fsh-generated/resources/structuredefinition-ProductSubmissionDocument
    at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshots(Publisher.java:5411)
    at org.hl7.fhir.igtools.publisher.Publisher.loadConformance(Publisher.java:4668)
    at org.hl7.fhir.igtools.publisher.Publisher.createIg(Publisher.java:1006)
    at org.hl7.fhir.igtools.publisher.Publisher.execute(Publisher.java:857)
    at org.hl7.fhir.igtools.publisher.Publisher.main(Publisher.java:10033)
Caused by: org.hl7.fhir.exceptions.FHIRException: Unable to generate snapshot for http://hl7.org/fhir/us/spl/StructureDefinition/ProductSubmissionDocument in /Users/jeanduteau/Documents/DDIWork/Samvit/SPL/fhir-spl/fsh-generated/resources/structuredefinition-ProductSubmissionDocument
    at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshot(Publisher.java:5464)
    at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshots(Publisher.java:5409)
    ... 4 more
Caused by: org.hl7.fhir.exceptions.DefinitionException: Unable to find element Composition.section in http://hl7.org/fhir/us/spl/StructureDefinition/ProductSubmissionDocument
    at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:1214)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.processPaths(ProfileUtilities.java:1485)
    at org.hl7.fhir.r5.conformance.ProfileUtilities.generateSnapshot(ProfileUtilities.java:669)
    at org.hl7.fhir.igtools.publisher.Publisher.generateSnapshot(Publisher.java:5459)
    ... 5 more

view this post on Zulip Jean Duteau (Apr 06 2022 at 17:28):

I'll raise this on #IG creation


Last updated: Apr 12 2022 at 19:14 UTC