<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.2.5
Name: [2] Organizacja odpowiedzialna za dokument (bazowy)
Description: Bazowy szablon CDA dla organizacji odpowiedzialnej za przechowywanie i udostępnianie dokumentu
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.2.5-2018-06-30T000000">
   <title>[2] Organizacja odpowiedzialna za dokument (bazowy)</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.5
Context: *[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]
Item: (plCdaBaseCustodian)
-->

   <rule fpi="RULC-1"
         context="*[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]"
         id="d16e3496-false-d16996e0">
      <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.5-2018-06-30T000000.html"
              test="count(hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]) &gt;= 1">(plCdaBaseCustodian): element hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']] 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.5-2018-06-30T000000.html"
              test="count(hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]) &lt;= 1">(plCdaBaseCustodian): element hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.5
Context: *[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]
Item: (plCdaBaseCustodian)
-->

   <rule fpi="RULC-1"
         context="*[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]"
         id="d16e3527-false-d17013e0">
      <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.5-2018-06-30T000000.html"
              test="string(@typeCode) = ('CST') or not(@typeCode)">(plCdaBaseCustodian): The value for typeCode SHALL be 'CST'. 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.5-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']) &gt;= 1">(plCdaBaseCustodian): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5'] 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.5-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']) &lt;= 1">(plCdaBaseCustodian): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5'] 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.5-2018-06-30T000000.html"
              test="count(hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization]) &gt;= 1">(plCdaBaseCustodian): element hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization] 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.5-2018-06-30T000000.html"
              test="count(hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization]) &lt;= 1">(plCdaBaseCustodian): element hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.5
Context: *[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']
Item: (plCdaBaseCustodian)
-->

   <rule fpi="RULC-1"
         context="*[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']"
         id="d16e3531-false-d17043e0">
      <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.5-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.2.5')">(plCdaBaseCustodian): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.2.5'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.5
Context: *[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]/hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization]
Item: (plCdaBaseCustodian)
-->

   <rule fpi="RULC-1"
         context="*[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]/hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization]"
         id="d16e3536-false-d17054e0">
      <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.5-2018-06-30T000000.html"
              test="string(@classCode) = ('ASSIGNED') or not(@classCode)">(plCdaBaseCustodian): 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.2.5-2018-06-30T000000.html"
              test="count(hl7:representedCustodianOrganization[not(@nullFlavor)]) &gt;= 1">(plCdaBaseCustodian): element hl7:representedCustodianOrganization[not(@nullFlavor)] 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.5-2018-06-30T000000.html"
              test="count(hl7:representedCustodianOrganization[not(@nullFlavor)]) &lt;= 1">(plCdaBaseCustodian): element hl7:representedCustodianOrganization[not(@nullFlavor)] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.5
Context: *[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]/hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization]/hl7:representedCustodianOrganization[not(@nullFlavor)]
Item: (plCdaBaseCustodian)
-->

   <rule fpi="RULC-1"
         context="*[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]/hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization]/hl7:representedCustodianOrganization[not(@nullFlavor)]"
         id="d16e3540-false-d17074e0">
      <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.5-2018-06-30T000000.html"
              test="string(@classCode) = ('ORG') or not(@classCode)">(plCdaBaseCustodian): The value for classCode SHALL be 'ORG'. 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.5-2018-06-30T000000.html"
              test="string(@determinerCode) = ('INSTANCE') or not(@determinerCode)">(plCdaBaseCustodian): The value for determinerCode SHALL be 'INSTANCE'. Found: "<value-of select="@determinerCode"/>"</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.5-2018-06-30T000000.html"
              test="count(hl7:id[not(@nullFlavor)]) &gt;= 1">(plCdaBaseCustodian): element hl7:id[not(@nullFlavor)] is mandatory [min 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.5
Context: *[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]/hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization]/hl7:representedCustodianOrganization[not(@nullFlavor)]/hl7:id[not(@nullFlavor)]
Item: (plCdaBaseCustodian)
-->

   <rule fpi="RULC-1"
         context="*[hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]]/hl7:custodian[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.5']]/hl7:assignedCustodian[not(@nullFlavor)][hl7:representedCustodianOrganization]/hl7:representedCustodianOrganization[not(@nullFlavor)]/hl7:id[not(@nullFlavor)]"
         id="d16e3546-false-d17096e0">
      <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.5-2018-06-30T000000.html"
              test="@root">(plCdaBaseCustodian): attribute @root SHALL be present.</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.5-2018-06-30T000000.html"
              test="not(@root) or matches(@root,'^[0-2](\.(0|[1-9]\d*))*$') or matches(@root,'^[A-Fa-f\d]{8}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{4}-[A-Fa-f\d]{12}$') or matches(@root,'^[A-Za-z][A-Za-z\d\-]*$')">(plCdaBaseCustodian): Attribute @root SHALL be of data type 'uid'  - '<value-of select="@root"/>'</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.5-2018-06-30T000000.html"
              test="@displayable">(plCdaBaseCustodian): attribute @displayable SHALL be present.</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.5-2018-06-30T000000.html"
              test="not(@displayable) or string(@displayable)=('true','false')">(plCdaBaseCustodian): Attribute @displayable SHALL be of data type 'bl'  - '<value-of select="@displayable"/>'</assert>
   </rule>
</pattern>
