<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.4.301
Name: [4] Wezwanie zespołu ratownictwa medycznego
Description: Wezwanie zespołu ratownictwa medycznego
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.4.301-2025-02-26T000000-closed">
   <title>[4] Wezwanie zespołu ratownictwa medycznego</title>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/*[not(@xsi:nil = 'true')][not(self::hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']])]"
         id="d16e14027-true-d54230e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d16e14027-true-d54230e0: '<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:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']] (rule-reference: d16e14027-true-d54230e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]/*[not(@xsi:nil = 'true')][not(self::hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301'] | self::hl7:id[not(@nullFlavor)] | self::hl7:code[(@code = 'I' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')] | self::hl7:statusCode[@code = 'completed'] | self::hl7:performer[hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]] | self::hl7:participant[@typeCode='INF'][not(@nullFlavor)] | self::hl7:participant[@typeCode='LOC'][not(@nullFlavor)])]"
         id="d16e14166-true-d54296e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d16e14166-true-d54296e0: '<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.301'] | hl7:id[not(@nullFlavor)] | hl7:code[(@code = 'I' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')] | hl7:statusCode[@code = 'completed'] | hl7:performer[hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]] | hl7:participant[@typeCode='INF'][not(@nullFlavor)] | hl7:participant[@typeCode='LOC'][not(@nullFlavor)] (rule-reference: d16e14166-true-d54296e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]/hl7:performer[hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]]/*[not(@xsi:nil = 'true')][not(self::hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']])]"
         id="d16e14190-true-d54351e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d16e14190-true-d54351e0: '<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:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']] (rule-reference: d16e14190-true-d54351e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]/hl7:performer[hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]]/hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]/*[not(@xsi:nil = 'true')][not(self::hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133'] | self::hl7:id[not(@nullFlavor)] | self::hl7:code[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.3.4424.13.11.230-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem)] | self::hl7:addr | self::hl7:telecom | self::hl7:assignedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']] | self::hl7:representedOrganization[not(@nullFlavor)])]"
         id="d54324e3-true-d54418e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d54324e3-true-d54418e0: '<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.2.133'] | hl7:id[not(@nullFlavor)] | hl7:code[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.3.4424.13.11.230-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem)] | hl7:addr | hl7:telecom | hl7:assignedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']] | hl7:representedOrganization[not(@nullFlavor)] (rule-reference: d54324e3-true-d54418e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]/hl7:performer[hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]]/hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]/hl7:assignedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]/*[not(@xsi:nil = 'true')][not(self::hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1'] | self::hl7:name)]"
         id="d54324e24-true-d54472e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d54324e24-true-d54472e0: '<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.2.1'] | hl7:name (rule-reference: d54324e24-true-d54472e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]/hl7:performer[hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]]/hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]/hl7:representedOrganization[not(@nullFlavor)]/*[not(@xsi:nil = 'true')][not(self::hl7:id[not(@nullFlavor)])]"
         id="d54324e26-true-d54497e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d54324e26-true-d54497e0: '<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:id[not(@nullFlavor)] (rule-reference: d54324e26-true-d54497e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]/hl7:participant[@typeCode='INF'][not(@nullFlavor)]/*[not(@xsi:nil = 'true')][not(self::hl7:participantRole[hl7:code[(@code = 'If' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')]])]"
         id="d16e14195-true-d54516e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d16e14195-true-d54516e0: '<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:participantRole[hl7:code[(@code = 'If' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')]] (rule-reference: d16e14195-true-d54516e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]/hl7:participant[@typeCode='INF'][not(@nullFlavor)]/hl7:participantRole[hl7:code[(@code = 'If' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')]]/*[not(@xsi:nil = 'true')][not(self::hl7:id[not(@nullFlavor)] | self::hl7:code[(@code = 'If' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')])]"
         id="d16e14199-true-d54538e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d16e14199-true-d54538e0: '<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:id[not(@nullFlavor)] | hl7:code[(@code = 'If' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')] (rule-reference: d16e14199-true-d54538e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]/hl7:participant[@typeCode='LOC'][not(@nullFlavor)]/*[not(@xsi:nil = 'true')][not(self::hl7:participantRole[hl7:code[(@code = 'Ia' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')]])]"
         id="d16e14212-true-d54563e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d16e14212-true-d54563e0: '<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:participantRole[hl7:code[(@code = 'Ia' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')]] (rule-reference: d16e14212-true-d54563e0)</assert>
   </rule>

   <!-- Checking undefined contents for template/element @isClosed="true". Match context that we did not already match -->
   <rule fpi="RUL-QQQ"
         context="*[hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]]/hl7:encounter[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.301']]/hl7:participant[@typeCode='LOC'][not(@nullFlavor)]/hl7:participantRole[hl7:code[(@code = 'Ia' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')]]/*[not(@xsi:nil = 'true')][not(self::hl7:code[(@code = 'Ia' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')] | self::hl7:addr[not(@nullFlavor)])]"
         id="d16e14216-true-d54585e0">
      <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.301-2025-02-26T000000.html"
              test="not(.)">(plCdaEmergencyMedicalServiceEncounter)/d16e14216-true-d54585e0: '<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[(@code = 'Ia' and @codeSystem = '2.16.840.1.113883.3.4424.13.5.30.1')] | hl7:addr[not(@nullFlavor)] (rule-reference: d16e14216-true-d54585e0)</assert>
   </rule>
</pattern>
