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

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]"
         id="d16e5206-false-d22989e0">
      <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.31-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']) &gt;= 1">(plCdaBasePharmacy): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31'] 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.31-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']) &lt;= 1">(plCdaBasePharmacy): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31'] 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.31-2018-06-30T000000.html"
              test="count(hl7:id[@root='2.16.840.1.113883.3.4424.2.6'][not(@nullFlavor)]) &gt;= 1">(plCdaBasePharmacy): element hl7:id[@root='2.16.840.1.113883.3.4424.2.6'][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.31-2018-06-30T000000.html"
              test="count(hl7:id[@root='2.16.840.1.113883.3.4424.2.6'][not(@nullFlavor)]) &lt;= 1">(plCdaBasePharmacy): element hl7:id[@root='2.16.840.1.113883.3.4424.2.6'][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.31-2018-06-30T000000.html"
              test="count(hl7:id[@root='2.16.840.1.113883.3.4424.2.2.1']) &lt;= 1">(plCdaBasePharmacy): element hl7:id[@root='2.16.840.1.113883.3.4424.2.2.1'] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.31-2018-06-30T000000.html"
              test="count(hl7:name) &gt;= 1">(plCdaBasePharmacy): 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.31-2018-06-30T000000.html"
              test="count(hl7:name) &lt;= 1">(plCdaBasePharmacy): 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.31-2018-06-30T000000.html"
              test="count(hl7:standardIndustryClassCode) = 0">(plCdaBasePharmacy): element hl7:standardIndustryClassCode 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.31-2018-06-30T000000.html"
              test="count(hl7:asOrganizationPartOf) &lt;= 1">(plCdaBasePharmacy): 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.31
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']
Item: (plCdaBasePharmacy)
-->

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

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:id[@root='2.16.840.1.113883.3.4424.2.6'][not(@nullFlavor)]"
         id="d16e5265-false-d23053e0">
      <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.31-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.2.6')">(plCdaBasePharmacy): The value for root SHALL be '2.16.840.1.113883.3.4424.2.6'. Found: "<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.31-2018-06-30T000000.html"
              test="@extension">(plCdaBasePharmacy): 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.31-2018-06-30T000000.html"
              test="not(@extension) or string-length(@extension)&gt;0">(plCdaBasePharmacy): Attribute @extension SHALL be of data type 'st'  - '<value-of select="@extension"/>'</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.31
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:id[@root='2.16.840.1.113883.3.4424.2.2.1']
Item: (plCdaBasePharmacy)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:id[@root='2.16.840.1.113883.3.4424.2.2.1']"
         id="d16e5272-false-d23068e0">
      <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.31-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.2.2.1')">(plCdaBasePharmacy): The value for root SHALL be '2.16.840.1.113883.3.4424.2.2.1'. Found: "<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.31-2018-06-30T000000.html"
              test="@extension">(plCdaBasePharmacy): 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.31-2018-06-30T000000.html"
              test="not(@extension) or string-length(@extension)&gt;0">(plCdaBasePharmacy): Attribute @extension SHALL be of data type 'st'  - '<value-of select="@extension"/>'</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.31
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:name
Item: (plCdaBasePharmacy)
-->

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

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:telecom"
         id="d16e5282-false-d23093e0">
      <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.31-2018-06-30T000000.html"
              test="string-length(@value)&gt;0">(plCdaBasePharmacy): Wartość dla telefonu, adresu email lub lokalizacji zasobu nie może by pusta.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.31
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:standardIndustryClassCode
Item: (plCdaBasePharmacy)
-->

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

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:asOrganizationPartOf"
         id="d16e5292-false-d23109e0">
      <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.31-2018-06-30T000000.html"
              test="string(@classCode) = ('PART') or not(@classCode)">(plCdaBasePharmacy): 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.31-2018-06-30T000000.html"
              test="count(hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]) &lt;= 1">(plCdaBasePharmacy): 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.31-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">(plCdaBasePharmacy): 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.31-2018-06-30T000000.html"
              test="count(hl7:effectiveTime) &lt;= 1">(plCdaBasePharmacy): 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.31-2018-06-30T000000.html"
              test="count(hl7:wholeOrganization) &lt;= 1">(plCdaBasePharmacy): 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.31
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:asOrganizationPartOf/hl7:id
Item: (plCdaBasePharmacy)
-->

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

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:asOrganizationPartOf/hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]"
         id="d16e5298-false-d23162e0">
      <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.31-2018-06-30T000000.html"
              test="@nullFlavor or (@codeSystem='2.16.840.1.113883.5.111')">(plCdaBasePharmacy): 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.31
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/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: (plCdaBasePharmacy)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/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="d16e5303-false-d23178e0">
      <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.31-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)">(plCdaBasePharmacy): 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.31
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.31']]/hl7:asOrganizationPartOf/hl7:effectiveTime
Item: (plCdaBasePharmacy)
-->

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