<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.1937.777.63.10.649
Name: Storia Clinica (Tele)
Description: History general Narrative - Reported (LOINC: 11329-0 )
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135">
   <title>Storia Clinica (Tele)</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]
Item: (Storia Clinica (Tele))
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]
Item: (Storia Clinica (Tele))
-->

   <rule fpi="RULC-1"
         context="*[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]"
         id="d44e5195-false-d93877e0">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@classCode) = ('DOCSECT') or not(@classCode)">(Storia Clinica (Tele)): The value for classCode SHALL be 'DOCSECT'. Found: "<value-of select="@classCode"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@moodCode) = ('EVN') or not(@moodCode)">(Storia Clinica (Tele)): The value for moodCode SHALL be 'EVN'. Found: "<value-of select="@moodCode"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.1937.777.63.10.649']) &lt;= 1">(Storia Clinica (Tele)): element hl7:templateId[@root = '2.16.840.1.113883.3.1937.777.63.10.649'] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:id) &lt;= 1">(Storia Clinica (Tele)): element hl7:id appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]) &gt;= 1">(Storia Clinica (Tele)): element hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')] is required [min 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]) &lt;= 1">(Storia Clinica (Tele)): element hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:title) &lt;= 1">(Storia Clinica (Tele)): element hl7:title appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:text) &gt;= 1">(Storia Clinica (Tele)): element hl7:text is required [min 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:text) &lt;= 1">(Storia Clinica (Tele)): element hl7:text appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:entry[hl7:organizer[hl7:code[(@code = '10157-6' and @codeSystem = '2.16.840.1.113883.6.1')]]]) &lt;= 1">(Storia Clinica (Tele)): element hl7:entry[hl7:organizer[hl7:code[(@code = '10157-6' and @codeSystem = '2.16.840.1.113883.6.1')]]] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:component[hl7:section]) &lt;= 1">(Storia Clinica (Tele)): element hl7:component[hl7:section] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="count(hl7:component[hl7:section]) &lt;= 1">(Storia Clinica (Tele)): element hl7:component[hl7:section] appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:templateId[@root = '2.16.840.1.113883.3.1937.777.63.10.649']
Item: (Storia Clinica (Tele))
-->

   <rule fpi="RULC-1"
         context="*[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:templateId[@root = '2.16.840.1.113883.3.1937.777.63.10.649']"
         id="d44e5201-false-d93991e0">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@root) = ('2.16.840.1.113883.3.1937.777.63.10.649')">(Storia Clinica (Tele)): The value for root SHALL be '2.16.840.1.113883.3.1937.777.63.10.649'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:id
Item: (Storia Clinica (Tele))
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]
Item: (Storia Clinica (Tele))
-->

   <rule fpi="RULC-1"
         context="*[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]"
         id="d44e5208-false-d94011e0">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@code) = ('11329-0')">(Storia Clinica (Tele)): The value for code SHALL be '11329-0'. Found: "<value-of select="@code"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@codeSystem) = ('2.16.840.1.113883.6.1')">(Storia Clinica (Tele)): The value for codeSystem SHALL be '2.16.840.1.113883.6.1'. Found: "<value-of select="@codeSystem"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@codeSystemName) = ('LOINC') or not(@codeSystemName)">(Storia Clinica (Tele)): The value for codeSystemName SHALL be 'LOINC'. Found: "<value-of select="@codeSystemName"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="not(@codeSystemName) or string-length(@codeSystemName)&gt;0">(Storia Clinica (Tele)): Attribute @codeSystemName SHALL be of data type 'st'  - '<value-of select="@codeSystemName"/>'</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="not(@displayName) or string-length(@displayName)&gt;0">(Storia Clinica (Tele)): Attribute @displayName SHALL be of data type 'st'  - '<value-of select="@displayName"/>'</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:title
Item: (Storia Clinica (Tele))
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:text
Item: (Storia Clinica (Tele))
-->


   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:entry[hl7:observation[hl7:code[(@code = '75326-9' and @codeSystem = '2.16.840.1.113883.6.1')]]]
Item: (Storia Clinica (Tele))
-->
   <rule fpi="RULC-1"
         context="*[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:entry[hl7:observation[hl7:code[(@code = '75326-9' and @codeSystem = '2.16.840.1.113883.6.1')]]]">
      <let name="theAttValue"
           value="distinct-values(tokenize(normalize-space(@typeCode),'\s'))"/>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="not(@typeCode) or empty($theAttValue[not(. = (doc('include/voc-2.16.840.1.113883.1.11.19446-DYNAMIC.xml')/*/valueSet/conceptList/concept/@code))])">(Storia Clinica (Tele)): The value for typeCode SHALL be selected from value set '2.16.840.1.113883.1.11.19446' x_ActRelationshipEntry (DYNAMIC).</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@contextConductionInd) = ('true') or not(@contextConductionInd)">(Storia Clinica (Tele)): The value for contextConductionInd SHALL be 'true'. Found: "<value-of select="@contextConductionInd"/>"</assert>
   </rule>

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:entry[hl7:organizer[hl7:code[(@code = '10157-6' and @codeSystem = '2.16.840.1.113883.6.1')]]]
Item: (Storia Clinica (Tele))
-->
   <rule fpi="RULC-1"
         context="*[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:entry[hl7:organizer[hl7:code[(@code = '10157-6' and @codeSystem = '2.16.840.1.113883.6.1')]]]">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="not(@typeCode) or (string-length(@typeCode) &gt; 0 and not(matches(@typeCode,'\s')))">(Storia Clinica (Tele)): Attribute @typeCode SHALL be of data type 'cs'  - '<value-of select="@typeCode"/>'</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="not(@contextConductionInd) or string(@contextConductionInd)=('true','false')">(Storia Clinica (Tele)): Attribute @contextConductionInd SHALL be of data type 'bl'  - '<value-of select="@contextConductionInd"/>'</assert>
   </rule>

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:component[hl7:section]
Item: (Storia Clinica (Tele))
-->
   <rule fpi="RULC-1"
         context="*[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:component[hl7:section]">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@typeCode) = ('COMP') or not(@typeCode)">(Storia Clinica (Tele)): The value for typeCode SHALL be 'COMP'. Found: "<value-of select="@typeCode"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@contextConductionInd) = ('true') or not(@contextConductionInd)">(Storia Clinica (Tele)): The value for contextConductionInd SHALL be 'true'. Found: "<value-of select="@contextConductionInd"/>"</assert>
   </rule>

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.649
Context: *[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:component[hl7:section]
Item: (Storia Clinica (Tele))
-->
   <rule fpi="RULC-1"
         context="*[hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]]/hl7:section[hl7:code[(@code = '11329-0' and @codeSystem = '2.16.840.1.113883.6.1')]]/hl7:component[hl7:section]">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@typeCode) = ('COMP') or not(@typeCode)">(Storia Clinica (Tele)): The value for typeCode SHALL be 'COMP'. Found: "<value-of select="@typeCode"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251014T164917/tmp-2.16.840.1.113883.3.1937.777.63.10.649-2025-05-27T123135.html"
              test="string(@contextConductionInd) = ('true') or not(@contextConductionInd)">(Storia Clinica (Tele)): The value for contextConductionInd SHALL be 'true'. Found: "<value-of select="@contextConductionInd"/>"</assert>
   </rule>
</pattern>
