<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.2.50
Name: [2] Osoba powiązana
Description: Bazowy szablon CDA dla osoby powiązanej
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.2.50-2018-06-30T000000">
   <title>[2] Osoba powiązana</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.50
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.50']]
Item: (plCdaBaseRelatedEntity)
-->

   <rule fpi="RULC-1"
         context="*[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.50']]"
         id="d16e3557-false-d17124e0">
      <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.50-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.50']) &gt;= 1">(plCdaBaseRelatedEntity): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.50'] 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.50-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.50']) &lt;= 1">(plCdaBaseRelatedEntity): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.50'] 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.50-2018-06-30T000000.html"
              test="count(hl7:code[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.19563-DYNAMIC.xml')//valueSet[1]/conceptList/concept/concat(@code, @codeSystem) or @nullFlavor]) &lt;= 1">(plCdaBaseRelatedEntity): element hl7:code[concat(@code, @codeSystem) = doc('include/voc-2.16.840.1.113883.1.11.19563-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.2.50-2018-06-30T000000.html"
              test="count(hl7:effectiveTime) &lt;= 1">(plCdaBaseRelatedEntity): element hl7:effectiveTime 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.50-2018-06-30T000000.html"
              test="count(hl7:relatedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]) &lt;= 1">(plCdaBaseRelatedEntity): element hl7:relatedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.50
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.50']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.50']
Item: (plCdaBaseRelatedEntity)
-->

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

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

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

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


   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.50
Context: *[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.50']]/hl7:relatedPerson[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.1']]
Item: (plCdaBaseRelatedEntity)
--></pattern>
