<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.2.61
Name: [2] Odbiorca informacji (bazowy)
Description: Bazowy szablon CDA dla odbiorcy informacji
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.2.61-2018-09-30T000000">
   <title>[2] Odbiorca informacji (bazowy)</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.61
Context: *[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]
Item: (plCdaBaseInformationRecipient)
-->

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

   <rule fpi="RULC-1"
         context="*[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]"
         id="d16e3869-false-d18186e0">
      <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.61-2018-09-30T000000.html"
              test="@typeCode">(plCdaBaseInformationRecipient): attribute @typeCode SHALL be present.</assert>
      <let name="theAttValue"
           value="distinct-values(tokenize(normalize-space(@typeCode),'\s'))"/>
      <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.61-2018-09-30T000000.html"
              test="not(@typeCode) or empty($theAttValue[not(. = (doc('include/voc-2.16.840.1.113883.1.11.19366-DYNAMIC.xml')/*/valueSet/conceptList/concept/@code))])">(plCdaBaseInformationRecipient): The value for typeCode SHALL be selected from value set '2.16.840.1.113883.1.11.19366' x_InformationRecipient (DYNAMIC).</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.61-2018-09-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']) &gt;= 1">(plCdaBaseInformationRecipient): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61'] 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.61-2018-09-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']) &lt;= 1">(plCdaBaseInformationRecipient): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61'] 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.61-2018-09-30T000000.html"
              test="count(hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]]) &gt;= 1">(plCdaBaseInformationRecipient): element hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]] 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.61-2018-09-30T000000.html"
              test="count(hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]]) &lt;= 1">(plCdaBaseInformationRecipient): element hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.61
Context: *[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']
Item: (plCdaBaseInformationRecipient)
-->

   <rule fpi="RULC-1"
         context="*[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']"
         id="d16e3876-false-d18241e0">
      <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.61-2018-09-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.2.61')">(plCdaBaseInformationRecipient): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.2.61'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.61
Context: *[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]/hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]]
Item: (plCdaBaseInformationRecipient)
-->

   <rule fpi="RULC-1"
         context="*[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]/hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]]"
         id="d16e3881-false-d18266e0">
      <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.61-2018-09-30T000000.html"
              test="@classCode">(plCdaBaseInformationRecipient): attribute @classCode SHALL be present.</assert>
      <let name="theAttValue"
           value="distinct-values(tokenize(normalize-space(@classCode),'\s'))"/>
      <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.61-2018-09-30T000000.html"
              test="not(@classCode) or empty($theAttValue[not(. = (('ASSIGNED')))])">(plCdaBaseInformationRecipient): The value for classCode SHALL be 'code 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.61-2018-09-30T000000.html"
              test="count(hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]) &lt;= 1">(plCdaBaseInformationRecipient): element hl7:informationRecipient[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.61-2018-09-30T000000.html"
              test="count(hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]) &gt;= 1">(plCdaBaseInformationRecipient): element hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']] 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.61-2018-09-30T000000.html"
              test="count(hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]) &lt;= 1">(plCdaBaseInformationRecipient): element hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.61
Context: *[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]/hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]]/hl7:id
Item: (plCdaBaseInformationRecipient)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.61
Context: *[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]/hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]]/hl7:addr
Item: (plCdaBaseInformationRecipient)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.61
Context: *[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]/hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]]/hl7:telecom
Item: (plCdaBaseInformationRecipient)
-->


   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.61
Context: *[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]/hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]
Item: (plCdaBaseInformationRecipient)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.61
Context: *[hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]]/hl7:informationRecipient[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.61']]/hl7:intendedRecipient[hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]]/hl7:receivedOrganization[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.89']]
Item: (plCdaBaseInformationRecipient)
--></pattern>
