WHO Immunization Implementation Guide
0.2.0 - ci-build

WHO Immunization Implementation Guide, published by WHO. This guide is not an authorized publication; it is the continuous build for version 0.2.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/WorldHealthOrganization/smart-immunizations/ and changes regularly. See the Directory of published versions

Library: IMMZD2DTHib2p1bLogic

Official URL: http://smart.who.int/immunizations/Library/IMMZD2DTHib2p1bLogic Version: 0.2.0
Draft as of 2025-08-08 Computable Name: IMMZD2DTHib2p1bLogic

This library defines decision support logic for the IMMZ.D2.DT.Hib.2 doses with booster dose decision table in the Immunization CPG

Title: IMMZD2DTHib2p1bLogic
Id: IMMZD2DTHib2p1bLogic
Version: 0.2.0
Url: IMMZD2DTHib2p1bLogic
Status: draft
Type:

system: http://terminology.hl7.org/CodeSystem/library-type

code: logic-library

Date: 2025-08-08 19:12:11+0000
Publisher: WHO
Description:

This library defines decision support logic for the IMMZ.D2.DT.Hib.2 doses with booster dose decision table in the Immunization CPG

Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
Todaydate01In
PatientPatient01Out
Client is not due for Hib vaccination Case 1boolean01Out
Client is not due for Hib vaccination Case 2boolean01Out
Client is not due for Hib vaccination Case 3boolean01Out
Client is not due for Hib vaccinationboolean01Out
Client is not due for Hib vaccination Guidancestring01Out
Client is due for Hib vaccination Case 1boolean01Out
Client is due for Hib vaccination Case 2boolean01Out
Client is due for Hib vaccinationboolean01Out
Client is due for Hib vaccination Guidancestring01Out
Hib immunization schedule is complete Case 1boolean01Out
Hib immunization schedule is complete Case 2boolean01Out
Hib immunization schedule is completeboolean01Out
Hib immunization schedule is complete Guidancestring01Out
Primary series is complete. Client is not due for Hib booster doseboolean01Out
Primary series is complete. Client is not due for Hib booster dose Guidancestring01Out
Primary series is complete. Client is due for Hib booster doseboolean01Out
Primary series is complete. Client is due for Hib booster dose Guidancestring01Out
Guidancestring01Out
Has Guidanceboolean01Out
Test ValidationResource01Out
Content: text/cql

/*
 * Library: IMMZD2DTHib2p1bLogic (IMMZ.D2.DT.Hib.2 doses with booster dose)
 * Rule: Determine if the client is due for a Haemophilus influenzae type b (Hib) vaccination according to the national immunization schedule
 * Decision Table: 2 primary doses with a booster dose (2p+1)
 * Trigger: IMMZ.D2 Determine required vaccination(s) if any
 */
library IMMZD2DTHib2p1bLogic

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

include IMMZD2DTHibEncounterElements called Encounter

parameter Today Date default Today()

context Patient


/*
@dynamicValue: Guidance
*/
define "Guidance":
  case
    when "Client is not due for Hib vaccination" then "Client is not due for Hib vaccination Guidance"
    when "Client is due for Hib vaccination" then "Client is due for Hib vaccination Guidance"
    when "Hib immunization schedule is complete" then "Hib immunization schedule is complete Guidance"
    when "Primary series is complete. Client is not due for Hib booster dose" then "Primary series is complete. Client is not due for Hib booster dose Guidance"
    when "Primary series is complete. Client is due for Hib booster dose" then "Primary series is complete. Client is due for Hib booster dose Guidance"
    else ''
  end

define "Has Guidance":
  "Guidance" is not null and "Guidance" != ''

/*
@output: Client is not due for Hib vaccination Case 1
@pseudocode: "Immunization recommendation status" = "Not due"
*/
define "Client is not due for Hib vaccination Case 1":
  Encounter."Client's age is less than 6 weeks"

/*
@output: Client is not due for Hib vaccination Case 2
@pseudocode: "Immunization recommendation status" = "Not due"
*/
define "Client is not due for Hib vaccination Case 2":
  Encounter."One Hib primary series doses was administered"
    and Encounter."Client's age is at least 6 weeks and not more than 5 years"
    and Encounter."Client's age was less than 1 year when first Hib dose was administered"
    and Encounter."The latest Hib dose was administered less than 8 weeks ago"

/*
@output: Client is not due for Hib vaccination Case 3
@pseudocode: "Immunization recommendation status" = "Not due"
*/
define "Client is not due for Hib vaccination Case 3":
  Encounter."Client's age is more than 5 years"

/*
@output: Client is not due for Hib vaccination
@pseudocode: "Immunization recommendation status" = "Not due"
*/
define "Client is not due for Hib vaccination":
  "Client is not due for Hib vaccination Case 1"
    or "Client is not due for Hib vaccination Case 2"
    or "Client is not due for Hib vaccination Case 3"

