<?xml version="1.0" encoding="UTF-8"?>
<!--
Template derived pattern
===========================================
ID: 2.16.840.1.113883.3.1937.777.63.10.653
Name: Terapia Farmacologica In Atto (Tele)
Description: History of Medication use Narrative (LOINC: 10160-0 )
-->
<pattern xmlns="http://purl.oclc.org/dsdl/schematron"
         id="template-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936">
   <title>Terapia Farmacologica In Atto (Tele)</title>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.653
Context: *[hl7:section]
Item: (Terapia Farmacologica In Atto (Tele))
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.653
Context: *[hl7:section]/hl7:section
Item: (Terapia Farmacologica In Atto (Tele))
-->

   <rule fpi="RULC-1"
         context="*[hl7:section]/hl7:section"
         id="d44e5209-false-d919505e0">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="string(@classCode) = ('DOCSECT') or not(@classCode)">(Terapia Farmacologica In Atto (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-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="string(@moodCode) = ('EVN') or not(@moodCode)">(Terapia Farmacologica In Atto (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-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.3.1937.777.63.10.653']) &lt;= 1">(Terapia Farmacologica In Atto (Tele)): element hl7:templateId[@root = '2.16.840.1.113883.3.1937.777.63.10.653'] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="count(hl7:id) &lt;= 1">(Terapia Farmacologica In Atto (Tele)): element hl7:id appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="count(hl7:code[(@code = '10160-0 ' and @codeSystem = '2.16.840.1.113883.6.1') or @nullFlavor]) &lt;= 1">(Terapia Farmacologica In Atto (Tele)): element hl7:code[(@code = '10160-0 ' and @codeSystem = '2.16.840.1.113883.6.1') or @nullFlavor] appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="count(hl7:title) &lt;= 1">(Terapia Farmacologica In Atto (Tele)): element hl7:title appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="count(hl7:text) &gt;= 1">(Terapia Farmacologica In Atto (Tele)): element hl7:text is required [min 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="count(hl7:text) &lt;= 1">(Terapia Farmacologica In Atto (Tele)): element hl7:text appears too often [max 1x].</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.653
Context: *[hl7:section]/hl7:section/hl7:templateId[@root = '2.16.840.1.113883.3.1937.777.63.10.653']
Item: (Terapia Farmacologica In Atto (Tele))
-->

   <rule fpi="RULC-1"
         context="*[hl7:section]/hl7:section/hl7:templateId[@root = '2.16.840.1.113883.3.1937.777.63.10.653']"
         id="d44e5215-false-d919561e0">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="string(@root) = ('2.16.840.1.113883.3.1937.777.63.10.653')">(Terapia Farmacologica In Atto (Tele)): The value for root SHALL be '2.16.840.1.113883.3.1937.777.63.10.653'. Found: "<value-of select="@root"/>"</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.653
Context: *[hl7:section]/hl7:section/hl7:id
Item: (Terapia Farmacologica In Atto (Tele))
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.653
Context: *[hl7:section]/hl7:section/hl7:code[(@code = '10160-0 ' and @codeSystem = '2.16.840.1.113883.6.1') or @nullFlavor]
Item: (Terapia Farmacologica In Atto (Tele))
-->

   <rule fpi="RULC-1"
         context="*[hl7:section]/hl7:section/hl7:code[(@code = '10160-0 ' and @codeSystem = '2.16.840.1.113883.6.1') or @nullFlavor]"
         id="d44e5222-false-d919581e0">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="@nullFlavor or (@code='10160-0 ' and @codeSystem='2.16.840.1.113883.6.1')">(Terapia Farmacologica In Atto (Tele)): The element value SHALL be one of 'code '10160-0 ' codeSystem '2.16.840.1.113883.6.1''.</assert>
   </rule>
   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.653
Context: *[hl7:section]/hl7:section/hl7:title
Item: (Terapia Farmacologica In Atto (Tele))
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.653
Context: *[hl7:section]/hl7:section/hl7:text
Item: (Terapia Farmacologica In Atto (Tele))
-->


   <!--
Template derived rules for ID: 2.16.840.1.113883.3.1937.777.63.10.653
Context: *[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]
Item: (Terapia Farmacologica In Atto (Tele))
-->
   <rule fpi="RULC-1"
         context="*[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]">
      <let name="theAttValue"
           value="distinct-values(tokenize(normalize-space(@typeCode),'\s'))"/>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.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))])">(Terapia Farmacologica In Atto (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-20251030T104952/tmp-2.16.840.1.113883.3.1937.777.63.10.653-2025-05-27T124936.html"
              test="string(@contextConductionInd) = ('true') or not(@contextConductionInd)">(Terapia Farmacologica In Atto (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.2.9.10.1.6.53
Context: *[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]
Item: (Codice Farmaco )
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.2.9.10.1.6.53
Context: *[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct
Item: (Codice Farmaco )
-->
   <rule fpi="RULC-1"
         context="*[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.2.9.10.1.6.53-2018-03-19T000000.html"
              test="string(@classCode) = ('MANU') or not(@classCode)">(Codice Farmaco ): The value for classCode SHALL be 'MANU'. Found: "<value-of select="@classCode"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.2.9.10.1.6.53-2018-03-19T000000.html"
              test="count(hl7:templateId[@root = '2.16.840.1.113883.2.9.10.1.6.53']) &lt;= 1">(Codice Farmaco ): element hl7:templateId[@root = '2.16.840.1.113883.2.9.10.1.6.53'] appears too often [max 1x].</assert>
   </rule>

   <!--
Template derived rules for ID: 2.16.840.1.113883.2.9.10.1.6.53
Context: *[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct/hl7:templateId[@root = '2.16.840.1.113883.2.9.10.1.6.53']
Item: (Codice Farmaco )
-->
   <rule fpi="RULC-1"
         context="*[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct/hl7:templateId[@root = '2.16.840.1.113883.2.9.10.1.6.53']">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.2.9.10.1.6.53-2018-03-19T000000.html"
              test="string(@root) = ('2.16.840.1.113883.2.9.10.1.6.53')">(Codice Farmaco ): The value for root SHALL be '2.16.840.1.113883.2.9.10.1.6.53'. Found: "<value-of select="@root"/>"</assert>
   </rule>

   <!--
Template derived rules for ID: 2.16.840.1.113883.2.9.10.1.6.53
Context: *[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct/hl7:id
Item: (Codice Farmaco )
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.2.9.10.1.6.53
Context: *[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct/hl7:manufacturedMaterial
Item: (Codice Farmaco )
-->
   <rule fpi="RULC-1"
         context="*[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct/hl7:manufacturedMaterial">
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.2.9.10.1.6.53-2018-03-19T000000.html"
              test="string(@classCode) = ('MMAT') or not(@classCode)">(Codice Farmaco ): The value for classCode SHALL be 'MMAT'. Found: "<value-of select="@classCode"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.2.9.10.1.6.53-2018-03-19T000000.html"
              test="string(@determinerCode) = ('KIND') or not(@determinerCode)">(Codice Farmaco ): The value for determinerCode SHALL be 'KIND'. Found: "<value-of select="@determinerCode"/>"</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.2.9.10.1.6.53-2018-03-19T000000.html"
              test="count(hl7:code) &gt;= 1">(Codice Farmaco ): element hl7:code is required [min 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.2.9.10.1.6.53-2018-03-19T000000.html"
              test="count(hl7:code) &lt;= 1">(Codice Farmaco ): element hl7:code appears too often [max 1x].</assert>
      <assert role="error"
              see="https://hl7itig.art-decor.pub/hl7itig-html-20251030T104952/tmp-2.16.840.1.113883.2.9.10.1.6.53-2018-03-19T000000.html"
              test="count(hl7:name) &lt;= 1">(Codice Farmaco ): element hl7:name appears too often [max 1x].</assert>
   </rule>

   <!--
Template derived rules for ID: 2.16.840.1.113883.2.9.10.1.6.53
Context: *[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct/hl7:manufacturedMaterial/hl7:code
Item: (Codice Farmaco )
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.2.9.10.1.6.53
Context: *[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct/hl7:manufacturedMaterial/hl7:code/hl7:translation
Item: (Codice Farmaco )
-->

   <!--
Template derived rules for ID: 2.16.840.1.113883.2.9.10.1.6.53
Context: *[hl7:section]/hl7:section/hl7:entry[hl7:manufacturedProduct]/hl7:manufacturedProduct/hl7:manufacturedMaterial/hl7:name
Item: (Codice Farmaco )
--></pattern>
