<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.2.3
Name: [2] Dane pacjenta (bazowy)
Description: Bazowy szablon CDA danych pacjenta
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000">
   <title>[2] Dane pacjenta (bazowy)</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3'])&gt;=1 and not(hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/@nullFlavor)">(plCdaBaseRecordTarget): element hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3'] jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3'])&lt;=1">(plCdaBaseRecordTarget): element hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3'] występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="string(@typeCode)='RCT' or not(@typeCode)">(plCdaBaseRecordTarget): Wartość dla @typeCode MUSI wynosić 'RCT'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="string(@contextControlCode)='OP' or not(@contextControlCode)">(plCdaBaseRecordTarget): Wartość dla @contextControlCode MUSI wynosić 'OP'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.2.3'])&gt;=1 and not(hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.2.3']/@nullFlavor)">(plCdaBaseRecordTarget): element hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.2.3'] jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.2.3'])&lt;=1">(plCdaBaseRecordTarget): element hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.2.3'] występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:patientRole)&gt;=1 and not(hl7:patientRole/@nullFlavor)">(plCdaBaseRecordTarget): element hl7:patientRole jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:patientRole)&lt;=1">(plCdaBaseRecordTarget): element hl7:patientRole występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.2.3']
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.2.3']"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='II' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:II", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="II"/>
      <let name="theValue" value="@value"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="string(@root)='2.16.840.1.113883.3.4424.13.10.2.3'">(plCdaBaseRecordTarget): Wartość dla @root MUSI wynosić '2.16.840.1.113883.3.4424.13.10.2.3'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@root) or matches(@root,'^[0-2](\.(0|[1-9][0-9]*))*$')">(plCdaBaseRecordTarget): Atrybut @root MUSI być typu 'oid'</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="string(@classCode)='PAT' or not(@classCode)">(plCdaBaseRecordTarget): Wartość dla @classCode MUSI wynosić 'PAT'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:id)&gt;=1 and not(hl7:id/@nullFlavor)">(plCdaBaseRecordTarget): element hl7:id jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:patient)&gt;=1 and not(hl7:patient/@nullFlavor)">(plCdaBaseRecordTarget): element hl7:patient jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:patient)&lt;=1">(plCdaBaseRecordTarget): element hl7:patient występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:providerOrganization[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.2'])&lt;=1">(plCdaBaseRecordTarget): element hl7:providerOrganization[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.2'] występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:id
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:id"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='II' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:II", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="II"/>
      <let name="theValue" value="@value"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@root">(plCdaBaseRecordTarget): atrybut @root MUSI wystąpić.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@root) or matches(@root,'^[0-2](\.(0|[1-9][0-9]*))*$')">(plCdaBaseRecordTarget): Atrybut @root MUSI być typu 'oid'</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@extension">(plCdaBaseRecordTarget): atrybut @extension MUSI wystąpić.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@extension) or string-length(@extension)&gt;0">(plCdaBaseRecordTarget): Atrybut @extension MUSI być typu 'st'</assert>
      <report role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@root='2.16.840.1.113883.3.4424.1.1.616' and not(matches(string(@extension),'^[0-9]{11}$'))">(plCdaBaseRecordTarget): Jeżeli identyfikatorem jest numer PESEL, to musi zawierać 11 cyfr.</report>
      <report role="warning"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@root=('2.16.840.1.113883.3.4424.1.1','2.16.840.1.113883.3.4424.1.2','2.16.840.1.113883.3.4424.1.3','2.16.840.1.113883.3.4424.1.5')">(plCdaBaseRecordTarget): Nieprawidłowa pula identyfikacji dla identyfikatora pacjenta.</report>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:addr
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:addr"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='AD' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:AD", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="AD.PL"/>
      <let name="theValue" value="@value"/>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:telecom
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:telecom"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='TEL' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:TEL", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="TEL"/>
      <let name="theValue" value="@value"/>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="string(@classCode)='PSN' or not(@classCode)">(plCdaBaseRecordTarget): Wartość dla @classCode MUSI wynosić 'PSN'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="string(@determinerCode)='INSTANCE' or not(@determinerCode)">(plCdaBaseRecordTarget): Wartość dla @determinerCode MUSI wynosić 'INSTANCE'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:id)=0">(plCdaBaseRecordTarget): element hl7:id NIE MOŻE wystąpić.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:name)&gt;=1 ">(plCdaBaseRecordTarget): element hl7:name jest required [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:name)&lt;=1">(plCdaBaseRecordTarget): element hl7:name występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:administrativeGenderCode)&lt;=1">(plCdaBaseRecordTarget): element hl7:administrativeGenderCode występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:birthTime)&lt;=1">(plCdaBaseRecordTarget): element hl7:birthTime występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:maritalStatusCode)&lt;=1">(plCdaBaseRecordTarget): element hl7:maritalStatusCode występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:religiousAffiliationCode)&lt;=1">(plCdaBaseRecordTarget): element hl7:religiousAffiliationCode występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:raceCode)&lt;=1">(plCdaBaseRecordTarget): element hl7:raceCode występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:ethnicGroupCode)&lt;=1">(plCdaBaseRecordTarget): element hl7:ethnicGroupCode występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:birthplace)&lt;=1">(plCdaBaseRecordTarget): element hl7:birthplace występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(extPL:multipleBirthInd)&lt;=1">(plCdaBaseRecordTarget): element extPL:multipleBirthInd występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(extPL:multipleBirthOrderNumber)&lt;=1">(plCdaBaseRecordTarget): element extPL:multipleBirthOrderNumber występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:id
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:id"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='II' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:II", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="II"/>
      <let name="theValue" value="@value"/>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:administrativeGenderCode
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:administrativeGenderCode"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CE' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CE", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CE"/>
      <let name="theValue" value="@value"/>
      <let name="theCode" value="@code"/>
      <let name="theCodeSystem" value="@codeSystem"/>
      <let name="theCodeSystemVersion" value="@codeSystemVersion"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.1-DYNAMIC.xml')/*/valueSet[conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion] or completeCodeSystem[@codeSystem=$theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion]])">(plCdaBaseRecordTarget): Wartość elementu MUSI wynosić AdministrativeGender (DYNAMICZNE).</assert>
      <let name="theNullFlavor" value="@nullFlavor"/>
      <let name="validNullFlavorsFound"
           value="exists(doc('include/voc-2.16.840.1.113883.1.11.1-DYNAMIC.xml')/*/valueSet/conceptList/exception[@code = $theNullFlavor][@codeSystem = '2.16.840.1.113883.5.1008'])"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@nullFlavor) or not(empty(($validNullFlavorsFound))) ">(plCdaBaseRecordTarget): Kod braku danych dla @code MUSI pochodzić ze zbioru dopuszczalnych kodów braku danych zdefiniowanych dla tego atrybutu lub powiązanych ze zbiorem wartości AdministrativeGender (DYNAMICZNE)</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthTime
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthTime"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='TS' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:TS", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="TS.DATE"/>
      <let name="theValue" value="@value"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="concat(substring(@value,1,4),'-',substring(@value,5,2),'-',substring(@value,7,2)) castable as xs:date">(plCdaBaseRecordTarget): Pierwsze 8 cyfr daty urodzenia powinno być w formacie YYYYMMDD.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:maritalStatusCode
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:maritalStatusCode"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CE' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CE", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CE"/>
      <let name="theValue" value="@value"/>
      <let name="theCode" value="@code"/>
      <let name="theCodeSystem" value="@codeSystem"/>
      <let name="theCodeSystemVersion" value="@codeSystemVersion"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.12212-DYNAMIC.xml')/*/valueSet[conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion] or completeCodeSystem[@codeSystem=$theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion]])">(plCdaBaseRecordTarget): Wartość elementu MUSI wynosić MaritalStatus (DYNAMICZNE).</assert>
      <let name="theNullFlavor" value="@nullFlavor"/>
      <let name="validNullFlavorsFound"
           value="exists(doc('include/voc-2.16.840.1.113883.1.11.12212-DYNAMIC.xml')/*/valueSet/conceptList/exception[@code = $theNullFlavor][@codeSystem = '2.16.840.1.113883.5.1008'])"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@nullFlavor) or not(empty(($validNullFlavorsFound))) ">(plCdaBaseRecordTarget): Kod braku danych dla @code MUSI pochodzić ze zbioru dopuszczalnych kodów braku danych zdefiniowanych dla tego atrybutu lub powiązanych ze zbiorem wartości MaritalStatus (DYNAMICZNE)</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:religiousAffiliationCode
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:religiousAffiliationCode"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CE' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CE", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CE"/>
      <let name="theValue" value="@value"/>
      <let name="theCode" value="@code"/>
      <let name="theCodeSystem" value="@codeSystem"/>
      <let name="theCodeSystemVersion" value="@codeSystemVersion"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.19185-DYNAMIC.xml')/*/valueSet[conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion] or completeCodeSystem[@codeSystem=$theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion]])">(plCdaBaseRecordTarget): Wartość elementu MUSI wynosić ReligiousAffiliation (DYNAMICZNE).</assert>
      <let name="theNullFlavor" value="@nullFlavor"/>
      <let name="validNullFlavorsFound"
           value="exists(doc('include/voc-2.16.840.1.113883.1.11.19185-DYNAMIC.xml')/*/valueSet/conceptList/exception[@code = $theNullFlavor][@codeSystem = '2.16.840.1.113883.5.1008'])"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@nullFlavor) or not(empty(($validNullFlavorsFound))) ">(plCdaBaseRecordTarget): Kod braku danych dla @code MUSI pochodzić ze zbioru dopuszczalnych kodów braku danych zdefiniowanych dla tego atrybutu lub powiązanych ze zbiorem wartości ReligiousAffiliation (DYNAMICZNE)</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:raceCode
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:raceCode"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CE' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CE", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CE"/>
      <let name="theValue" value="@value"/>
      <let name="theCode" value="@code"/>
      <let name="theCodeSystem" value="@codeSystem"/>
      <let name="theCodeSystemVersion" value="@codeSystemVersion"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.14914-DYNAMIC.xml')/*/valueSet[conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion] or completeCodeSystem[@codeSystem=$theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion]])">(plCdaBaseRecordTarget): Wartość elementu MUSI wynosić Race (DYNAMICZNE).</assert>
      <let name="theNullFlavor" value="@nullFlavor"/>
      <let name="validNullFlavorsFound"
           value="exists(doc('include/voc-2.16.840.1.113883.1.11.14914-DYNAMIC.xml')/*/valueSet/conceptList/exception[@code = $theNullFlavor][@codeSystem = '2.16.840.1.113883.5.1008'])"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@nullFlavor) or not(empty(($validNullFlavorsFound))) ">(plCdaBaseRecordTarget): Kod braku danych dla @code MUSI pochodzić ze zbioru dopuszczalnych kodów braku danych zdefiniowanych dla tego atrybutu lub powiązanych ze zbiorem wartości Race (DYNAMICZNE)</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:ethnicGroupCode
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:ethnicGroupCode"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CE' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CE", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CE"/>
      <let name="theValue" value="@value"/>
      <let name="theCode" value="@code"/>
      <let name="theCodeSystem" value="@codeSystem"/>
      <let name="theCodeSystemVersion" value="@codeSystemVersion"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.15836-DYNAMIC.xml')/*/valueSet[conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion] or completeCodeSystem[@codeSystem=$theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion]])">(plCdaBaseRecordTarget): Wartość elementu MUSI wynosić Ethnicity (DYNAMICZNE).</assert>
      <let name="theNullFlavor" value="@nullFlavor"/>
      <let name="validNullFlavorsFound"
           value="exists(doc('include/voc-2.16.840.1.113883.1.11.15836-DYNAMIC.xml')/*/valueSet/conceptList/exception[@code = $theNullFlavor][@codeSystem = '2.16.840.1.113883.5.1008'])"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@nullFlavor) or not(empty(($validNullFlavorsFound))) ">(plCdaBaseRecordTarget): Kod braku danych dla @code MUSI pochodzić ze zbioru dopuszczalnych kodów braku danych zdefiniowanych dla tego atrybutu lub powiązanych ze zbiorem wartości Ethnicity (DYNAMICZNE)</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="string(@classCode)='GUARD'">(plCdaBaseRecordTarget): Wartość dla @classCode MUSI wynosić 'GUARD'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:code)&lt;=1">(plCdaBaseRecordTarget): element hl7:code występuje zbyt często [max 1x].</assert>
      <let name="elmcount"
           value="count(hl7:guardianPerson[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.1']|hl7:guardianOrganization[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.2'])"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="$elmcount&gt;=1">(plCdaBaseRecordTarget): wybór (hl7:guardianPerson[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.1'] lub hl7:guardianOrganization[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.2']) zawiera zbyt mało elementów [min 1x]</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="$elmcount&lt;=1">(plCdaBaseRecordTarget): wybór (hl7:guardianPerson[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.1'] lub hl7:guardianOrganization[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.2']) zawiera zbyt dużo elementów [min 1x]</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian/hl7:id
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian/hl7:id"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='II' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:II", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="II"/>
      <let name="theValue" value="@value"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@root">(plCdaBaseRecordTarget): atrybut @root MUSI wystąpić.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@root) or matches(@root,'^[0-2](\.(0|[1-9][0-9]*))*$')">(plCdaBaseRecordTarget): Atrybut @root MUSI być typu 'oid'</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@extension">(plCdaBaseRecordTarget): atrybut @extension MUSI wystąpić.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@extension) or string-length(@extension)&gt;0">(plCdaBaseRecordTarget): Atrybut @extension MUSI być typu 'st'</assert>
      <report role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@root='2.16.840.1.113883.3.4424.1.1.616' and not(matches(string(@extension),'^[0-9]{11}$'))">(plCdaBaseRecordTarget): Jeżeli identyfikatorem jest numer PESEL to musi zawierać 11 cyfr.</report>
      <report role="warning"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@root=('2.16.840.1.113883.3.4424.1.1','2.16.840.1.113883.3.4424.1.2','2.16.840.1.113883.3.4424.1.3','2.16.840.1.113883.3.4424.1.5')">(plCdaBaseRecordTarget): Nieprawidłowa pula identyfikacji dla identyfikatora pacjenta.</report>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian/hl7:code
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian/hl7:code"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CE' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CE", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CE"/>
      <let name="theValue" value="@value"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@nullFlavor or (@codeSystem='2.16.840.1.113883.5.111')">(plCdaBaseRecordTarget): Wartość elementu MUSI wynosić codeSystem '2.16.840.1.113883.5.111'.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian/hl7:addr
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian/hl7:addr"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='AD' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:AD", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="AD.PL"/>
      <let name="theValue" value="@value"/>
   </rule>

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian/hl7:guardianPerson[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.1']
Item: (plCdaBaseRecordTarget)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:guardian/hl7:guardianOrganization[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.2']
Item: (plCdaBaseRecordTarget)
-->
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthplace
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthplace"
         id="tmp-">
      <let name="theAttValue"
           value="distinct-values(tokenize(normalize-space(@classCode),' '))"/>
      <let name="theAttCheck"
           value="distinct-values(document('include/voc-2.16.840.1.113883.1.11.20115-DYNAMIC.xml')/*/valueSet/conceptList/concept[@code = $theAttValue]/@code)"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@classCode) or count($theAttValue) = count($theAttCheck)">(plCdaBaseRecordTarget): Wartość dla classCode MUSI pochodzić z zbiór wartości 'RoleClassBirthplace' (DYNAMICZNE)</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:birthplace)&gt;=1 ">(plCdaBaseRecordTarget): element hl7:birthplace jest required [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:birthplace)&lt;=1">(plCdaBaseRecordTarget): element hl7:birthplace występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthplace/hl7:birthplace
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthplace/hl7:birthplace"
         id="tmp-">
      <let name="theAttValue"
           value="distinct-values(tokenize(normalize-space(@classCode),' '))"/>
      <let name="theAttCheck"
           value="distinct-values(document('include/voc-2.16.840.1.113883.1.11.10892-DYNAMIC.xml')/*/valueSet/conceptList/concept[@code = $theAttValue]/@code)"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@classCode) or count($theAttValue) = count($theAttCheck)">(plCdaBaseRecordTarget): Wartość dla classCode MUSI pochodzić z zbiór wartości 'EntityClassPlace' (DYNAMICZNE)</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="string(@determinerCode)='INSTANCE' or not(@determinerCode)">(plCdaBaseRecordTarget): Wartość dla @determinerCode MUSI wynosić 'INSTANCE'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:name)&lt;=1">(plCdaBaseRecordTarget): element hl7:name występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:addr)&lt;=1">(plCdaBaseRecordTarget): element hl7:addr występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthplace/hl7:birthplace/hl7:name
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthplace/hl7:birthplace/hl7:name"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='EN' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:EN", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="EN"/>
      <let name="theValue" value="@value"/>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthplace/hl7:birthplace/hl7:addr
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:birthplace/hl7:birthplace/hl7:addr"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='AD' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:AD", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="AD"/>
      <let name="theValue" value="@value"/>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:languageCode)&lt;=1">(plCdaBaseRecordTarget): element hl7:languageCode występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:modeCode)&lt;=1">(plCdaBaseRecordTarget): element hl7:modeCode występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:proficiencyLevelCode)&lt;=1">(plCdaBaseRecordTarget): element hl7:proficiencyLevelCode występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="count(hl7:preferenceInd)&lt;=1">(plCdaBaseRecordTarget): element hl7:preferenceInd występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication/hl7:languageCode
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication/hl7:languageCode"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CS' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CS", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CS"/>
      <let name="theValue" value="@value"/>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication/hl7:modeCode
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication/hl7:modeCode"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CE' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CE", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CE"/>
      <let name="theValue" value="@value"/>
      <let name="theCode" value="@code"/>
      <let name="theCodeSystem" value="@codeSystem"/>
      <let name="theCodeSystemVersion" value="@codeSystemVersion"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.12249-DYNAMIC.xml')/*/valueSet[conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion] or completeCodeSystem[@codeSystem=$theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion]])">(plCdaBaseRecordTarget): Wartość elementu MUSI wynosić LanguageAbilityMode (DYNAMICZNE).</assert>
      <let name="theNullFlavor" value="@nullFlavor"/>
      <let name="validNullFlavorsFound"
           value="exists(doc('include/voc-2.16.840.1.113883.1.11.12249-DYNAMIC.xml')/*/valueSet/conceptList/exception[@code = $theNullFlavor][@codeSystem = '2.16.840.1.113883.5.1008'])"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@nullFlavor) or not(empty(($validNullFlavorsFound))) ">(plCdaBaseRecordTarget): Kod braku danych dla @code MUSI pochodzić ze zbioru dopuszczalnych kodów braku danych zdefiniowanych dla tego atrybutu lub powiązanych ze zbiorem wartości LanguageAbilityMode (DYNAMICZNE)</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication/hl7:proficiencyLevelCode
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication/hl7:proficiencyLevelCode"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CE' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CE", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CE"/>
      <let name="theValue" value="@value"/>
      <let name="theCode" value="@code"/>
      <let name="theCodeSystem" value="@codeSystem"/>
      <let name="theCodeSystemVersion" value="@codeSystemVersion"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.12199-DYNAMIC.xml')/*/valueSet[conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion] or completeCodeSystem[@codeSystem=$theCodeSystem][not(@codeSystemVersion) or @codeSystemVersion=$theCodeSystemVersion]])">(plCdaBaseRecordTarget): Wartość elementu MUSI wynosić LanguageAbilityProficiency (DYNAMICZNE).</assert>
      <let name="theNullFlavor" value="@nullFlavor"/>
      <let name="validNullFlavorsFound"
           value="exists(doc('include/voc-2.16.840.1.113883.1.11.12199-DYNAMIC.xml')/*/valueSet/conceptList/exception[@code = $theNullFlavor][@codeSystem = '2.16.840.1.113883.5.1008'])"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="not(@nullFlavor) or not(empty(($validNullFlavorsFound))) ">(plCdaBaseRecordTarget): Kod braku danych dla @code MUSI pochodzić ze zbioru dopuszczalnych kodów braku danych zdefiniowanych dla tego atrybutu lub powiązanych ze zbiorem wartości LanguageAbilityProficiency (DYNAMICZNE)</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication/hl7:preferenceInd
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/hl7:languageCommunication/hl7:preferenceInd"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='BL' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:BL", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="BL"/>
      <let name="theValue" value="@value"/>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/extPL:multipleBirthInd
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/extPL:multipleBirthInd"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='BL' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:BL", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="BL"/>
      <let name="theValue" value="@value"/>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/extPL:multipleBirthOrderNumber
Item: (plCdaBaseRecordTarget)
-->

   <rule context="*[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:patient/extPL:multipleBirthOrderNumber"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='INT' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(plCdaBaseRecordTarget): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:INT", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="INT.POS"/>
      <let name="theValue" value="@value"/>
      <let name="digitok"
           value="matches(string($theValue), '^-?[1-9][0-9]*$|^+?[0-9]*$')"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="$digitok or @nullFlavor">(plCdaBaseRecordTarget): @value nie jest poprawną liczbą typu INT <value-of select="$theValue"/>
      </assert>
      <report role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="extPL:multipleBirthInd/@value and not(extPL:multipleBirthOrderNumber/@value)">(plCdaBaseRecordTarget): Dla ciąży mnogiej wymagane jest podanie numeru kolejności urodzenia.</report>
   </rule>

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.3
Context: *[hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']]/hl7:recordTarget[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.3']/hl7:patientRole/hl7:providerOrganization[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.2.2']
Item: (plCdaBaseRecordTarget)
--></pattern>