/*
@output: Client is not due for Hib vaccination Guidance
@guidance: Should not vaccinate client with first Hib dose as client's age is less than 6 weeks. 
Check for any other vaccines due and inform the caregiver of when to come back for first dose.
@guidance: Should not vaccinate client with second Hib dose as the latest Hib dose was administered less than 8 weeks ago. 
Check for any other vaccines due and inform the caregiver of when to come back for second dose.
@guidance: Should not vaccinate client with Hib dose as client is more than 5 years old and Hib vaccination is not required for healthy children aged over 5 years. 
Check for any other vaccines due.
*/
define "Client is not due for Hib vaccination Guidance":
  case
    when "Client is not due for Hib vaccination Case 1" then 'Should not vaccinate client with first Hib dose as client\'s age is less than 6 weeks. 
Check for any other vaccines due and inform the caregiver of when to come back for first dose.'
    when "Client is not due for Hib vaccination Case 2" then 'Should not vaccinate client with second Hib dose as the latest Hib dose was administered less than 8 weeks ago. 
Check for any other vaccines due and inform the caregiver of when to come back for second dose.'
    when "Client is not due for Hib vaccination Case 3" then 'Should not vaccinate client with Hib dose as client is more than 5 years old and Hib vaccination is not required for healthy children aged over 5 years. 
Check for any other vaccines due.'
    else ''
  end

/*
@output: Client is due for Hib vaccination Case 1
@pseudocode: "Immunization recommendation status" = "Due"
*/
define "Client is due for Hib vaccination Case 1":
  Encounter."No Hib primary series doses were administered"
    and Encounter."Client's age is between 6 weeks and 5 years"

/*
@output: Client is due for Hib vaccination Case 2
@pseudocode: "Immunization recommendation status" = "Due"
*/
define "Client is due for Hib vaccination Case 2":
  Encounter."One Hib primary series doses was administered"
    and Encounter."Client's age is at least 6 weeks and not more than 5 years"
    and Encounter."Client's age was less than 1 year when first Hib dose was administered"
    and Encounter."The latest Hib dose was administered more than 8 weeks ago"

/*
@output: Client is due for Hib vaccination
@pseudocode: "Immunization recommendation status" = "Due"
*/
define "Client is due for Hib vaccination":
  "Client is due for Hib vaccination Case 1"
    or "Client is due for Hib vaccination Case 2"

/*
@output: Client is due for Hib vaccination Guidance
@guidance: Should vaccinate client with first Hib dose as client is within appropriate age range. 
Check for contraindications.
@guidance: Should vaccinate client with second Hib dose as client's age was less than 1 year when first Hib dose was adminsitered and latest Hib dose was administered more than 8 weeks ago. 
Check for contraindications.
*/
define "Client is due for Hib vaccination Guidance":
  case
    when "Client is due for Hib vaccination Case 1" then 'Should vaccinate client with first Hib dose as client is within appropriate age range. 
Check for contraindications.'
    when "Client is due for Hib vaccination Case 2" then 'Should vaccinate client with second Hib dose as client\'s age was less than 1 year when first Hib dose was adminsitered and latest Hib dose was administered more than 8 weeks ago. 
Check for contraindications.'
    else ''
  end

/*
@output: Hib immunization schedule is complete Case 1
@pseudocode: "Immunization recommendation status" = "Complete"
*/
define "Hib immunization schedule is complete Case 1":
  Encounter."One Hib primary series doses was administered"
    and Encounter."Client's age is at least 6 weeks and not more than 5 years"
    and Encounter."Client's age was more than 1 year when first Hib dose was administered"

/*
@output: Hib immunization schedule is complete Case 2
@pseudocode: "Immunization recommendation status" = "Complete"
*/
define "Hib immunization schedule is complete Case 2":
  Encounter."Two Hib primary series doses were administered"
    and Encounter."One Hib booster dose was administered"

/*
@output: Hib immunization schedule is complete
@pseudocode: "Immunization recommendation status" = "Complete"
*/
define "Hib immunization schedule is complete":
  "Hib immunization schedule is complete Case 1"
    or "Hib immunization schedule is complete Case 2"

/*
@output: Hib immunization schedule is complete Guidance
@guidance: Hib immunization schedule is complete as client's age was more than 1 year when first Hib dose was administered.
Check for any other vaccines due.
@guidance: Hib immunization schedule is complete. Three Hib primary series doses and a booster dose were administered. 
Check for any vaccines due.
*/
define "Hib immunization schedule is complete Guidance":
  case
    when "Hib immunization schedule is complete Case 1" then 'Hib immunization schedule is complete as client\'s age was more than 1 year when first Hib dose was administered.
