<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.4.18
Name: [4] Autor fragmentu treści dokumentu
Description: 
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.4.18-2018-06-30T000000">
   <title>[4] Autor fragmentu treści dokumentu</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]
Item: (plCdaBaseBodyAuthor)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]"
         id="d16e7768-false-d31142e0">
      <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.18-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']) &gt;= 1">(plCdaBaseBodyAuthor): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18'] 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.4.18-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']) &lt;= 1">(plCdaBaseBodyAuthor): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18'] 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.4.18-2018-06-30T000000.html"
              test="count(hl7:functionCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.10267-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseBodyAuthor): element hl7:functionCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.10267-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @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.4.18-2018-06-30T000000.html"
              test="count(hl7:time) &gt;= 1">(plCdaBaseBodyAuthor): element hl7:time 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.4.18-2018-06-30T000000.html"
              test="count(hl7:time) &lt;= 1">(plCdaBaseBodyAuthor): element hl7:time 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.4.18-2018-06-30T000000.html"
              test="count(hl7:assignedAuthor) &gt;= 1">(plCdaBaseBodyAuthor): element hl7:assignedAuthor 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.4.18-2018-06-30T000000.html"
              test="count(hl7:assignedAuthor) &lt;= 1">(plCdaBaseBodyAuthor): element hl7:assignedAuthor appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']
Item: (plCdaBaseBodyAuthor)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']"
         id="d16e7814-false-d31203e0">
      <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.18-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.4.18')">(plCdaBaseBodyAuthor): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.4.18'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:functionCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.10267-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]
Item: (plCdaBaseBodyAuthor)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:functionCode[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.10267-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]"
         id="d16e7819-false-d31217e0">
      <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.4.18-2018-06-30T000000.html"
              test="@nullFlavor or exists(doc('include/voc-2.16.840.1.113883.1.11.10267-DYNAMIC.xml')//valueSet[1][conceptList/concept[@code = $theCode][@codeSystem = $theCodeSystem]])">(plCdaBaseBodyAuthor): The element value SHALL be one of '2.16.840.1.113883.1.11.10267 ParticipationFunction (DYNAMIC)'.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:time
Item: (plCdaBaseBodyAuthor)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor
Item: (plCdaBaseBodyAuthor)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor"
         id="d16e7826-false-d31261e0">
      <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.18-2018-06-30T000000.html"
              test="string(@classCode) = ('ASSIGNED') or not(@classCode)">(plCdaBaseBodyAuthor): 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.4.18-2018-06-30T000000.html"
              test="count(hl7:id) &gt;= 1">(plCdaBaseBodyAuthor): element hl7:id 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.4.18-2018-06-30T000000.html"
              test="count(hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]) &lt;= 1">(plCdaBaseBodyAuthor): element hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor] appears too often [max 1x].</assert>
      <let name="elmcount"
           value="count(hl7:assignedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']] | hl7:assignedAuthoringDevice[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.25']])"/>
      <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.18-2018-06-30T000000.html"
              test="$elmcount &lt;= 1">(plCdaBaseBodyAuthor): choice (hl7:assignedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]  or  hl7:assignedAuthoringDevice[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.25']]) contains too many elements [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.4.18-2018-06-30T000000.html"
              test="count(hl7:representedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]) &lt;= 1">(plCdaBaseBodyAuthor): element hl7:representedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor/hl7:id
Item: (plCdaBaseBodyAuthor)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor/hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]
Item: (plCdaBaseBodyAuthor)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor/hl7:code[@codeSystem = '2.16.840.1.113883.5.111' or @nullFlavor]"
         id="d16e7832-false-d31343e0">
      <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.18-2018-06-30T000000.html"
              test="@nullFlavor or (@codeSystem='2.16.840.1.113883.5.111')">(plCdaBaseBodyAuthor): The element value SHALL be one of 'codeSystem '2.16.840.1.113883.5.111''.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor/hl7:addr
Item: (plCdaBaseBodyAuthor)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor/hl7:telecom
Item: (plCdaBaseBodyAuthor)
-->


   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor/hl7:assignedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]
Item: (plCdaBaseBodyAuthor)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor/hl7:assignedAuthoringDevice[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.25']]
Item: (plCdaBaseBodyAuthor)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.18
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.18']]/hl7:assignedAuthor/hl7:representedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.2']]
Item: (plCdaBaseBodyAuthor)
--></pattern>
