<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.2.133
Name: [2] Osoba przypisana w karcie medycznych czynności ratunkowych
Description: Bazowy szablon CDA dla przypisanej osoby z danej organizacji w karcie medycznych czynności ratunkowych
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.2.133-2025-02-26T000000">
   <title>[2] Osoba przypisana w karcie medycznych czynności ratunkowych</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]]
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->

   <rule fpi="RULC-1"
         context="*[hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]]"
         id="d16e3065-false-d15708e0">
      <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.133-2025-02-26T000000.html"
              test="count(hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]) &gt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']] 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.133-2025-02-26T000000.html"
              test="count(hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']]) &lt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element hl7:assignedEntity[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[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']]
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->

   <rule fpi="RULC-1"
         context="*[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']]"
         id="d16e3116-false-d15733e0">
      <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.133-2025-02-26T000000.html"
              test="string(@classCode) = ('ASSIGNED') or not(@classCode)">(plCdaParamedicRescueSummaryNoteAssignedEntity): The value for classCode SHALL be 'ASSIGNED'. 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.133-2025-02-26T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']) &gt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133'] 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.133-2025-02-26T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']) &lt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133'] 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.133-2025-02-26T000000.html"
              test="count(hl7:id[not(@nullFlavor)]) &gt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): 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.133-2025-02-26T000000.html"
              test="count(hl7:id[not(@nullFlavor)]) &lt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element hl7:id[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.133-2025-02-26T000000.html"
              test="count(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)]) &gt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element 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)] 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.133-2025-02-26T000000.html"
              test="count(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)]) &lt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element 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)] 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.133-2025-02-26T000000.html"
              test="count(hl7:assignedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]) &lt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element hl7:assignedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.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.133-2025-02-26T000000.html"
              test="count(hl7:representedOrganization[not(@nullFlavor)]) &gt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element hl7:representedOrganization[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.133-2025-02-26T000000.html"
              test="count(hl7:representedOrganization[not(@nullFlavor)]) &lt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element hl7:representedOrganization[not(@nullFlavor)] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[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:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->

   <rule fpi="RULC-1"
         context="*[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:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.133']"
         id="d16e3120-false-d15801e0">
      <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.133-2025-02-26T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.2.133')">(plCdaParamedicRescueSummaryNoteAssignedEntity): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.2.133'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[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:id[not(@nullFlavor)]
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[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: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)]
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->

   <rule fpi="RULC-1"
         context="*[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: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)]"
         id="d16e3127-false-d15823e0">
      <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.133-2025-02-26T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.3.4424.13.11.230-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaParamedicRescueSummaryNoteAssignedEntity): The element value SHALL be one of '2.16.840.1.113883.3.4424.13.11.230 Role członków ZRM (DYNAMIC)'.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[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:addr
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[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:telecom
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->


   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[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']]
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[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)]
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->

   <rule fpi="RULC-1"
         context="*[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)]"
         id="d16e3139-false-d15873e0">
      <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.133-2025-02-26T000000.html"
              test="count(hl7:id[not(@nullFlavor)]) &gt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): 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.133-2025-02-26T000000.html"
              test="count(hl7:id[not(@nullFlavor)]) &lt;= 1">(plCdaParamedicRescueSummaryNoteAssignedEntity): element hl7:id[not(@nullFlavor)] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.133
Context: *[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)]/hl7:id[not(@nullFlavor)]
Item: (plCdaParamedicRescueSummaryNoteAssignedEntity)
-->
</pattern>
