<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.2.19
Name: [2] Dane ubezpieczyciela publicznego (bazowy)
Description: Bazowy szablon struktury CDA dla danych ubezpieczyciela publicznego
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.2.19-2018-06-30T000000">
   <title>[2] Dane ubezpieczyciela publicznego (bazowy)</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.19
Context: *[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]
Item: (plCdaBasePublicUnderwriterParticipant)
-->

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

   <rule fpi="RULC-1"
         context="*[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]/hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]"
         id="d16e4761-false-d21666e0">
      <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.19-2018-06-30T000000.html"
              test="string(@typeCode) = ('IND')">(plCdaBasePublicUnderwriterParticipant): The value for typeCode SHALL be 'IND'. 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.19-2018-06-30T000000.html"
              test="string(@contextControlCode) = ('OP') or not(@contextControlCode)">(plCdaBasePublicUnderwriterParticipant): The value for contextControlCode SHALL be 'OP'. Found: "<value-of select="@contextControlCode"/>"</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.19-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']) &gt;= 1">(plCdaBasePublicUnderwriterParticipant): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19'] 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.19-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']) &lt;= 1">(plCdaBasePublicUnderwriterParticipant): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19'] 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.19-2018-06-30T000000.html"
              test="count(hl7:associatedEntity[@classCode = 'UNDWRT']) &gt;= 1">(plCdaBasePublicUnderwriterParticipant): element hl7:associatedEntity[@classCode = 'UNDWRT'] 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.19-2018-06-30T000000.html"
              test="count(hl7:associatedEntity[@classCode = 'UNDWRT']) &lt;= 1">(plCdaBasePublicUnderwriterParticipant): element hl7:associatedEntity[@classCode = 'UNDWRT'] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.19
Context: *[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]/hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']
Item: (plCdaBasePublicUnderwriterParticipant)
-->

   <rule fpi="RULC-1"
         context="*[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]/hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']"
         id="d16e4767-false-d21700e0">
      <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.19-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.2.19')">(plCdaBasePublicUnderwriterParticipant): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.2.19'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.19
Context: *[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]/hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]/hl7:associatedEntity[@classCode = 'UNDWRT']
Item: (plCdaBasePublicUnderwriterParticipant)
-->

   <rule fpi="RULC-1"
         context="*[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]/hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]/hl7:associatedEntity[@classCode = 'UNDWRT']"
         id="d16e4772-false-d21711e0">
      <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.19-2018-06-30T000000.html"
              test="string(@classCode) = ('UNDWRT')">(plCdaBasePublicUnderwriterParticipant): The value for classCode SHALL be 'UNDWRT'. Found: "<value-of select="@classCode"/>"</assert>
      <let name="elmcount"
           value="count(hl7:id[@root = '2.16.840.1.113883.3.4424.3.1'] | hl7:id[@root = '2.16.840.1.113883.3.4424.11.1.49'])"/>
      <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.19-2018-06-30T000000.html"
              test="$elmcount &gt;= 1">(plCdaBasePublicUnderwriterParticipant): choice (hl7:id[@root = '2.16.840.1.113883.3.4424.3.1']  or  hl7:id[@root = '2.16.840.1.113883.3.4424.11.1.49']) does not contain enough elements [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.19-2018-06-30T000000.html"
              test="$elmcount &lt;= 1">(plCdaBasePublicUnderwriterParticipant): choice (hl7:id[@root = '2.16.840.1.113883.3.4424.3.1']  or  hl7:id[@root = '2.16.840.1.113883.3.4424.11.1.49']) 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.2.19-2018-06-30T000000.html"
              test="count(hl7:id[@root = '2.16.840.1.113883.3.4424.3.1']) &lt;= 1">(plCdaBasePublicUnderwriterParticipant): element hl7:id[@root = '2.16.840.1.113883.3.4424.3.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.19-2018-06-30T000000.html"
              test="count(hl7:id[@root = '2.16.840.1.113883.3.4424.11.1.49']) &lt;= 1">(plCdaBasePublicUnderwriterParticipant): element hl7:id[@root = '2.16.840.1.113883.3.4424.11.1.49'] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.19
Context: *[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]/hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]/hl7:associatedEntity[@classCode = 'UNDWRT']/hl7:id[@root = '2.16.840.1.113883.3.4424.3.1']
Item: (plCdaBasePublicUnderwriterParticipant)
-->

   <rule fpi="RULC-1"
         context="*[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]/hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]/hl7:associatedEntity[@classCode = 'UNDWRT']/hl7:id[@root = '2.16.840.1.113883.3.4424.3.1']"
         id="d16e4778-false-d21752e0">
      <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.19-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.3.1')">(plCdaBasePublicUnderwriterParticipant): The value for root SHALL be '2.16.840.1.113883.3.4424.3.1'. Found: "<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.19-2018-06-30T000000.html"
              test="@extension">(plCdaBasePublicUnderwriterParticipant): attribute @extension 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.19-2018-06-30T000000.html"
              test="not(@extension) or string-length(@extension)&gt;0">(plCdaBasePublicUnderwriterParticipant): Attribute @extension SHALL be of data type 'st'  - '<value-of select="@extension"/>'</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.2.19
Context: *[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]/hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]/hl7:associatedEntity[@classCode = 'UNDWRT']/hl7:id[@root = '2.16.840.1.113883.3.4424.11.1.49']
Item: (plCdaBasePublicUnderwriterParticipant)
-->

   <rule fpi="RULC-1"
         context="*[hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]]/hl7:participant[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.2.19']]/hl7:associatedEntity[@classCode = 'UNDWRT']/hl7:id[@root = '2.16.840.1.113883.3.4424.11.1.49']"
         id="d16e4785-false-d21770e0">
      <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.19-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.11.1.49')">(plCdaBasePublicUnderwriterParticipant): The value for root SHALL be '2.16.840.1.113883.3.4424.11.1.49'. Found: "<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.19-2018-06-30T000000.html"
              test="@extension">(plCdaBasePublicUnderwriterParticipant): attribute @extension 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.19-2018-06-30T000000.html"
              test="not(@extension) or string-length(@extension)&gt;0">(plCdaBasePublicUnderwriterParticipant): Attribute @extension SHALL be of data type 'st'  - '<value-of select="@extension"/>'</assert>
   </rule>
</pattern>
