FHIR Chat · nonXMLBody vs structuredBody (choice) · cda/publish

Stream: cda/publish

Topic: nonXMLBody vs structuredBody (choice)


view this post on Zulip Sean McIlvenna (Sep 19 2019 at 14:59):

How would you recommend constraining ClinicalDocument.componentOf.nonXMLBody and ClinicalDocument.componentOf.structuredBody so that only one of the two is allowed. nonXMLBody and structuredBody are a choice in XML Schema... but, that isn't currently represented/supported in the cda-core-2.0 spec. Right now, both are allowed and both are optional, when only one of the two should be allowed and should be required...
I'm guessing maybe a <constraint> with xpath or FhirPath that asserts that the other element does not exist?
Ex:

<element>
  <path value="ClinicalDocument.component.nonXMLBody" />
  ...
  <constraint>
    <key value="?" />
    <severity value="error" />
    <human value="When nonXMLBody is present, structuredBody SHALL NOT be present." />
    <xpath value="not(../cda:structuredBody)" />
  </constraint>
</element>

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:00):

not sure that xpath would work, though... not sure how it would know the "cda:" namespace prefix.

view this post on Zulip Oliver Egger (Sep 19 2019 at 15:07):

I would suggest using fhirpath: (nonXMLBody | structuredBody).count()=1

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:08):

and put that FHIRPath on both the structuredBody and nonXMLBody elements?

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:08):

(basically, repeat it?)

view this post on Zulip Oliver Egger (Sep 19 2019 at 15:08):

     <constraint>
        <key value="choice-1"/>
        <severity value="error"/>
        <human value="Choice of the contained elements"/>
        <expression value="(nonXMLBody | structuredBody).count()<=1 and (nonXMLBody | structuredBody).count()>=1"/>
     </constraint>

view this post on Zulip Oliver Egger (Sep 19 2019 at 15:09):

sorry, no one up, on the component level:
<element id="ClinicalDocument.component">
<path value="ClinicalDocument.component"/>
<min value="1"/>
<max value="1"/>
<type>
<code value="http://fhir.ch/ig/cda-r2/StructureDefinition/Component"/>
<profile value="http://fhir.ch/ig/cda-r2/StructureDefinition/Component"/>
</type>
<constraint>
<key value="choice-1"/>
<severity value="error"/>
<human value="Choice of the contained elements"/>
<expression value="(nonXMLBody | structuredBody).count()<=1 and (nonXMLBody | structuredBody).count()>=1"/>
</constraint>
</element>

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:10):

I see.

view this post on Zulip Oliver Egger (Sep 19 2019 at 15:12):

I have them autogenerated from the model i can provide you with the expressions if you want to.

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:13):

I have to use this instead:
<expression value="(nonXMLBody | structuredBody).count() <= 1 and (nonXMLBody | structuredBody).count() >= 1"/>
(escape the < and > )

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:13):

ugh

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:13):

zulip unescaped my escaping

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:13):

&lt;=

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:13):

and

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:13):

&gt;=

view this post on Zulip Oliver Egger (Sep 19 2019 at 15:14):

yes sorry, zulip conversion, i have them also escaped in the strucuredefintions ..

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:14):

cool

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:14):

np

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:14):

    <element id="ClinicalDocument.component">
      <path value="ClinicalDocument.component"/>
      <min value="1"/>
      <max value="1"/>
      <type>
        <code value="http://hl7.org/fhir/cda/StructureDefinition/Component2"/>
      </type>
      <constraint>
        <key value="body-choice"/>
        <severity value="error"/>
        <human value="Choice of the body required."/>
        <expression value="(nonXMLBody | structuredBody).count() &lt;= 1 and (nonXMLBody | structuredBody).count() &gt;= 1"/>
      </constraint>
    </element>

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:14):

yes?

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:25):

are we sure that works since "nonXMLBody" and "structuredBody" are not part of ClinicalDocument, and are instead part of the contained profile http://hl7.org/fhir/cda/StructureDefinition/Component2?

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:25):

Should this instead be a <constraint> at the root element of Component2?

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:26):

ex:

view this post on Zulip Sean McIlvenna (Sep 19 2019 at 15:26):

    <element id="Component2">
      <path value="Component2"/>
      <min value="1"/>
      <max value="1"/>
      <constraint>
        <key value="body-choice"/>
        <severity value="error"/>
        <human value="Choice of the body required."/>
        <expression value="(nonXMLBody | structuredBody).count() &lt;= 1 and (nonXMLBody | structuredBody).count() &gt;= 1"/>
      </constraint>
    </element>

view this post on Zulip Oliver Egger (Sep 19 2019 at 18:56):

thats the better place


Last updated: Apr 12 2022 at 19:14 UTC