<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.2.2
Name: [2] Organizacja (bazowy)
Description: Bazowy szablon struktury CDA dla organizacji
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.2.2-2018-06-30T000000">
   <title>[2] Organizacja (bazowy)</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]
Item: (plCdaBaseOrganization)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]"
         id="d16e2470-false-d14345e0">
      <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.2-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']) &gt;= 1">(plCdaBaseOrganization): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2'] 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.2-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']) &lt;= 1">(plCdaBaseOrganization): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2'] 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.2-2018-06-30T000000.html"
              test="count(hl7:id) &gt;= 1">(plCdaBaseOrganization): element hl7:id 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.2-2018-06-30T000000.html"
              test="count(hl7:addr) &lt;= 1">(plCdaBaseOrganization): element hl7:addr 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.2-2018-06-30T000000.html"
              test="count(hl7:standardIndustryClassCode) &lt;= 1">(plCdaBaseOrganization): element hl7:standardIndustryClassCode 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.2-2018-06-30T000000.html"
              test="count(hl7:asOrganizationPartOf) &lt;= 1">(plCdaBaseOrganization): element hl7:asOrganizationPartOf appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']
Item: (plCdaBaseOrganization)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']"
         id="d16e2499-false-d14394e0">
      <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.2-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.2.2')">(plCdaBaseOrganization): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.2.2'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:id
Item: (plCdaBaseOrganization)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:name
Item: (plCdaBaseOrganization)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:telecom
Item: (plCdaBaseOrganization)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:addr
Item: (plCdaBaseOrganization)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:standardIndustryClassCode
Item: (plCdaBaseOrganization)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:asOrganizationPartOf
Item: (plCdaBaseOrganization)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:asOrganizationPartOf"
         id="d16e2515-false-d14445e0">
      <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.2-2018-06-30T000000.html"
              test="string(@classCode) = ('PART') or not(@classCode)">(plCdaBaseOrganization): The value for classCode SHALL be 'PART'. 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.2-2018-06-30T000000.html"
              test="count(hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]) &lt;= 1">(plCdaBaseOrganization): element hl7:code[@codeSystem = '2.16.840.1.113883.5.111' 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.2-2018-06-30T000000.html"
              test="count(hl7:statusCode[@code = doc('include/voc-2.16.840.1.113883.1.11.15999-DYNAMIC.xml')//valueSet[1]/conceptList/*/@code or @nullFlavor]) &lt;= 1">(plCdaBaseOrganization): element hl7:statusCode[@code = doc('include/voc-2.16.840.1.113883.1.11.15999-DYNAMIC.xml')//valueSet[1]/conceptList/*/@code 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.2-2018-06-30T000000.html"
              test="count(hl7:effectiveTime) &lt;= 1">(plCdaBaseOrganization): element hl7:effectiveTime 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.2-2018-06-30T000000.html"
              test="count(hl7:wholeOrganization) &lt;= 1">(plCdaBaseOrganization): element hl7:wholeOrganization appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:asOrganizationPartOf/hl7:id
Item: (plCdaBaseOrganization)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:asOrganizationPartOf/hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]
Item: (plCdaBaseOrganization)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:asOrganizationPartOf/hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]"
         id="d16e2521-false-d14498e0">
      <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.2-2018-06-30T000000.html"
              test="@nullFlavor or (@codeSystem='2.16.840.1.113883.5.111')">(plCdaBaseOrganization): 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.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:asOrganizationPartOf/hl7:statusCode[@code = doc('include/voc-2.16.840.1.113883.1.11.15999-DYNAMIC.xml')//valueSet[1]/conceptList/*/@code or @nullFlavor]
Item: (plCdaBaseOrganization)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:asOrganizationPartOf/hl7:statusCode[@code = doc('include/voc-2.16.840.1.113883.1.11.15999-DYNAMIC.xml')//valueSet[1]/conceptList/*/@code or @nullFlavor]"
         id="d16e2526-false-d14514e0">
      <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.2-2018-06-30T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.15999-DYNAMIC.xml')//valueSet[1]/conceptList/concept[@code = $theCode] or completeCodeSystem)">(plCdaBaseOrganization): The element value SHALL be one of '2.16.840.1.113883.1.11.15999 RoleStatus (DYNAMIC)'.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:asOrganizationPartOf/hl7:effectiveTime
Item: (plCdaBaseOrganization)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.2
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]/hl7:asOrganizationPartOf/hl7:wholeOrganization
Item: (plCdaBaseOrganization)
-->
</pattern>
