<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.4.1
Name: [4] Rozpoznanie główne
Description: Szablon CDA dla rozpoznania głównego
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000">
   <title>[4] Rozpoznanie główne</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]"
         id="d16e7528-false-d30359e0">
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]) &gt;= 1">(plCdaPrincipalDiagnosis): element hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']] is mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]) &lt;= 1">(plCdaPrincipalDiagnosis): element hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]"
         id="d16e7561-false-d30376e0">
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="string(@classCode) = ('BATTERY')">(plCdaPrincipalDiagnosis): The value for classCode SHALL be 'BATTERY'. Found: "<value-of select="@classCode"/>"</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="string(@moodCode) = ('EVN')">(plCdaPrincipalDiagnosis): The value for moodCode SHALL be 'EVN'. Found: "<value-of select="@moodCode"/>"</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']) &gt;= 1">(plCdaPrincipalDiagnosis): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1'] is mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']) &lt;= 1">(plCdaPrincipalDiagnosis): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1'] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:code[(@code = '8319008' and @codeSystem = '2.16.840.1.113883.6.96') or @nullFlavor]) &lt;= 1">(plCdaPrincipalDiagnosis): element hl7:code[(@code = '8319008' and @codeSystem = '2.16.840.1.113883.6.96') or @nullFlavor] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:statusCode[@code = 'completed']) &gt;= 1">(plCdaPrincipalDiagnosis): element hl7:statusCode[@code = 'completed'] is mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:statusCode[@code = 'completed']) &lt;= 1">(plCdaPrincipalDiagnosis): element hl7:statusCode[@code = 'completed'] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:component[not(@nullFlavor)][hl7:observation]) &gt;= 1">(plCdaPrincipalDiagnosis): element hl7:component[not(@nullFlavor)][hl7:observation] is mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:component[not(@nullFlavor)][hl7:observation]) &lt;= 1">(plCdaPrincipalDiagnosis): element hl7:component[not(@nullFlavor)][hl7:observation] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']"
         id="d16e7567-false-d30426e0">
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.4.1')">(plCdaPrincipalDiagnosis): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.4.1'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:code[(@code = '8319008' and @codeSystem = '2.16.840.1.113883.6.96') or @nullFlavor]
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:code[(@code = '8319008' and @codeSystem = '2.16.840.1.113883.6.96') or @nullFlavor]"
         id="d16e7572-false-d30438e0">
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="@nullFlavor or (@code='8319008' and @codeSystem='2.16.840.1.113883.6.96' and @displayName='Principal diagnosis' and @codeSystemName='SNOMED CT')">(plCdaPrincipalDiagnosis): The element value SHALL be one of 'code '8319008' codeSystem '2.16.840.1.113883.6.96' displayName='Principal diagnosis' codeSystemName='SNOMED CT''.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:statusCode[@code = 'completed']
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:statusCode[@code = 'completed']"
         id="d16e7577-false-d30452e0">
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="@nullFlavor or (@code='completed')">(plCdaPrincipalDiagnosis): The element value SHALL be one of 'code 'completed''.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]"
         id="d16e7583-false-d30465e0">
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="string(@typeCode) = ('COMP') or not(@typeCode)">(plCdaPrincipalDiagnosis): The value for typeCode SHALL be 'COMP'. Found: "<value-of select="@typeCode"/>"</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:observation[not(@nullFlavor)]) &gt;= 1">(plCdaPrincipalDiagnosis): element hl7:observation[not(@nullFlavor)] is mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:observation[not(@nullFlavor)]) &lt;= 1">(plCdaPrincipalDiagnosis): element hl7:observation[not(@nullFlavor)] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]/hl7:observation[not(@nullFlavor)]
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]/hl7:observation[not(@nullFlavor)]"
         id="d16e7587-false-d30485e0">
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="string(@classCode) = ('OBS') or not(@classCode)">(plCdaPrincipalDiagnosis): The value for classCode SHALL be 'OBS'. Found: "<value-of select="@classCode"/>"</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="string(@moodCode) = ('EVN') or not(@moodCode)">(plCdaPrincipalDiagnosis): The value for moodCode SHALL be 'EVN'. Found: "<value-of select="@moodCode"/>"</assert>
      <let name="elmcount"
           value="count(hl7:code[@codeSystem='2.16.840.1.113883.6.3'] | hl7:code[@codeSystem='2.16.840.1.113883.6.260'])"/>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="$elmcount &gt;= 1">(plCdaPrincipalDiagnosis): choice (hl7:code[@codeSystem='2.16.840.1.113883.6.3']  or  hl7:code[@codeSystem='2.16.840.1.113883.6.260']) does not contain enough elements [min 1x]</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="$elmcount &lt;= 1">(plCdaPrincipalDiagnosis): choice (hl7:code[@codeSystem='2.16.840.1.113883.6.3']  or  hl7:code[@codeSystem='2.16.840.1.113883.6.260']) contains too many elements [max 1x]</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:code[@codeSystem='2.16.840.1.113883.6.3']) &lt;= 1">(plCdaPrincipalDiagnosis): element hl7:code[@codeSystem='2.16.840.1.113883.6.3'] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:code[@codeSystem='2.16.840.1.113883.6.260']) &lt;= 1">(plCdaPrincipalDiagnosis): element hl7:code[@codeSystem='2.16.840.1.113883.6.260'] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="count(hl7:targetSiteCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.3.4424.13.11.80-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaPrincipalDiagnosis): element hl7:targetSiteCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.3.4424.13.11.80-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]/hl7:observation[not(@nullFlavor)]/hl7:code[@codeSystem='2.16.840.1.113883.6.3']
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]/hl7:observation[not(@nullFlavor)]/hl7:code[@codeSystem='2.16.840.1.113883.6.3']"
         id="d16e7595-false-d30524e0">
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="@nullFlavor or (@codeSystem='2.16.840.1.113883.6.3' and @codeSystemName='icd10')">(plCdaPrincipalDiagnosis): The element value SHALL be one of 'codeSystem '2.16.840.1.113883.6.3' codeSystemName='icd10''.</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="@code">(plCdaPrincipalDiagnosis): attribute @code SHALL be present.</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="not(@code) or string-length(@code)&gt;0">(plCdaPrincipalDiagnosis): Attribute @code SHALL be of data type 'st'  - '<value-of select="@code"/>'</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="@displayName">(plCdaPrincipalDiagnosis): attribute @displayName SHALL be present.</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="not(@displayName) or string-length(@displayName)&gt;0">(plCdaPrincipalDiagnosis): Attribute @displayName SHALL be of data type 'st'  - '<value-of select="@displayName"/>'</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]/hl7:observation[not(@nullFlavor)]/hl7:code[@codeSystem='2.16.840.1.113883.6.260']
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]/hl7:observation[not(@nullFlavor)]/hl7:code[@codeSystem='2.16.840.1.113883.6.260']"
         id="d16e7604-false-d30545e0">
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="@nullFlavor or (@codeSystem='2.16.840.1.113883.6.260' and @codeSystemName='icd10DualCoding')">(plCdaPrincipalDiagnosis): The element value SHALL be one of 'codeSystem '2.16.840.1.113883.6.260' codeSystemName='icd10DualCoding''.</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="@code">(plCdaPrincipalDiagnosis): attribute @code SHALL be present.</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="not(@code) or string-length(@code)&gt;0">(plCdaPrincipalDiagnosis): Attribute @code SHALL be of data type 'st'  - '<value-of select="@code"/>'</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="@displayName">(plCdaPrincipalDiagnosis): attribute @displayName SHALL be present.</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="not(@displayName) or string-length(@displayName)&gt;0">(plCdaPrincipalDiagnosis): Attribute @displayName SHALL be of data type 'st'  - '<value-of select="@displayName"/>'</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.1
Context: *[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]/hl7:observation[not(@nullFlavor)]/hl7:targetSiteCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.3.4424.13.11.80-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaPrincipalDiagnosis)
-->

   <rule fpi="RULC-1"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.1']]/hl7:component[not(@nullFlavor)][hl7:observation]/hl7:observation[not(@nullFlavor)]/hl7:targetSiteCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.3.4424.13.11.80-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e7614-false-d30571e0">
      <let name="theCode" value="@code"/>
      <let name="theCodeSystem" value="@codeSystem"/>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.4.1-2018-09-30T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.3.4424.13.11.80-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaPrincipalDiagnosis): The element value SHALL be one of '2.16.840.1.113883.3.4424.13.11.80 Strona ciała w rozpoznaniu (DYNAMIC)'.</assert>
   </rule>
</pattern>
