<?xml version="1.0" encoding="UTF-8"?>

<Library xmlns="http://hl7.org/fhir">
  <id value="IMMZD18SVaricella1DoseLogic"/>
  <meta>
    <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary"/>
    <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary"/>
    <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"/>
    <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-module"/>
  </meta>
  <text>
    <status value="extensions"/><div xmlns="http://www.w3.org/1999/xhtml">
<div>
    <table class="grid dict">
        
        
        <tr>
            <th scope="row"><b>Title: </b></th>
            <td style="padding-left: 4px;">IMMZD18SVaricella1DoseLogic</td>
        </tr>
        

        
        
        <tr>
            <th scope="row"><b>Id: </b></th>
            <td style="padding-left: 4px;">IMMZD18SVaricella1DoseLogic</td>
        </tr>
        

        
        
        <tr>
            <th scope="row"><b>Version: </b></th>
            <td style="padding-left: 4px;">1.0.0</td>
        </tr>
        

        
        <tr>
            <th scope="row"><b>Url: </b></th>
            <td style="padding-left: 4px;"><a href="Library-IMMZD18SVaricella1DoseLogic.html">IMMZD18SVaricella1DoseLogic</a></td>
        </tr>
        

        

        

        
        <tr>
            <th scope="row"><b>Status: </b></th>
            <td style="padding-left: 4px;">draft</td>
        </tr>
        

        

        
        <tr>
            <th scope="row"><b>Type: </b></th>
            <td style="padding-left: 4px;">
                
                    
                        
                        <p style="margin-bottom: 5px;">
                            <b>system: </b> <span><a href="http://terminology.hl7.org/7.1.0/CodeSystem-library-type.html">http://terminology.hl7.org/CodeSystem/library-type</a></span>
                        </p>
                        
                        
                        <p style="margin-bottom: 5px;">
                            <b>code: </b> <span>logic-library</span>
                        </p>
                        
                        
                    
                
                
            </td>
        </tr>
        

        

        
        <tr>
            <th scope="row"><b>Date: </b></th>
            <td style="padding-left: 4px;">2026-03-31 13:54:17+0000</td>
        </tr>
        

        
        <tr>
            <th scope="row"><b>Publisher: </b></th>
            <td style="padding-left: 4px;">WHO</td>
        </tr>
        

        
        <tr>
            <th scope="row"><b>Description: </b></th>
            <td style="padding-left: 4px;"><div><p>This library defines decision support logic for the IMMZ.D18.S.Varicella.1-dose schedule table in the Immunization CPG</p>
</div></td>
        </tr>
        

        

        

        

        

        

        

        

        

        

        

        
        <tr>
            <th scope="row"><b>Related Artifacts: </b></th>
            <td style="padding-left: 4px;">
                
                
                
                <p><b>Dependencies</b></p>
                <ul>
                  
                    <li><a href="Library-WHOCommon.html">WHOCommon</a></li>
                  
                    <li><a href="Library-IMMZCommon.html">IMMZCommon</a></li>
                  
                    <li><a href="Library-IMMZConcepts.html">IMMZConcepts</a></li>
                  
                    <li><a href="Library-IMMZEncounterElements.html">IMMZEncounterElements</a></li>
                  
                    <li><a href="Library-IMMZD2DTVaricellaEncounterElements.html">IMMZD2DTVaricellaEncounterElements</a></li>
                  
                </ul>
                
                
                
                
                
            </td>
        </tr>
        

        
        <tr>
          <th scope="row"><b>Parameters: </b></th>
          <td style="padding-left: 4px;">
            <table class="grid-dict">
              <tr><th><b>Name</b></th><th><b>Type</b></th><th><b>Min</b></th><th><b>Max</b></th><th><b>In/Out</b></th></tr>
              
                <tr><th>Today</th><th>date</th><th>0</th><th>1</th><th>In</th></tr>
              
                <tr><th>Patient</th><th>Patient</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>One varicella dose from primary series was administered. The primary series has been completed</th><th>boolean</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>Varicella dose 1</th><th>boolean</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>Varicella dose 1 Due Date</th><th>date</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>Varicella dose 1 Overdue</th><th>date</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>Varicella dose 1 Create</th><th>string</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>Varicella dose 1 Expiration</th><th>Resource</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>Test Validation</th><th>Resource</th><th>0</th><th>1</th><th>Out</th></tr>
              
            </table>
          </td>
        </tr>
        

        

        
        
        <tr>
          <td colspan="2">
            <table>
              <tr><th><a id="cql-content"><b>Content: </b></a> text/cql</th></tr>
              <tr><td><pre><code class="language-cql">/*
 * Library: IMMZD18SVaricella1DoseLogic (IMMZ.D18.S.Varicella.1-dose schedule)
 * Schedule Table: 1-dose schedule
 */
library IMMZD18SVaricella1DoseLogic

using FHIR version '4.0.1'
include FHIRHelpers version '4.0.1'

include WHOCommon called WC

include IMMZCommon called Common
include IMMZConcepts called Concepts

include IMMZEncounterElements called IE
include IMMZD2DTVaricellaEncounterElements called Encounter

parameter Today Date default Today()


context Patient


/*
@output: Varicella dose 1
@description: Provision of the varicella dose 1
@trigger: Child's birth
@pseudo: 
@triggerDate: &quot;Date of birth&quot;
*/
define &quot;Varicella dose 1&quot;:
  Encounter.&quot;No varicella primary series dose was administered&quot;
  and not &quot;One varicella dose from primary series was administered. The primary series has been completed&quot;


