<?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 fpi="RULC-1"
         context="*[hl7:recordTarget[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.3']]]"
         id="d16e4865-false-d22108e0">
      <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.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">(plCdaBaseRecordTarget): element hl7:recordTarget[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.3']] 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.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']] appears too often [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 fpi="RULC-1"
         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="d16e5016-false-d22169e0">
      <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.2.3-2020-06-08T000000.html"
              test="string(@typeCode) = ('RCT') or not(@typeCode)">(plCdaBaseRecordTarget): The value for typeCode SHALL be 'RCT'. 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.2.3-2020-06-08T000000.html"
              test="string(@contextControlCode) = ('OP') or not(@contextControlCode)">(plCdaBaseRecordTarget): The value for contextControlCode SHALL be 'OP'. Found: "<value-of select="@contextControlCode"/>"</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.2.3-2020-06-08T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.3']) &gt;= 1">(plCdaBaseRecordTarget): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.3'] 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.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'] 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.2.3-2020-06-08T000000.html"
              test="count(hl7:patientRole[not(@nullFlavor)][hl7:patient]) &gt;= 1">(plCdaBaseRecordTarget): element hl7:patientRole[not(@nullFlavor)][hl7:patient] 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.2.3-2020-06-08T000000.html"
              test="count(hl7:patientRole[not(@nullFlavor)][hl7:patient]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:patientRole[not(@nullFlavor)][hl7:patient] appears too often [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 fpi="RULC-1"
         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="d16e5022-false-d22225e0">
      <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.2.3-2020-06-08T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.2.3')">(plCdaBaseRecordTarget): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.2.3'. Found: "<value-of select="@root"/>"</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[not(@nullFlavor)][hl7:patient]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]"
         id="d16e5027-false-d22258e0">
      <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.2.3-2020-06-08T000000.html"
              test="string(@classCode) = ('PAT') or not(@classCode)">(plCdaBaseRecordTarget): The value for classCode SHALL be 'PAT'. 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.2.3-2020-06-08T000000.html"
              test="count(hl7:id[not(@nullFlavor)]) &gt;= 1">(plCdaBaseRecordTarget): element hl7:id[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.2.3-2020-06-08T000000.html"
              test="count(hl7:patient[not(@nullFlavor)]) &gt;= 1">(plCdaBaseRecordTarget): element hl7:patient[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.2.3-2020-06-08T000000.html"
              test="count(hl7:patient[not(@nullFlavor)]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:patient[not(@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.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']] appears too often [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[not(@nullFlavor)][hl7:patient]/hl7:id[not(@nullFlavor)]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:id[not(@nullFlavor)]"
         id="d16e5031-false-d22321e0">
      <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.2.3-2020-06-08T000000.html"
              test="@root">(plCdaBaseRecordTarget): attribute @root 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.2.3-2020-06-08T000000.html"
              test="not(@root) or matches(@root,'^[0-2](\.(0|[1-9]\d*))*$') or matches(@root,'^[A-Fa-f\d]{8}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{12}$') or matches(@root,'^[A-Za-z][A-Za-z\d\-]*$')">(plCdaBaseRecordTarget): Attribute @root SHALL be of data type 'uid'  - '<value-of select="@root"/>'</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.2.3-2020-06-08T000000.html"
              test="@extension">(plCdaBaseRecordTarget): attribute @extension 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.2.3-2020-06-08T000000.html"
              test="not(@extension) or string-length(@extension)&gt;0">(plCdaBaseRecordTarget): Attribute @extension SHALL be of data type 'st'  - '<value-of select="@extension"/>'</assert>
      <report 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.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.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/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[not(@nullFlavor)][hl7:patient]/hl7:addr
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[not(@nullFlavor)][hl7:patient]/hl7:telecom
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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]"
         id="d16e5074-false-d22368e0">
      <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.2.3-2020-06-08T000000.html"
              test="string(@classCode) = ('PSN') or not(@classCode)">(plCdaBaseRecordTarget): The value for classCode SHALL be 'PSN'. 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.2.3-2020-06-08T000000.html"
              test="string(@determinerCode) = ('INSTANCE') or not(@determinerCode)">(plCdaBaseRecordTarget): The value for determinerCode SHALL be 'INSTANCE'. Found: "<value-of select="@determinerCode"/>"</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.2.3-2020-06-08T000000.html"
              test="count(hl7:id) = 0">(plCdaBaseRecordTarget): element hl7:id MAY NOT 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.2.3-2020-06-08T000000.html"
              test="count(hl7:name) &gt;= 1">(plCdaBaseRecordTarget): element hl7:name is required [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.2.3-2020-06-08T000000.html"
              test="count(hl7:name) &lt;= 1">(plCdaBaseRecordTarget): element hl7:name 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.2.3-2020-06-08T000000.html"
              test="count(hl7:administrativeGenderCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.1-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:administrativeGenderCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.1-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) 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.2.3-2020-06-08T000000.html"
              test="count(hl7:birthTime) &lt;= 1">(plCdaBaseRecordTarget): element hl7:birthTime 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.2.3-2020-06-08T000000.html"
              test="count(hl7:maritalStatusCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12212-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:maritalStatusCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12212-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) 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.2.3-2020-06-08T000000.html"
              test="count(hl7:religiousAffiliationCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.19185-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:religiousAffiliationCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.19185-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) 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.2.3-2020-06-08T000000.html"
              test="count(hl7:raceCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.14914-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:raceCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.14914-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) 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.2.3-2020-06-08T000000.html"
              test="count(hl7:ethnicGroupCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.15836-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:ethnicGroupCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.15836-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) 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.2.3-2020-06-08T000000.html"
              test="count(hl7:birthplace[hl7:birthplace]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:birthplace[hl7:birthplace] 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.2.3-2020-06-08T000000.html"
              test="count(extPL:multipleBirthInd) &lt;= 1">(plCdaBaseRecordTarget): element extPL:multipleBirthInd 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.2.3-2020-06-08T000000.html"
              test="count(extPL:multipleBirthOrderNumber) &lt;= 1">(plCdaBaseRecordTarget): element extPL:multipleBirthOrderNumber appears too often [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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:id
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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:name
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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:administrativeGenderCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.1-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:administrativeGenderCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.1-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e5084-false-d22507e0">
      <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.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.1-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaBaseRecordTarget): The element value SHALL be one of '2.16.840.1.113883.1.11.1 AdministrativeGender (DYNAMIC)'.</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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:birthTime
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:birthTime"
         id="d16e5090-false-d22524e0">
      <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.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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:maritalStatusCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12212-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:maritalStatusCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12212-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e5096-false-d22535e0">
      <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.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.12212-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaBaseRecordTarget): The element value SHALL be one of '2.16.840.1.113883.1.11.12212 MaritalStatus (DYNAMIC)'.</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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:religiousAffiliationCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.19185-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:religiousAffiliationCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.19185-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e5101-false-d22555e0">
      <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.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.19185-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaBaseRecordTarget): The element value SHALL be one of '2.16.840.1.113883.1.11.19185 ReligiousAffiliation (DYNAMIC)'.</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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:raceCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.14914-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:raceCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.14914-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e5106-false-d22575e0">
      <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.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.14914-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaBaseRecordTarget): The element value SHALL be one of '2.16.840.1.113883.1.11.14914 Race (DYNAMIC)'.</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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:ethnicGroupCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.15836-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:ethnicGroupCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.15836-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e5111-false-d22595e0">
      <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.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.15836-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaBaseRecordTarget): The element value SHALL be one of '2.16.840.1.113883.1.11.15836 Ethnicity (DYNAMIC)'.</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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:guardian[@classCode = 'GUARD']
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:guardian[@classCode = 'GUARD']"
         id="d16e5116-false-d22625e0">
      <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.2.3-2020-06-08T000000.html"
              test="string(@classCode) = ('GUARD')">(plCdaBaseRecordTarget): The value for classCode SHALL be 'GUARD'. 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.2.3-2020-06-08T000000.html"
              test="count(hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor] appears too often [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.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.3-2020-06-08T000000.html"
              test="$elmcount &gt;= 1">(plCdaBaseRecordTarget): choice (hl7:guardianPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]  or  hl7:guardianOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]) 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.2.3-2020-06-08T000000.html"
              test="$elmcount &lt;= 1">(plCdaBaseRecordTarget): choice (hl7:guardianPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]  or  hl7:guardianOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]) contains too many elements [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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:guardian[@classCode = 'GUARD']/hl7:id
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:guardian[@classCode = 'GUARD']/hl7:id"
         id="d16e5120-false-d22681e0">
      <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.2.3-2020-06-08T000000.html"
              test="@root">(plCdaBaseRecordTarget): attribute @root 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.2.3-2020-06-08T000000.html"
              test="not(@root) or matches(@root,'^[0-2](\.(0|[1-9]\d*))*$') or matches(@root,'^[A-Fa-f\d]{8}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{12}$') or matches(@root,'^[A-Za-z][A-Za-z\d\-]*$')">(plCdaBaseRecordTarget): Attribute @root SHALL be of data type 'uid'  - '<value-of select="@root"/>'</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.2.3-2020-06-08T000000.html"
              test="@extension">(plCdaBaseRecordTarget): attribute @extension 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.2.3-2020-06-08T000000.html"
              test="not(@extension) or string-length(@extension)&gt;0">(plCdaBaseRecordTarget): Attribute @extension SHALL be of data type 'st'  - '<value-of select="@extension"/>'</assert>
      <report 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.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.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:guardian[@classCode = 'GUARD']/hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:guardian[@classCode = 'GUARD']/hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]"
         id="d16e5133-false-d22700e0">
      <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.2.3-2020-06-08T000000.html"
              test="@nullFlavor or (@codeSystem='2.16.840.1.113883.5.111')">(plCdaBaseRecordTarget): The element value SHALL be one of '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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:guardian[@classCode = 'GUARD']/hl7:addr
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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:guardian[@classCode = 'GUARD']/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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:guardian[@classCode = 'GUARD']/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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:birthplace[hl7:birthplace]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:birthplace[hl7:birthplace]"
         id="d16e5149-false-d22760e0">
      <let name="theAttValue"
           value="distinct-values(tokenize(normalize-space(@classCode),'\s'))"/>
      <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.2.3-2020-06-08T000000.html"
              test="not(@classCode) or empty($theAttValue[not(. = (doc('include/voc-2.16.840.1.113883.1.11.20115-DYNAMIC.xml')/*/valueSet/conceptList/concept/@code))])">(plCdaBaseRecordTarget): The value for classCode SHALL be selected from value set '2.16.840.1.113883.1.11.20115' RoleClassBirthplace (DYNAMIC).</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.2.3-2020-06-08T000000.html"
              test="count(hl7:birthplace) &gt;= 1">(plCdaBaseRecordTarget): element hl7:birthplace is required [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.2.3-2020-06-08T000000.html"
              test="count(hl7:birthplace) &lt;= 1">(plCdaBaseRecordTarget): element hl7:birthplace appears too often [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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:birthplace[hl7:birthplace]/hl7:birthplace
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:birthplace[hl7:birthplace]/hl7:birthplace"
         id="d16e5156-false-d22788e0">
      <let name="theAttValue"
           value="distinct-values(tokenize(normalize-space(@classCode),'\s'))"/>
      <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.2.3-2020-06-08T000000.html"
              test="not(@classCode) or empty($theAttValue[not(. = (doc('include/voc-2.16.840.1.113883.1.11.10892-DYNAMIC.xml')/*/valueSet/conceptList/concept/@code))])">(plCdaBaseRecordTarget): The value for classCode SHALL be selected from value set '2.16.840.1.113883.1.11.10892' EntityClassPlace (DYNAMIC).</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.2.3-2020-06-08T000000.html"
              test="string(@determinerCode) = ('INSTANCE') or not(@determinerCode)">(plCdaBaseRecordTarget): The value for determinerCode SHALL be 'INSTANCE'. Found: "<value-of select="@determinerCode"/>"</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.2.3-2020-06-08T000000.html"
              test="count(hl7:name) &lt;= 1">(plCdaBaseRecordTarget): element hl7:name 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.2.3-2020-06-08T000000.html"
              test="count(hl7:addr) &lt;= 1">(plCdaBaseRecordTarget): element hl7:addr appears too often [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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:birthplace[hl7:birthplace]/hl7:birthplace/hl7:name
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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:birthplace[hl7:birthplace]/hl7:birthplace/hl7:addr
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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:languageCommunication
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:languageCommunication"
         id="d16e5171-false-d22840e0">
      <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.2.3-2020-06-08T000000.html"
              test="count(hl7:languageCode) &lt;= 1">(plCdaBaseRecordTarget): element hl7:languageCode 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.2.3-2020-06-08T000000.html"
              test="count(hl7:modeCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12249-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:modeCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12249-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) 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.2.3-2020-06-08T000000.html"
              test="count(hl7:proficiencyLevelCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12199-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseRecordTarget): element hl7:proficiencyLevelCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12199-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) 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.2.3-2020-06-08T000000.html"
              test="count(hl7:preferenceInd) &lt;= 1">(plCdaBaseRecordTarget): element hl7:preferenceInd appears too often [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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:languageCommunication/hl7:languageCode
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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:languageCommunication/hl7:modeCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12249-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:languageCommunication/hl7:modeCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12249-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e5178-false-d22897e0">
      <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.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.12249-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaBaseRecordTarget): The element value SHALL be one of '2.16.840.1.113883.1.11.12249 LanguageAbilityMode (DYNAMIC)'.</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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:languageCommunication/hl7:proficiencyLevelCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12199-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:languageCommunication/hl7:proficiencyLevelCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.12199-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e5183-false-d22917e0">
      <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.2.3-2020-06-08T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.12199-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaBaseRecordTarget): The element value SHALL be one of '2.16.840.1.113883.1.11.12199 LanguageAbilityProficiency (DYNAMIC)'.</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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/hl7:languageCommunication/hl7:preferenceInd
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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/extPL:multipleBirthInd
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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/extPL:multipleBirthOrderNumber
Item: (plCdaBaseRecordTarget)
-->

   <rule fpi="RULC-1"
         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[not(@nullFlavor)][hl7:patient]/hl7:patient[not(@nullFlavor)]/extPL:multipleBirthOrderNumber"
         id="d16e5193-false-d22950e0">
      <report 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.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[not(@nullFlavor)][hl7:patient]/hl7:providerOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]
Item: (plCdaBaseRecordTarget)
--></pattern>
