<?xml version='1.0' encoding='UTF-8'?>
<Library xmlns="http://hl7.org/fhir" xmlns:html="http://www.w3.org/1999/xhtml">
  <id value="IMMZIND37Logic" />
  <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" /><html:div>
<html:div>
    <html:table class="grid dict">
        
        
        <html:tr>
            <html:th scope="row"><html:b>Title: </html:b></html:th>
            <html:td style="padding-left: 4px;">IMMZIND37Logic</html:td>
        </html:tr>
        

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

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

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

        

        

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

        

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

        

        
        <html:tr>
            <html:th scope="row"><html:b>Date: </html:b></html:th>
            <html:td style="padding-left: 4px;">2026-03-25 23:30:34+0000</html:td>
        </html:tr>
        

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

        
        <html:tr>
            <html:th scope="row"><html:b>Description: </html:b></html:th>
            <html:td style="padding-left: 4px;"><html:div><html:p>This library defines population criteria logic for the IMMZ.IND.37 indicator in the Immunization CPG</html:p>
</html:div></html:td>
        </html:tr>
        

        

        

        

        

        

        

        

        

        

        

        
        <html:tr>
            <html:th scope="row"><html:b>Related Artifacts: </html:b></html:th>
            <html:td style="padding-left: 4px;">
                
                
                
                <html:p><html:b>Dependencies</html:b></html:p>
                <html:ul>
                  
                    <html:li><html:a href="Library-WHOCommon.html">WHOCommon</html:a></html:li>
                  
                    <html:li><html:a href="Library-IMMZCommon.html">IMMZCommon</html:a></html:li>
                  
                    <html:li><html:a href="Library-IMMZConcepts.html">IMMZConcepts</html:a></html:li>
                  
                    <html:li><html:code>http://smart.who.int/immunizations/Library/IMMZIndicatorElements</html:code></html:li>
                  
                </html:ul>
                
                
                
                
                
            </html:td>
        </html:tr>
        

        
        <html:tr>
          <html:th scope="row"><html:b>Parameters: </html:b></html:th>
          <html:td style="padding-left: 4px;">
            <html:table class="grid-dict">
              <html:tr><html:th><html:b>Name</html:b></html:th><html:th><html:b>Type</html:b></html:th><html:th><html:b>Min</html:b></html:th><html:th><html:b>Max</html:b></html:th><html:th><html:b>In/Out</html:b></html:th></html:tr>
              
                <html:tr><html:th>Measurement Period</html:th><html:th>Period</html:th><html:th>0</html:th><html:th>1</html:th><html:th>In</html:th></html:tr>
              
                <html:tr><html:th>Patient</html:th><html:th>Patient</html:th><html:th>0</html:th><html:th>1</html:th><html:th>Out</html:th></html:tr>
              
                <html:tr><html:th>Initial Population</html:th><html:th>boolean</html:th><html:th>0</html:th><html:th>1</html:th><html:th>Out</html:th></html:tr>
              
                <html:tr><html:th>Denominator</html:th><html:th>boolean</html:th><html:th>0</html:th><html:th>1</html:th><html:th>Out</html:th></html:tr>
              
                <html:tr><html:th>Numerator</html:th><html:th>boolean</html:th><html:th>0</html:th><html:th>1</html:th><html:th>Out</html:th></html:tr>
              
                <html:tr><html:th>Stratification 1</html:th><html:th>string</html:th><html:th>0</html:th><html:th>1</html:th><html:th>Out</html:th></html:tr>
              
                <html:tr><html:th>Stratification 2</html:th><html:th>Coding</html:th><html:th>0</html:th><html:th>1</html:th><html:th>Out</html:th></html:tr>
              
                <html:tr><html:th>Stratification 3</html:th><html:th>Coding</html:th><html:th>0</html:th><html:th>1</html:th><html:th>Out</html:th></html:tr>
              
                <html:tr><html:th>Stratification 4</html:th><html:th>Coding</html:th><html:th>0</html:th><html:th>1</html:th><html:th>Out</html:th></html:tr>
              
            </html:table>
          </html:td>
        </html:tr>
        

        

        
        
        <html:tr>
          <html:td colspan="2">
            <html:table>
              <html:tr><html:th><html:a id="cql-content"><html:b>Content: </html:b></html:a> text/cql</html:th></html:tr>
              <html:tr><html:td><html:pre><html:code class="language-cql">/*
 * Library: IMMZ.IND.37 Logic
 * Drop-out rate from the 1st dose of measles and rubella-containing vaccine to the 2nd dose
 * The percentage in the target population who received a 1st dose of measles and rubella-containing vaccine in the primary series but have not received the 2nd dose of measles and rubella-containing vaccine in the primary series (i.e. are past due for measles and rubella-containing vaccine 2nd dose) during the reporting period
 * 
 * Numerator: Number of clients who received a 1st dose of measles and rubella-containing vaccine during the reporting period who should have received the 2nd dose of measles and rubella-containing vaccine during the reporting period but did not receive it
 * Numerator Computation: (COUNT of clients with an immunization event WHERE "Vaccine type"" = "Measles and rubella-containing vaccines" for the 1st dose in the primary series AND "Date and time of vaccination" is during the reporting period) - (COUNT of clients with an immunization event WHERE "Vaccine type"" = "Measles and rubella-containing vaccines" for the 2nd dose in the primary series AND "Date and time of vaccination" is during the reporting period)
 * Denominator: Number of clients in the target population who received dose 1 of measles and rubella-containing vaccine during the reporting period
 * Denominator Computation: COUNT clients with an immunization event WHERE "Vaccine type" = "Measles and rubella-containing vaccines" for a 1st dose in the primary series AND "Date and time of vaccination" is during the reporting period
 * 
 * Disaggregation
 *  - Administrative area
 *  - Sex
 *  - Age in years
 *  - Age group (depending on schedule)
 *
 * References: WHO Immunization facility analysis guide (5)
 * 
 * Annotations: –
 */
