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

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

   <rule fpi="RULC-1"
         context="*[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]"
         id="d16e6033-false-d25213e0">
      <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.53-2018-06-30T000000.html"
              test="string(@typeCode) = ('FLFS') or not(@typeCode)">(plCdaBaseInFulfillmentOf): The value for typeCode SHALL be 'FLFS'. 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.53-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']) &gt;= 1">(plCdaBaseInFulfillmentOf): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53'] 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.53-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']) &lt;= 1">(plCdaBaseInFulfillmentOf): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53'] 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.53-2018-06-30T000000.html"
              test="count(hl7:order[@moodCode = 'RQO']) &gt;= 1">(plCdaBaseInFulfillmentOf): element hl7:order[@moodCode = 'RQO'] 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.53-2018-06-30T000000.html"
              test="count(hl7:order[@moodCode = 'RQO']) &lt;= 1">(plCdaBaseInFulfillmentOf): element hl7:order[@moodCode = 'RQO'] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.53
Context: *[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']
Item: (plCdaBaseInFulfillmentOf)
-->

   <rule fpi="RULC-1"
         context="*[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']"
         id="d16e6037-false-d25243e0">
      <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.53-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.2.53')">(plCdaBaseInFulfillmentOf): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.2.53'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.53
Context: *[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]/hl7:order[@moodCode = 'RQO']
Item: (plCdaBaseInFulfillmentOf)
-->

   <rule fpi="RULC-1"
         context="*[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]/hl7:order[@moodCode = 'RQO']"
         id="d16e6042-false-d25254e0">
      <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.53-2018-06-30T000000.html"
              test="string(@classCode) = ('ACT') or not(@classCode)">(plCdaBaseInFulfillmentOf): The value for classCode SHALL be 'ACT'. 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.53-2018-06-30T000000.html"
              test="string(@moodCode) = ('RQO')">(plCdaBaseInFulfillmentOf): The value for moodCode SHALL be 'RQO'. Found: "<value-of select="@moodCode"/>"</assert>
      <assert role="error"
              see="https://www.csioz.gov.pl/HL7POL/pl-cda-html-pl-PL/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.2.53-2018-06-30T000000.html"
              test="count(hl7:id[not(@nullFlavor)]) &gt;= 1">(plCdaBaseInFulfillmentOf): 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.53-2018-06-30T000000.html"
              test="count(hl7:code[@codeSystem = '2.16.840.1.113883.5.4' or @nullFlavor]) &lt;= 1">(plCdaBaseInFulfillmentOf): element hl7:code[@codeSystem = '2.16.840.1.113883.5.4' 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.53-2018-06-30T000000.html"
              test="count(hl7:priorityCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.16866-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseInFulfillmentOf): element hl7:priorityCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.16866-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.53
Context: *[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]/hl7:order[@moodCode = 'RQO']/hl7:id[not(@nullFlavor)]
Item: (plCdaBaseInFulfillmentOf)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.53
Context: *[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]/hl7:order[@moodCode = 'RQO']/hl7:code[@codeSystem = '2.16.840.1.113883.5.4' or @nullFlavor]
Item: (plCdaBaseInFulfillmentOf)
-->

   <rule fpi="RULC-1"
         context="*[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]/hl7:order[@moodCode = 'RQO']/hl7:code[@codeSystem = '2.16.840.1.113883.5.4' or @nullFlavor]"
         id="d16e6050-false-d25301e0">
      <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.53-2018-06-30T000000.html"
              test="@nullFlavor or (@codeSystem='2.16.840.1.113883.5.4')">(plCdaBaseInFulfillmentOf): The element value SHALL be one of 'codeSystem '2.16.840.1.113883.5.4''.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.53
Context: *[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]/hl7:order[@moodCode = 'RQO']/hl7:priorityCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.16866-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaBaseInFulfillmentOf)
-->

   <rule fpi="RULC-1"
         context="*[hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]]/hl7:inFulfillmentOf[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.53']]/hl7:order[@moodCode = 'RQO']/hl7:priorityCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.16866-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e6055-false-d25317e0">
      <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.53-2018-06-30T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.16866-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaBaseInFulfillmentOf): The element value SHALL be one of '2.16.840.1.113883.1.11.16866 ActPriority (DYNAMIC)'.</assert>
   </rule>
</pattern>
