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: IMMZD2DTDTPPregnantLogic

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

This library defines decision support logic for the IMMZ.D2.DT.DTP.Pregnancy decision table in the Immunization CPG

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

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

code: logic-library

Date: 2025-09-17 23:03:28+0000
Publisher: WHO
Description:

This library defines decision support logic for the IMMZ.D2.DT.DTP.Pregnancy decision table in the Immunization CPG

Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
Todaydate01In
EncounterIdstring01In
PatientPatient01Out
Client should follow 'delayed or interrupted series' decision logicboolean01Out
Client should follow 'delayed or interrupted series' decision logic Guidancestring01Out
Client should follow 'pregnancy starting with 3 doses' decision logicboolean01Out
Client should follow 'pregnancy starting with 3 doses' decision logic Guidancestring01Out
Client should follow 'pregnancy starting with 4 doses' decision logicboolean01Out
Client should follow 'pregnancy starting with 4 doses' decision logic Guidancestring01Out
Tetanus and diphtheria immunization schedule is complete Case 1boolean01Out
Tetanus and diphtheria immunization schedule is complete Case 2boolean01Out
Tetanus and diphtheria immunization schedule is completeboolean01Out
Tetanus and diphtheria immunization schedule is complete Guidancestring01Out
Guidancestring01Out
Has Guidanceboolean01Out
Test ValidationResource01Out
Content: text/cql

/*
 * Library: IMMZD2DTDTPPregnantLogic (IMMZ.D2.DT.DTP.Pregnancy)
 * Rule: Determine if the client is due for a diphtheria–tetanus–pertussis (DTP) vaccination according to the national immunization schedule
 * Decision Table: Determine whether DTP-containing vaccines are needed for pregnant women
 * Trigger: IMMZ.D2 Determine required vaccination(s) if any
 */
library IMMZD2DTDTPPregnantLogic

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

include WHOCommon called WC
include IMMZCommon called IC
include WHOConcepts called Concepts
include WHOElements called WE
include IMMZD2DTDTPEncounterElements called Encounter
include IMMZEncounterElements called IE

parameter Today Date default Today()
parameter EncounterId String

context Patient

/*
@dynamicValue: Guidance
*/
define "Guidance":
  case
    when "Client should follow 'delayed or interrupted series' decision logic" then "Client should follow 'delayed or interrupted series' decision logic Guidance"
    when "Client should follow 'pregnancy starting with 3 doses' decision logic" then "Client should follow 'pregnancy starting with 3 doses' decision logic Guidance"
    when "Client should follow 'pregnancy starting with 4 doses' decision logic" then "Client should follow 'pregnancy starting with 4 doses' decision logic Guidance"
    when "Tetanus and diphtheria immunization schedule is complete" then "Tetanus and diphtheria immunization schedule is complete Guidance"
    else ''
  end

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

/*
@output: Client should follow 'delayed or interrupted series' decision logic
@pseudocode: 
*/
define "Client should follow 'delayed or interrupted series' decision logic":
  Encounter."No DTP primary series doses were administered"
    and Encounter."Client is currently pregnant"

/*
@output: Client should follow 'delayed or interrupted series' decision logic Guidance
@guidance: The client has a delayed start. Please follow the 'delayed or interrupted' schedule.
*/
define "Client should follow 'delayed or interrupted series' decision logic Guidance":
  'The client has a delayed start. Please follow the \'delayed or interrupted\' schedule.'

/*
@output: Client should follow 'pregnancy starting with 3 doses' decision logic
@pseudocode: 
*/
define "Client should follow 'pregnancy starting with 3 doses' decision logic":
  Encounter."Three DTP primary series doses were administered"
    and Encounter."No tetanus and diphtheria booster dose was administered"
    and Encounter."Client is currently pregnant"

/*
@output: Client should follow 'pregnancy starting with 3 doses' decision logic Guidance
@guidance: The client has received 3 tetanus-containing vaccine doses during childhood. Please follow the 'pregnancy starting with 3 doses' schedule.
*/
define "Client should follow 'pregnancy starting with 3 doses' decision logic Guidance":
  'The client has received 3 tetanus-containing vaccine doses during childhood. Please follow the \'pregnancy starting with 3 doses\' schedule.'

/*
@output: Client should follow 'pregnancy starting with 4 doses' decision logic
@pseudocode: 
*/
define "Client should follow 'pregnancy starting with 4 doses' decision logic":
  Encounter."Three DTP primary series doses were administered"
    and Encounter."One tetanus and diphtheria booster dose was administered"
    and Encounter."Client is currently pregnant"