library IMMZIND37Logic

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 IMMZIndicatorElements called Elements


parameter "Measurement Period" Interval&lt;Date&gt; default Interval[@2025-01-01, @2025-12-31]

context Patient

/*
 * As defined by Member State
 */
define "Initial Population":
  true

/*
@denominator: Number of clients in the target population who received dose 1 of measles and rubella-containing vaccine during the reporting period
@pseudocode: COUNT clients with an immunization event WHERE "Vaccine type" = "Measles and rubella-containing vaccines" for a 1st dose in the primary series AND "Date and time of vaccination" is during the reporting period
@note: Updated to include those who have received the first dose and are due for the second during the measurement period
*/
define "Denominator":
  exists( Elements."Measles and Rubella Doses Administered to Patient".getDose('1') )
    and Patient.birthDate + 15 months during "Measurement Period"

/*
@numerator: Number of clients who received a 1st dose of measles and rubella-containing vaccine during the reporting period who should have received the 2nd dose of measles and rubella-containing vaccine during the reporting period but did not receive it
@pseudocode: (COUNT of clients with an immunization event WHERE "Vaccine type"" = "Measles and rubella-containing vaccines" for the 1st dose in the primary series AND "Date and time of vaccination" is during the reporting period) - (COUNT of clients with an immunization event WHERE "Vaccine type"" = "Measles and rubella-containing vaccines" for the 2nd dose in the primary series AND "Date and time of vaccination" is during the reporting period)
@note: Only include those from the denominator that did not receive a measles/rubella 2nd dose during the measurement period.
        Those where the 2nd dose due date is during the period but have not received the 2nd dose.
*/
define "Numerator":
  "Denominator"
  and not exists( Elements."Measles and Rubella Doses Administered to Patient During Measurement Period".getDose('2') )

/*
@disaggregation: Administrative area
                 Sex
                 Age in years
                 Age group (depending on schedule)
*/
define "Stratification 1":
	Elements."By Geographic Region Stratifier"

define "Stratification 2":
	Elements."By Administrative Gender Stratifier"

define "Stratification 3":
	Elements."Age Stratifier"

define "Stratification 4":
	Elements."Toddler By Age Stratifier"
</html:code></html:pre></html:td></html:tr>
            </html:table>
          </html:td>
        </html:tr>
        
        
        
        
        
        <html:tr>
          <html:td colspan="2">
            <html:table>
              <html:tr><html:th><html:b>Content: </html:b> application/elm+xml</html:th></html:tr>
              <html:tr><html:td><html:pre><html:code>Encoded data (29588 characters)</html:code></html:pre></html:td></html:tr>
            </html:table>
          </html:td>
        </html:tr>
        
        
    </html:table>
</html:div>
</html:div>
  </text>
  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability">
    <valueCode value="computable" />
  </extension>
  <url value="http://smart.who.int/immunizations/Library/IMMZIND37Logic" />
  <version value="0.2.0" />
  <name value="IMMZIND37Logic" />
  <title value="IMMZIND37Logic" />
  <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-25T23:30:34+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 population criteria logic for the IMMZ.IND.37 indicator 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 Elements" />
    <resource value="http://smart.who.int/immunizations/Library/IMMZIndicatorElements" />
  </relatedArtifact>
  <parameter>
    <name value="Measurement Period" />
    <use value="in" />
    <min value="0" />
    <max value="1" />
    <type value="Period" />
  </parameter>
  <parameter>
    <name value="Patient" />
    <use value="out" />
    <min value="0" />
    <max value="1" />
    <type value="Patient" />
  </parameter>
  <parameter>
    <name value="Initial Population" />
    <use value="out" />
    <min value="0" />
    <max value="1" />
    <type value="boolean" />
  </parameter>
  <parameter>
    <name value="Denominator" />
    <use value="out" />
    <min value="0" />
    <max value="1" />
    <type value="boolean" />
  </parameter>
  <parameter>
    <name value="Numerator" />
    <use value="out" />
    <min value="0" />
    <max value="1" />
    <type value="boolean" />
  </parameter>
  <parameter>
    <name value="Stratification 1" />
    <use value="out" />
    <min value="0" />
    <max value="1" />
    <type value="string" />
  </parameter>
  <parameter>
    <name value="Stratification 2" />
    <use value="out" />
    <min value="0" />
    <max value="1" />
    <type value="Coding" />
  </parameter>
  <parameter>
    <name value="Stratification 3" />
    <use value="out" />
    <min value="0" />
    <max value="1" />
    <type value="Coding" />
  </parameter>
  <parameter>
    <name value="Stratification 4" />
    <use value="out" />
    <min value="0" />
    <max value="1" />
    <type value="Coding" />
  </parameter>
  <content>
    <contentType value="text/cql" />
    <url value="Library-IMMZIND37Logic.cql" /></content>
  <content>
    <contentType value="application/elm+xml" />
    <url value="Library-IMMZIND37Logic.elm.xml" /></content>
</Library>