<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.2.131
Name: [2] Treść karty medycznych czynności ratunkowych
Description: Bazowy szablon struktury CDA dla treści medycznej dokumentu.
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.2.131-2025-02-26T000000">
   <title>[2] Treść karty medycznych czynności ratunkowych</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.131
Context: *[hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]]
Item: (plCdaParamedicRescueSummaryNoteComponent)
-->

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

   <rule fpi="RULC-1"
         context="*[hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]]/hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]"
         id="d16e3038-false-d14649e0">
      <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.131-2025-02-26T000000.html"
              test="string(@typeCode) = ('COMP') or not(@typeCode)">(plCdaParamedicRescueSummaryNoteComponent): The value for typeCode SHALL be 'COMP'. 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.131-2025-02-26T000000.html"
              test="not(@contextConductionInd) or string(@contextConductionInd)=('true','false')">(plCdaParamedicRescueSummaryNoteComponent): Attribute @contextConductionInd SHALL be of data type 'bl'  - '<value-of select="@contextConductionInd"/>'</assert>
      <report 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.131-2025-02-26T000000.html"
              test="count(//(hl7:observation|hl7:substanceAdministration|hl7:supply|hl7:procedure|hl7:encounter|hl7:act|hl7:externalDocument)[not(ancestor::hl7:section/hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.3.222']) and not(ancestor::hl7:entryRelationship) and not(hl7:text/hl7:reference)])&gt;0">(plCdaParamedicRescueSummaryNoteComponent): Element text dla danego wyrażenia klinicznego jest wymagany, ze wskazaniem referencji do odpowiedniego elementu section.text.</report>
      <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.131-2025-02-26T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']) &gt;= 1">(plCdaParamedicRescueSummaryNoteComponent): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130'] 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.131-2025-02-26T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']) &lt;= 1">(plCdaParamedicRescueSummaryNoteComponent): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130'] 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.131-2025-02-26T000000.html"
              test="count(hl7:structuredBody[not(@nullFlavor)][hl7:component]) &gt;= 1">(plCdaParamedicRescueSummaryNoteComponent): element hl7:structuredBody[not(@nullFlavor)][hl7:component] 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.131-2025-02-26T000000.html"
              test="count(hl7:structuredBody[not(@nullFlavor)][hl7:component]) &lt;= 1">(plCdaParamedicRescueSummaryNoteComponent): element hl7:structuredBody[not(@nullFlavor)][hl7:component] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.131
Context: *[hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]]/hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']
Item: (plCdaParamedicRescueSummaryNoteComponent)
-->

   <rule fpi="RULC-1"
         context="*[hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]]/hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']"
         id="d16e3044-false-d14925e0">
      <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.131-2025-02-26T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.2.130')">(plCdaParamedicRescueSummaryNoteComponent): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.2.130'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.131
Context: *[hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]]/hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]/hl7:structuredBody[not(@nullFlavor)][hl7:component]
Item: (plCdaParamedicRescueSummaryNoteComponent)
-->

   <rule fpi="RULC-1"
         context="*[hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]]/hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]/hl7:structuredBody[not(@nullFlavor)][hl7:component]"
         id="d16e3049-false-d15179e0">
      <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.131-2025-02-26T000000.html"
              test="not(hl7:component[not(hl7:section/hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.222')])">(plCdaParamedicRescueSummaryNoteComponent): Jeżeli w dokumencie znajduje się sekcja postaci binarnej dokumentu, to nie może występować sekcja innego typu.</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.131-2025-02-26T000000.html"
              test="count(hl7:component[hl7:section[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.3.222']]]) &gt;= 1">(plCdaParamedicRescueSummaryNoteComponent): element hl7:component[hl7:section[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.3.222']]] 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.131-2025-02-26T000000.html"
              test="count(hl7:component[hl7:section[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.3.222']]]) &lt;= 1">(plCdaParamedicRescueSummaryNoteComponent): element hl7:component[hl7:section[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.3.222']]] appears too often [max 1x].</assert>
   </rule>

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.131
Context: *[hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]]/hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]/hl7:structuredBody[not(@nullFlavor)][hl7:component]/hl7:component[hl7:section[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.3.222']]]
Item: (plCdaParamedicRescueSummaryNoteComponent)
-->
   <rule fpi="RULC-1"
         context="*[hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]]/hl7:component[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.130']]/hl7:structuredBody[not(@nullFlavor)][hl7:component]/hl7:component[hl7:section[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.3.222']]]">
      <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.131-2025-02-26T000000.html"
              test="string(@typeCode) = ('COMP') or not(@typeCode)">(plCdaParamedicRescueSummaryNoteComponent): The value for typeCode SHALL be 'COMP'. Found: "<value-of select="@typeCode"/>"</assert>
   </rule>
</pattern>
