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

<Library xmlns="http://hl7.org/fhir">
  <id value="IMMZD18STyphoidTCVLogic"/>
  <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;">IMMZD18STyphoidTCVLogic</td>
        </tr>
        

        
        
        <tr>
            <th scope="row"><b>Id: </b></th>
            <td style="padding-left: 4px;">IMMZD18STyphoidTCVLogic</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-IMMZD18STyphoidTCVLogic.html">IMMZD18STyphoidTCVLogic</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.Typhoid.TCV 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-IMMZD2DTTyphoidEncounterElements.html">IMMZD2DTTyphoidEncounterElements</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 typhoid 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>TCV dose 1 Expiration</th><th>date</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>TCV dose 1</th><th>boolean</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>TCV dose 1 Due Date</th><th>date</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>TCV dose 1 Create</th><th>string</th><th>0</th><th>1</th><th>Out</th></tr>
              
                <tr><th>TCV dose 1 Overdue</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: IMMZD18STyphoidTCVLogic (IMMZ.D18.S.Typhoid.TCV schedule)
 * Schedule Table: Typhoid conjugate vaccine (TCV), 1 dose schedule
 */
library IMMZD18STyphoidTCVLogic

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 IMMZD2DTTyphoidEncounterElements called Encounter

parameter Today Date default Today()


context Patient


/*
@output: TCV dose 1
@description: Provision of the TCV dose 1
@trigger: Child's birth
@pseudo: 
@triggerDate: &quot;Date of birth&quot;
*/
define &quot;TCV dose 1&quot;:
  Encounter.&quot;No typhoid primary series doses were administered&quot;
  and not &quot;One typhoid dose from primary series was administered. The primary series has been completed&quot;
  and &quot;TCV dose 1 Expiration&quot; after day of Today


/*
@output: TCV dose 1 Create
@create: TCV dose 1 should be provided if the client's age is over 6 months, and the region recommends typhoid vaccination.
*/
define &quot;TCV dose 1 Create&quot;:
  if &quot;TCV dose 1&quot;
  then 'TCV dose 1 should be provided if the client\'s age is over 6 months, and the region recommends typhoid vaccination.' + '
Due Date: ' + ToString(&quot;TCV dose 1 Due Date&quot;) + '
Expiration: ' + ToString(&quot;TCV dose 1 Expiration&quot;)
  else ''


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


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


/*
@dynamicValue: TCV dose 1 Expiration
@pseudocode: &quot;Date of birth&quot; + 45 years
*/
define &quot;TCV dose 1 Expiration&quot;:
  Patient.birthDate + 45 years

  
/*
@complete: One typhoid 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;Typhoid vaccines&quot;)
*/
define &quot;One typhoid dose from primary series was administered. The primary series has been completed&quot;:
  Encounter.&quot;One typhoid primary series dose was administered&quot;



/*
@test: Test expected results based on example patients
*/
define &quot;Test Validation&quot;:
  case
    when Patient.id = 'Typhoid08.1' then &quot;TCV dose 1&quot;
    when Patient.id = 'Typhoid09.2' then &quot;TCV dose 1&quot;
    when Patient.id = 'Typhoid10.2' then not &quot;TCV dose 1&quot;
    when Patient.id = 'Typhoid11.1' then &quot;One typhoid 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/IMMZD18STyphoidTCVLogic"/>
  <version value="1.0.0"/>
  <name value="IMMZD18STyphoidTCVLogic"/>
  <title value="IMMZD18STyphoidTCVLogic"/>
  <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.Typhoid.TCV 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/IMMZD2DTTyphoidEncounterElements"/>
  </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 typhoid 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="TCV dose 1 Expiration"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="date"/>
  </parameter>
  <parameter>
    <name value="TCV dose 1"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="boolean"/>
  </parameter>
  <parameter>
    <name value="TCV dose 1 Due Date"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="date"/>
  </parameter>
  <parameter>
    <name value="TCV dose 1 Create"/>
    <use value="out"/>
    <min value="0"/>
    <max value="1"/>
    <type value="string"/>
  </parameter>
  <parameter>
    <name value="TCV dose 1 Overdue"/>
    <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="LyoKICogTGlicmFyeTogSU1N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