/*
@output: Varicella dose 1 Create
@create: Depending on the goal of the vaccination programme, 1–2 doses should be given with the first dose administered at 12–18 months of age.
*/
define &quot;Varicella dose 1 Create&quot;:
  if &quot;Varicella dose 1&quot;
  then 'Depending on the goal of the vaccination programme, 1–2 doses should be given with the first dose administered at 12–18 months of age.' + '
Due Date: ' + ToString(&quot;Varicella dose 1 Due Date&quot;) + '
Overdue: ' + ToString(&quot;Varicella dose 1 Overdue&quot;)
  else ''


/*
@dynamicValue: Varicella dose 1 Due Date
@pseudocode: &quot;Date of birth&quot; + 12 months
*/
define &quot;Varicella dose 1 Due Date&quot;:
  if &quot;Varicella dose 1&quot; then Patient.birthDate + 12 months
  else null


/*
@dynamicValue: Varicella dose 1 Overdue
@pseudocode: &quot;Date of birth&quot; + 18 months
*/
define &quot;Varicella dose 1 Overdue&quot;:
  if &quot;Varicella dose 1&quot; then Patient.birthDate + 18 months
  else null


/*
@dynamicValue: Varicella dose 1 Expiration
@pseudocode: To be determined by Member States; however, there is no recommended expiration date and individuals are always eligible to be vaccinated.
*/
define &quot;Varicella dose 1 Expiration&quot;:
  null

  
/*
@complete: One varicella dose from primary series was administered. The primary series has been completed
@pseudocode: &quot;Completed the primary vaccination series&quot; = TRUE (where &quot;Vaccine type&quot; = &quot;Varicella-containing vaccines&quot;)
*/
define &quot;One varicella dose from primary series was administered. The primary series has been completed&quot;:
  Encounter.&quot;One varicella primary series dose was administered&quot;



/*
@test: Test expected results based on example patients
*/
define &quot;Test Validation&quot;:
  case
    when Patient.id = 'Varicella09.1' then &quot;Varicella dose 1&quot;
    when Patient.id = 'Varicella10.3' then &quot;Varicella dose 1&quot;
    when Patient.id = 'Varicella11.3' then &quot;Varicella dose 1&quot;
    when Patient.id = 'Varicella12.1' then &quot;One varicella dose from primary series was administered. The primary series has been completed&quot;
    else 'No test case set'
  end
</code></pre></td></tr>
            </table>
          </td>
        </tr>
        
        
        
    </table>
</div>
</div>
  </text>
  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability">
    <valueCode value="computable"/>
  </extension>
  <url value="http://smart.who.int/immunizations/Library/IMMZD18SVaricella1DoseLogic"/>
  <version value="1.0.0"/>
  <name value="IMMZD18SVaricella1DoseLogic"/>
  <title value="IMMZD18SVaricella1DoseLogic"/>
  <status value="draft"/>
  <experimental value="false"/>
  <type>
    <coding>
      <system value="http://terminology.hl7.org/CodeSystem/library-type"/>
      <code value="logic-library"/>
    </coding>
  </type>
  <date value="2026-03-31T13:54:17+00:00"/>
  <publisher value="WHO"/>
  <contact>
    <name value="WHO"/>
    <telecom>
      <system value="url"/>
      <value value="http://who.int"/>
    </telecom>
  </contact>
  <description value="This library defines decision support logic for the IMMZ.D18.S.Varicella.1-dose schedule table in the Immunization CPG"/>
  <relatedArtifact>
    <type value="depends-on"/>
    <display value="Library WC"/>
    <resource value="http://smart.who.int/immunizations/Library/WHOCommon"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="depends-on"/>
    <display value="Library Common"/>
    <resource value="http://smart.who.int/immunizations/Library/IMMZCommon"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="depends-on"/>
    <display value="Library Concepts"/>
    <resource value="http://smart.who.int/immunizations/Library/IMMZConcepts"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="depends-on"/>
    <display value="Library IE"/>
    <resource value="http://smart.who.int/immunizations/Library/IMMZEncounterElements"/>
  </relatedArtifact>
  <relatedArtifact>
    <type value="depends-on"/>
    <display value="Library Encounter"/>
    <resource value="http://smart.who.int/immunizations/Library/IMMZD2DTVaricellaEncounterElements"/>
  </relatedArtifact>
  <parameter>
    <name value="Today"/>
    <use value="in"/>
    <min value="0"/>
    <max value="1"/>
    <type value="date"/>
  </parameter>
  <parameter>
    <name value="Patient"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="Patient"/>
  </parameter>
  <parameter>
    <name value="One varicella dose from primary series was administered. The primary series has been completed"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="boolean"/>
  </parameter>
  <parameter>
    <name value="Varicella dose 1"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="boolean"/>
  </parameter>
  <parameter>
    <name value="Varicella dose 1 Due Date"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="date"/>
  </parameter>
  <parameter>
    <name value="Varicella dose 1 Overdue"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="date"/>
  </parameter>
  <parameter>
    <name value="Varicella dose 1 Create"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="string"/>
  </parameter>
  <parameter>
    <name value="Varicella dose 1 Expiration"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="Resource"/>
  </parameter>
  <parameter>
    <name value="Test Validation"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="Resource"/>
  </parameter>
  <content>
    <contentType value="text/cql"/>
    <data value="LyoKICogTGlicmF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