<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.3.195
Name: [3] Sekcja uzasadnienia korygowania dokumentu
Description: Szablon struktury CDA dla sekcji uzasadnienia korygowania dokumentu
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000">
   <title>[3] Sekcja uzasadnienia korygowania dokumentu</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.3.195
Context: *[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]
Item: (ReasonForCorretingDocSection)
-->

   <rule context="*[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195'])&gt;=1 and not(hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/@nullFlavor)">(ReasonForCorretingDocSection): element hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195'] jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195'])&lt;=1">(ReasonForCorretingDocSection): element hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195'] występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.3.195
Context: *[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']
Item: (ReasonForCorretingDocSection)
-->

   <rule context="*[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="string(@classCode)='DOCSECT' or not(@classCode)">(ReasonForCorretingDocSection): Wartość dla @classCode MUSI wynosić 'DOCSECT'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="string(@moodCode)='EVN' or not(@moodCode)">(ReasonForCorretingDocSection): Wartość dla @moodCode MUSI wynosić 'EVN'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.3.195'])&gt;=1 and not(hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.3.195']/@nullFlavor)">(ReasonForCorretingDocSection): element hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.3.195'] jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.3.195'])&lt;=1">(ReasonForCorretingDocSection): element hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.3.195'] występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:code[(@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1')])&gt;=1 and not(hl7:code[(@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1')]/@nullFlavor)">(ReasonForCorretingDocSection): element hl7:code[(@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1')] jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:code[(@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1')])&lt;=1">(ReasonForCorretingDocSection): element hl7:code[(@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1')] występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:title)&gt;=1 and not(hl7:title/@nullFlavor)">(ReasonForCorretingDocSection): element hl7:title jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:title)&lt;=1">(ReasonForCorretingDocSection): element hl7:title występuje zbyt często [max 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:text)&gt;=1 and not(hl7:text/@nullFlavor)">(ReasonForCorretingDocSection): element hl7:text jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:text)&lt;=1">(ReasonForCorretingDocSection): element hl7:text występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.3.195
Context: *[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.3.195']
Item: (ReasonForCorretingDocSection)
-->

   <rule context="*[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:templateId[@root='2.16.840.1.113883.3.4424.13.10.3.195']"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='II' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(ReasonForCorretingDocSection): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:II", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="II"/>
      <let name="theValue" value="@value"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="string(@root)='2.16.840.1.113883.3.4424.13.10.3.195'">(ReasonForCorretingDocSection): Wartość dla @root MUSI wynosić '2.16.840.1.113883.3.4424.13.10.3.195'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="not(@root) or matches(@root,'^[0-2](\.(0|[1-9][0-9]*))*$')">(ReasonForCorretingDocSection): Atrybut @root MUSI być typu 'oid'</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.3.195
Context: *[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:code[(@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1')]
Item: (ReasonForCorretingDocSection)
-->

   <rule context="*[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:code[(@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1')]"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='CE' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(ReasonForCorretingDocSection): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:CE", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="CE"/>
      <let name="theValue" value="@value"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="@nullFlavor or (@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1' and @displayName='Annotation comment' and @codeSystemName='LOINC')">(ReasonForCorretingDocSection): Wartość elementu MUSI wynosić code '48767-8' codeSystem '2.16.840.1.113883.6.1' displayName='Annotation comment' codeSystemName='LOINC'.</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:translation[(@code='UZASKORDOK' and @codeSystem='2.16.840.1.113883.3.4424.13.5.14')])&gt;=1 and not(hl7:translation[(@code='UZASKORDOK' and @codeSystem='2.16.840.1.113883.3.4424.13.5.14')]/@nullFlavor)">(ReasonForCorretingDocSection): element hl7:translation[(@code='UZASKORDOK' and @codeSystem='2.16.840.1.113883.3.4424.13.5.14')] jest mandatory [min 1x].</assert>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="count(hl7:translation[(@code='UZASKORDOK' and @codeSystem='2.16.840.1.113883.3.4424.13.5.14')])&lt;=1">(ReasonForCorretingDocSection): element hl7:translation[(@code='UZASKORDOK' and @codeSystem='2.16.840.1.113883.3.4424.13.5.14')] występuje zbyt często [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.3.195
Context: *[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:code[(@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1')]/hl7:translation[(@code='UZASKORDOK' and @codeSystem='2.16.840.1.113883.3.4424.13.5.14')]
Item: (ReasonForCorretingDocSection)
-->

   <rule context="*[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:code[(@code='48767-8' and @codeSystem='2.16.840.1.113883.6.1')]/hl7:translation[(@code='UZASKORDOK' and @codeSystem='2.16.840.1.113883.3.4424.13.5.14')]"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="@nullFlavor or (@code='UZASKORDOK' and @codeSystem='2.16.840.1.113883.3.4424.13.5.14' and @displayName='Uzasadnienie korygowania dokumentu' and @codeSystemName='AtrybutyWBHIST')">(ReasonForCorretingDocSection): Wartość elementu MUSI wynosić code 'UZASKORDOK' codeSystem '2.16.840.1.113883.3.4424.13.5.14' displayName='Uzasadnienie korygowania dokumentu' codeSystemName='AtrybutyWBHIST'.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.3.195
Context: *[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:title
Item: (ReasonForCorretingDocSection)
-->

   <rule context="*[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:title"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='ST' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(ReasonForCorretingDocSection): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:ST", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="ST"/>
      <let name="theValue" value="text()"/>
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="text()='Uzasadnienie przyczyny zmian dokumentu'">(ReasonForCorretingDocSection): zawartość elementu hl7:title MUSI wynosić ''Uzasadnienie przyczyny zmian dokumentu''.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.3.195
Context: *[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:text
Item: (ReasonForCorretingDocSection)
-->

   <rule context="*[hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']]/hl7:section[hl7:templateId/@root='2.16.840.1.113883.3.4424.13.10.3.195']/hl7:text"
         id="tmp-">
      <assert role="error"
              see="https://www.cez.gov.pl/HL7POL-1.3.2/plcda-html-1.3.2/plcda-html/plcda-html-develop/tmp-2.16.840.1.113883.3.4424.13.10.3.195-2023-04-27T000000.html"
              test="(local-name-from-QName(resolve-QName(@xsi:type,.))='SD.TEXT' and namespace-uri-from-QName(resolve-QName(@xsi:type,.))='urn:hl7-org:v3') or not(@xsi:type)">(ReasonForCorretingDocSection): Jeśli występuje instrukcja @xsi:type, to MUSI mieć wartość "{urn:hl7-org:v3}:SD.TEXT", znaleziono "{<value-of select="namespace-uri-from-QName(resolve-QName(@xsi:type,.))"/>}:<value-of select="local-name-from-QName(resolve-QName(@xsi:type,.))"/>"</assert>
      <extends rule="SD.TEXT"/>
      <let name="theValue" value="@value"/>
   </rule>
</pattern>
