<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.4424.13.10.4.49
Name: [4] Dokument w postaci binarnej
Description: Szablon CDA dla dokumentu w postaci binarnej
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.4424.13.10.4.49-2018-06-30T000000">
   <title>[4] Dokument w postaci binarnej</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.49
Context: *[hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]]
Item: (plCdaDocumentBinaryContentEntry)
-->

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

   <rule fpi="RULC-1"
         context="*[hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]]/hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]"
         id="d16e5285-false-d22759e0">
      <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.49-2018-06-30T000000.html"
              test="string(@ID) = ('DOCUMENT_CONTENT')">(plCdaDocumentBinaryContentEntry): The value for ID SHALL be 'DOCUMENT_CONTENT'. Found: "<value-of select="@ID"/>"</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.49-2018-06-30T000000.html"
              test="not(@ID) or string-length(@ID)&gt;0">(plCdaDocumentBinaryContentEntry): Attribute @ID SHALL be of data type 'st'  - '<value-of select="@ID"/>'</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.49-2018-06-30T000000.html"
              test="string(@classCode) = ('OBS')">(plCdaDocumentBinaryContentEntry): The value for classCode SHALL be 'OBS'. 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.49-2018-06-30T000000.html"
              test="string(@moodCode) = ('EVN')">(plCdaDocumentBinaryContentEntry): The value for moodCode SHALL be 'EVN'. Found: "<value-of select="@moodCode"/>"</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.49-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']) &gt;= 1">(plCdaDocumentBinaryContentEntry): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49'] 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.49-2018-06-30T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']) &lt;= 1">(plCdaDocumentBinaryContentEntry): element hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49'] 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.49-2018-06-30T000000.html"
              test="count(hl7:value[not(@nullFlavor)]) &gt;= 1">(plCdaDocumentBinaryContentEntry): element hl7:value[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.4.49-2018-06-30T000000.html"
              test="count(hl7:value[not(@nullFlavor)]) &lt;= 1">(plCdaDocumentBinaryContentEntry): element hl7:value[not(@nullFlavor)] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.49
Context: *[hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]]/hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']
Item: (plCdaDocumentBinaryContentEntry)
-->

   <rule fpi="RULC-1"
         context="*[hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]]/hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]/hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']"
         id="d16e5293-false-d22803e0">
      <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.49-2018-06-30T000000.html"
              test="string(@root) = ('2.16.840.1.113883.3.4424.13.10.4.49')">(plCdaDocumentBinaryContentEntry): The value for root SHALL be '2.16.840.1.113883.3.4424.13.10.4.49'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.49
Context: *[hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]]/hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]/hl7:id
Item: (plCdaDocumentBinaryContentEntry)
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.49
Context: *[hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]]/hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]/hl7:value[not(@nullFlavor)]
Item: (plCdaDocumentBinaryContentEntry)
-->

   <rule fpi="RULC-1"
         context="*[hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]]/hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]/hl7:value[not(@nullFlavor)]"
         id="d16e5301-false-d22822e0">
      <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.49-2018-06-30T000000.html"
              test="string(@representation) = ('B64') or not(@representation)">(plCdaDocumentBinaryContentEntry): The value for representation SHALL be 'B64'. Found: "<value-of select="@representation"/>"</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.49-2018-06-30T000000.html"
              test="@mediaType">(plCdaDocumentBinaryContentEntry): attribute @mediaType 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.4.49-2018-06-30T000000.html"
              test="not(@mediaType) or (string-length(@mediaType) &gt; 0 and not(matches(@mediaType,'\s')))">(plCdaDocumentBinaryContentEntry): Attribute @mediaType SHALL be of data type 'cs'  - '<value-of select="@mediaType"/>'</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.49-2018-06-30T000000.html"
              test="not(@compression) or (string-length(@compression) &gt; 0 and not(matches(@compression,'\s')))">(plCdaDocumentBinaryContentEntry): Attribute @compression SHALL be of data type 'cs'  - '<value-of select="@compression"/>'</assert>
      <report 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.49-2018-06-30T000000.html"
              test="@representation and  hl7:reference">(plCdaDocumentBinaryContentEntry): Nie może istnieć jednocześnie wskazanie zawartości w postaci Base64 i referencja do dokumentu zewnętrznego.</report>
      <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.49-2018-06-30T000000.html"
              test="count(hl7:reference) &lt;= 1">(plCdaDocumentBinaryContentEntry): element hl7:reference appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.4424.13.10.4.49
Context: *[hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]]/hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]/hl7:value[not(@nullFlavor)]/hl7:reference
Item: (plCdaDocumentBinaryContentEntry)
-->

   <rule fpi="RULC-1"
         context="*[hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]]/hl7:observationMedia[hl7:templateId[@root = '2.16.840.1.113883.3.4424.13.10.4.49']]/hl7:value[not(@nullFlavor)]/hl7:reference"
         id="d16e5309-false-d22848e0">
      <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.49-2018-06-30T000000.html"
              test="@value">(plCdaDocumentBinaryContentEntry): attribute @value 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.4.49-2018-06-30T000000.html"
              test="not(@value) or string-length(@value)&gt;0">(plCdaDocumentBinaryContentEntry): Attribute @value SHALL be of data type 'st'  - '<value-of select="@value"/>'</assert>
   </rule>
</pattern>
