<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.4.276
Name: [4] KMCR Vb Postępowanie z pacjentem, Leki
Description: KMCR Vb Postępowanie z pacjentem, Leki
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.4.276-2025-02-26T000000-closed">
   <title>[4] KMCR Vb Postępowanie z pacjentem, Leki</title>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]]/*[not(@xsi:nil = 'true')][not(self::hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']])]"
         id="d16e12133-true-d47576e0">
      <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.4.276-2025-02-26T000000.html"
              test="not(.)">(plCdaRescueMedicationAdministrationEntry)/d16e12133-true-d47576e0: '<value-of select="name(..)"/>' is defined as closed, and this element '<name/>' is not allowed, or not allowed with this content. This may concern the templateId, code or id. Expected in this context:  hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']] (rule-reference: d16e12133-true-d47576e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]/*[not(@xsi:nil = 'true')][not(self::hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276'] | self::hl7:code[(@code = 'MEDLIST' and @codeSystem = '2.16.840.1.113883.11.13953')] | self::hl7:statusCode[@code = 'completed'] | self::hl7:component[not(@nullFlavor)][hl7:substanceAdministration[@classCode = 'SBADM'][@moodCode = 'EVN']])]"
         id="d16e12189-true-d47612e0">
      <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.4.276-2025-02-26T000000.html"
              test="not(.)">(plCdaRescueMedicationAdministrationEntry)/d16e12189-true-d47612e0: '<value-of select="name(..)"/>' is defined as closed, and this element '<name/>' is not allowed, or not allowed with this content. This may concern the templateId, code or id. Expected in this context:  hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276'] | hl7:code[(@code = 'MEDLIST' and @codeSystem = '2.16.840.1.113883.11.13953')] | hl7:statusCode[@code = 'completed'] | hl7:component[not(@nullFlavor)][hl7:substanceAdministration[@classCode = 'SBADM'][@moodCode = 'EVN']] (rule-reference: d16e12189-true-d47612e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]/hl7:code[(@code = 'MEDLIST' and @codeSystem = '2.16.840.1.113883.11.13953')]/*[not(@xsi:nil = 'true')][not(self::hl7:translation[(@code = 'KMCR_Vb' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')])]"
         id="d16e12200-true-d47635e0">
      <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.4.276-2025-02-26T000000.html"
              test="not(.)">(plCdaRescueMedicationAdministrationEntry)/d16e12200-true-d47635e0: '<value-of select="name(..)"/>' is defined as closed, and this element '<name/>' is not allowed, or not allowed with this content. This may concern the templateId, code or id. Expected in this context:  hl7:translation[(@code = 'KMCR_Vb' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')] (rule-reference: d16e12200-true-d47635e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]/hl7:component[not(@nullFlavor)][hl7:substanceAdministration[@classCode = 'SBADM'][@moodCode = 'EVN']]/*[not(@xsi:nil = 'true')][not(self::hl7:substanceAdministration[not(@nullFlavor)][@classCode = 'SBADM'][@moodCode = 'EVN'][hl7:consumable])]"
         id="d16e12216-true-d47661e0">
      <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.4.276-2025-02-26T000000.html"
              test="not(.)">(plCdaRescueMedicationAdministrationEntry)/d16e12216-true-d47661e0: '<value-of select="name(..)"/>' is defined as closed, and this element '<name/>' is not allowed, or not allowed with this content. This may concern the templateId, code or id. Expected in this context:  hl7:substanceAdministration[not(@nullFlavor)][@classCode = 'SBADM'][@moodCode = 'EVN'][hl7:consumable] (rule-reference: d16e12216-true-d47661e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]/hl7:component[not(@nullFlavor)][hl7:substanceAdministration[@classCode = 'SBADM'][@moodCode = 'EVN']]/hl7:substanceAdministration[not(@nullFlavor)][@classCode = 'SBADM'][@moodCode = 'EVN'][hl7:consumable]/*[not(@xsi:nil = 'true')][not(self::hl7:text[not(@nullFlavor)] | self::hl7:routeCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.14581-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor] | self::hl7:consumable[not(@nullFlavor)][hl7:manufacturedProduct])]"
         id="d16e12220-true-d47691e0">
      <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.4.276-2025-02-26T000000.html"
              test="not(.)">(plCdaRescueMedicationAdministrationEntry)/d16e12220-true-d47691e0: '<value-of select="name(..)"/>' is defined as closed, and this element '<name/>' is not allowed, or not allowed with this content. This may concern the templateId, code or id. Expected in this context:  hl7:text[not(@nullFlavor)] | hl7:routeCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.14581-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor] | hl7:consumable[not(@nullFlavor)][hl7:manufacturedProduct] (rule-reference: d16e12220-true-d47691e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]/hl7:component[not(@nullFlavor)][hl7:substanceAdministration[@classCode = 'SBADM'][@moodCode = 'EVN']]/hl7:substanceAdministration[not(@nullFlavor)][@classCode = 'SBADM'][@moodCode = 'EVN'][hl7:consumable]/hl7:consumable[not(@nullFlavor)][hl7:manufacturedProduct]/*[not(@xsi:nil = 'true')][not(self::hl7:manufacturedProduct[not(@nullFlavor)][hl7:manufacturedMaterial])]"
         id="d16e12240-true-d47718e0">
      <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.4.276-2025-02-26T000000.html"
              test="not(.)">(plCdaRescueMedicationAdministrationEntry)/d16e12240-true-d47718e0: '<value-of select="name(..)"/>' is defined as closed, and this element '<name/>' is not allowed, or not allowed with this content. This may concern the templateId, code or id. Expected in this context:  hl7:manufacturedProduct[not(@nullFlavor)][hl7:manufacturedMaterial] (rule-reference: d16e12240-true-d47718e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]/hl7:component[not(@nullFlavor)][hl7:substanceAdministration[@classCode = 'SBADM'][@moodCode = 'EVN']]/hl7:substanceAdministration[not(@nullFlavor)][@classCode = 'SBADM'][@moodCode = 'EVN'][hl7:consumable]/hl7:consumable[not(@nullFlavor)][hl7:manufacturedProduct]/hl7:manufacturedProduct[not(@nullFlavor)][hl7:manufacturedMaterial]/*[not(@xsi:nil = 'true')][not(self::hl7:manufacturedMaterial[not(@nullFlavor)])]"
         id="d16e12242-true-d47732e0">
      <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.4.276-2025-02-26T000000.html"
              test="not(.)">(plCdaRescueMedicationAdministrationEntry)/d16e12242-true-d47732e0: '<value-of select="name(..)"/>' is defined as closed, and this element '<name/>' is not allowed, or not allowed with this content. This may concern the templateId, code or id. Expected in this context:  hl7:manufacturedMaterial[not(@nullFlavor)] (rule-reference: d16e12242-true-d47732e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]]/hl7:organizer[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.276']]/hl7:component[not(@nullFlavor)][hl7:substanceAdministration[@classCode = 'SBADM'][@moodCode = 'EVN']]/hl7:substanceAdministration[not(@nullFlavor)][@classCode = 'SBADM'][@moodCode = 'EVN'][hl7:consumable]/hl7:consumable[not(@nullFlavor)][hl7:manufacturedProduct]/hl7:manufacturedProduct[not(@nullFlavor)][hl7:manufacturedMaterial]/hl7:manufacturedMaterial[not(@nullFlavor)]/*[not(@xsi:nil = 'true')][not(self::hl7:code[@codeSystem = '2.16.840.1.113883.3.4424.6.1' or @nullFlavor] | self::hl7:name[not(@nullFlavor)])]"
         id="d16e12244-true-d47753e0">
      <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.4.276-2025-02-26T000000.html"
              test="not(.)">(plCdaRescueMedicationAdministrationEntry)/d16e12244-true-d47753e0: '<value-of select="name(..)"/>' is defined as closed, and this element '<name/>' is not allowed, or not allowed with this content. This may concern the templateId, code or id. Expected in this context:  hl7:code[@codeSystem = '2.16.840.1.113883.3.4424.6.1' or @nullFlavor] | hl7:name[not(@nullFlavor)] (rule-reference: d16e12244-true-d47753e0)</assert>
   </rule>
</pattern>