/*
@output: Client should follow 'pregnancy starting with 4 doses' decision logic Guidance
@guidance: The client has received 4 tetanus-containing vaccines doses during childhood or pre-adulthood. Please follow the 'pregnancy starting with 4 doses' schedule.
*/
define "Client should follow 'pregnancy starting with 4 doses' decision logic Guidance":
  'The client has received 4 tetanus-containing vaccines doses during childhood or pre-adulthood. Please follow the \'pregnancy starting with 4 doses\' schedule.'

/*
@output: Tetanus and diphtheria immunization schedule is complete Case 1
@pseudocode: "Immunization recommendation status" = "Complete" (where "Vaccine type" = "Tetanus and diphtheria-containing vaccines")
*/
define "Tetanus and diphtheria immunization schedule is complete Case 1":
  Encounter."Three DTP primary series doses were administered"
    and Encounter."Two tetanus and diphtheria booster doses were administered"

/*
@output: Tetanus and diphtheria immunization schedule is complete Case 2
@pseudocode: "Immunization recommendation status" = "Complete" (where "Vaccine type" = "Tetanus and diphtheria-containing vaccines")
*/
define "Tetanus and diphtheria immunization schedule is complete Case 2":
  Encounter."Three DTP primary series doses were administered"
    and Encounter."Three tetanus and diphtheria booster doses were administered"

/*
@output: Tetanus and diphtheria immunization schedule is complete
@pseudocode: "Immunization recommendation status" = "Complete" (where "Vaccine type" = "Tetanus and diphtheria-containing vaccines")
*/
define "Tetanus and diphtheria immunization schedule is complete":
  "Tetanus and diphtheria immunization schedule is complete Case 1"
    or "Tetanus and diphtheria immunization schedule is complete Case 2"

/*
@output: Tetanus and diphtheria immunization schedule is complete Guidance
@guidance: Tetanus and diphtheria immunization schedule is complete.Three DTP primary series doses and two tetanus and diphtheria booster doses were administered. There is no need for any additional tetanus and diphtheria doses.
Check for any other vaccines due.
@guidance: Tetanus and diphtheria immunization schedule is complete.Three DTP primary series doses and three tetanus and diphtheria booster doses were administered. There is no need for any additional tetanus and diphtheria doses.
Check for any other vaccines due.
*/
define "Tetanus and diphtheria immunization schedule is complete Guidance":
  case
    when "Tetanus and diphtheria immunization schedule is complete Case 1" then 'Tetanus and diphtheria immunization schedule is complete.Three DTP primary series doses and two tetanus and diphtheria booster doses were administered. There is no need for any additional tetanus and diphtheria doses.
Check for any other vaccines due.'
    when "Tetanus and diphtheria immunization schedule is complete Case 2" then 'Tetanus and diphtheria immunization schedule is complete.Three DTP primary series doses and three tetanus and diphtheria booster doses were administered. There is no need for any additional tetanus and diphtheria doses.
Check for any other vaccines due.'
    else ''
  end


/*
@test: Test expected results based on example patients
*/
define "Test Validation":
  case
    when Patient.id = '54.DTP0PT' then "Client should follow 'delayed or interrupted series' decision logic" and "Guidance" = 'The client has a delayed start. Please follow the \'delayed or interrupted\' schedule.'
    when Patient.id = '55.DTP3Td0PT' then "Client should follow 'pregnancy starting with 3 doses' decision logic" and "Guidance" = 'The client has received 3 tetanus-containing vaccine doses during childhood. Please follow the \'pregnancy starting with 3 doses\' schedule.'
    when Patient.id = '56.DTP3Td1PT' then "Client should follow 'pregnancy starting with 4 doses' decision logic" and "Guidance" = 'The client has received 4 tetanus-containing vaccines doses during childhood or pre-adulthood. Please follow the \'pregnancy starting with 4 doses\' schedule.'
    when Patient.id = '57.DTP3Td2' then "Tetanus and diphtheria immunization schedule is complete Case 1" and "Guidance" = 'Tetanus and diphtheria immunization schedule is complete.Three DTP primary series doses and two tetanus and diphtheria booster doses were administered. There is no need for any additional tetanus and diphtheria doses.
Check for any other vaccines due.'
    when Patient.id = '58.DTP3Td3' then "Tetanus and diphtheria immunization schedule is complete Case 2" and "Guidance" = 'Tetanus and diphtheria immunization schedule is complete.Three DTP primary series doses and three tetanus and diphtheria booster doses were administered. There is no need for any additional tetanus and diphtheria doses.
Check for any other vaccines due.'
    else 'No test case set'
  end
Content: application/elm+xml
Encoded data (75240 characters)