Stream: cda/publish
Topic: nonXMLBody vs structuredBody (choice)
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>
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.
Oliver Egger (Sep 19 2019 at 15:07):
I would suggest using fhirpath: (nonXMLBody | structuredBody).count()=1
Sean McIlvenna (Sep 19 2019 at 15:08):
and put that FHIRPath on both the structuredBody and nonXMLBody elements?
Sean McIlvenna (Sep 19 2019 at 15:08):
(basically, repeat it?)
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>
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>
Sean McIlvenna (Sep 19 2019 at 15:10):
I see.
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.
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 > )
Sean McIlvenna (Sep 19 2019 at 15:13):
ugh
Sean McIlvenna (Sep 19 2019 at 15:13):
zulip unescaped my escaping
Sean McIlvenna (Sep 19 2019 at 15:13):
<=
Sean McIlvenna (Sep 19 2019 at 15:13):
and
Sean McIlvenna (Sep 19 2019 at 15:13):
>=
Oliver Egger (Sep 19 2019 at 15:14):
yes sorry, zulip conversion, i have them also escaped in the strucuredefintions ..
Sean McIlvenna (Sep 19 2019 at 15:14):
cool
Sean McIlvenna (Sep 19 2019 at 15:14):
np
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() <= 1 and (nonXMLBody | structuredBody).count() >= 1"/>
</constraint>
</element>
Sean McIlvenna (Sep 19 2019 at 15:14):
yes?
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?
Sean McIlvenna (Sep 19 2019 at 15:25):
Should this instead be a <constraint> at the root element of Component2?
Sean McIlvenna (Sep 19 2019 at 15:26):
ex:
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() <= 1 and (nonXMLBody | structuredBody).count() >= 1"/>
</constraint>
</element>
Oliver Egger (Sep 19 2019 at 18:56):
thats the better place
Last updated: Apr 12 2022 at 19:14 UTC