Check for any other vaccines due.'
    when "Hib immunization schedule is complete Case 2" then 'Hib immunization schedule is complete. Three Hib primary series doses and a booster dose were administered. 
Check for any vaccines due.'
    else ''
  end

/*
@output: Primary series is complete. Client is not due for Hib booster dose
@pseudocode: "Immunization recommendation status" = "Not due"
*/
define "Primary series is complete. Client is not due for Hib booster dose":
  Encounter."Two Hib primary series doses were administered"
    and Encounter."No Hib booster doses were administered"
    and Encounter."Client's age is at least 6 weeks and not more than 5 years"
    and Encounter."The latest Hib dose was administered less than 6 months ago"

/*
@output: Primary series is complete. Client is not due for Hib booster dose Guidance
@guidance: Should not vaccinate client with Hib booster dose as latest Hib dose was administered less than 6 months ago. Hib primary series is complete. 
Check for any other vaccines due and inform the caregiver of when to come back for booster dose.
*/
define "Primary series is complete. Client is not due for Hib booster dose Guidance":
  'Should not vaccinate client with Hib booster dose as latest Hib dose was administered less than 6 months ago. Hib primary series is complete. 
Check for any other vaccines due and inform the caregiver of when to come back for booster dose.'

/*
@output: Primary series is complete. Client is due for Hib booster dose
@pseudocode: "Immunization recommendation status" = "Due"
*/
define "Primary series is complete. Client is due for Hib booster dose":
  Encounter."Two Hib primary series doses were administered"
    and Encounter."No Hib booster doses were administered"
    and Encounter."Client's age is at least 6 weeks and not more than 5 years"
    and Encounter."Client's age was more than 1 year when first Hib dose was administered"
    and Encounter."The latest Hib dose was administered more than 6 months ago"

/*
@output: Primary series is complete. Client is due for Hib booster dose Guidance
@guidance: Should vaccinate client with Hib booster dose as primary series is complete and the latest Hib dose was administered more than 6 months ago. 
Check for contraindications.
*/
define "Primary series is complete. Client is due for Hib booster dose Guidance":
  'Should vaccinate client with Hib booster dose as primary series is complete and the latest Hib dose was administered more than 6 months ago. 
Check for contraindications.'


/*
@test: Test expected results based on example patients
*/
define "Test Validation":
  case
    when Patient.id = '42.3.' then "Client is not due for Hib vaccination Case 1" and "Guidance" = 'Should not vaccinate client with first Hib dose as client\'s age is less than 6 weeks. 
Check for any other vaccines due and inform the caregiver of when to come back for first dose.'
    when Patient.id = '43.13.' then "Client is due for Hib vaccination Case 1" and "Guidance" = 'Should vaccinate client with first Hib dose as client is within appropriate age range. 
Check for contraindications.'
    when Patient.id = '44.1345.' then "Client is not due for Hib vaccination Case 2" and "Guidance" = 'Should not vaccinate client with second Hib dose as the latest Hib dose was administered less than 8 weeks ago. 
Check for any other vaccines due and inform the caregiver of when to come back for second dose.'
    when Patient.id = '45.1345.' then "Client is due for Hib vaccination Case 2" and "Guidance" = 'Should vaccinate client with second Hib dose as client\'s age was less than 1 year when first Hib dose was adminsitered and latest Hib dose was administered more than 8 weeks ago. 
Check for contraindications.'
    when Patient.id = '46.134.' then "Hib immunization schedule is complete Case 1" and "Guidance" = 'Hib immunization schedule is complete as client\'s age was more than 1 year when first Hib dose was administered.
Check for any other vaccines due.'
    when Patient.id = '47.1235.' then "Primary series is complete. Client is not due for Hib booster dose" and "Guidance" = 'Should not vaccinate client with Hib booster dose as latest Hib dose was administered less than 6 months ago. Hib primary series is complete. 
Check for any other vaccines due and inform the caregiver of when to come back for booster dose.'
    when Patient.id = '48.12345.' then "Primary series is complete. Client is due for Hib booster dose" and "Guidance" = 'Should vaccinate client with Hib booster dose as primary series is complete and the latest Hib dose was administered more than 6 months ago. 
Check for contraindications.'
    when Patient.id = '49.12.' then "Hib immunization schedule is complete Case 2" and "Guidance" = 'Hib immunization schedule is complete. Three Hib primary series doses and a booster dose were administered. 
Check for any vaccines due.'
    when Patient.id = '50.3.' then "Client is not due for Hib vaccination Case 3" and "Guidance" = 'Should not vaccinate client with Hib dose as client is more than 5 years old and Hib vaccination is not required for healthy children aged over 5 years. 
Check for any other vaccines due.'
    else 'No test case set'
  end
Content: application/elm+xml
Encoded data (124320 characters)