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

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

This library defines encounter-based elements for Typhoid used throughout the Immunization CPG

Title: IMMZD2DTTyphoidEncounterElements
Id: IMMZD2DTTyphoidEncounterElements
Version: 0.2.0
Url: IMMZD2DTTyphoidEncounterElements
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 encounter-based elements for Typhoid used throughout the Immunization CPG

Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
Todaydate01In
EncounterIdstring01In
PatientPatient01Out
Typhoid Doses Administered to PatientImmunization0*Out
Typhoid Primary Series Doses Administered to PatientImmunization0*Out
Number of Typhoid Primary Series Doses Administeredinteger01Out
Date of Latest Typhoid Dosedate01Out
No typhoid primary series doses were administeredboolean01Out
One typhoid primary series dose was administeredboolean01Out
Client's age is less than 6 monthsboolean01Out
Client's age is between 6 months and 45 yearsboolean01Out
Client's age is more than or equal to 45 yearsboolean01Out
Client's age is less than 2 yearsboolean01Out
Client's age is more than or equal to 2 yearsboolean01Out
Client's age is less than 6 yearsboolean01Out
Client's age is more than or equal to 6 yearsboolean01Out
Primary series is completeboolean01Out
Primary series is not completeboolean01Out
The latest typhoid dose was administered less than 3 years agoboolean01Out
The latest typhoid dose was administered more than 3 years agoboolean01Out
No live vaccine, other than typhoid, was administered in the past 4 weeksboolean01Out
Live vaccine, other than typhoid, was administered in the past 4 weeksboolean01Out
Content: text/cql

/*
  * Library: IMMZD2DTTyphoidEncounterElements
  */
library IMMZD2DTTyphoidEncounterElements

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

include WHOConcepts
include WHOCommon called WC
include WHOElements called WE

include IMMZCommon called Common
include IMMZConcepts called Concepts

include IMMZEncounterElements called Encounter

include IMMZD2DTTyphoidElements called TyphoidElements

parameter Today Date default Today()
parameter EncounterId String

context Patient

/*
@internal: Typhoid containing Doses Administered to Patient
*/
define "Typhoid Doses Administered to Patient":
  Encounter."Doses Administered to Patient" I
  where
    I.vaccineCode in Concepts."Typhoid vaccines"

/*
@internal: Typhoid containing Doses Administered to Patient that are in the Primary series
*/
define "Typhoid Primary Series Doses Administered to Patient":
  "Typhoid Doses Administered to Patient".seriesPrimary()

/*
@internal: Number of Typhoid Primary Series doses
*/
define "Number of Typhoid Primary Series Doses Administered":
  Count("Typhoid Primary Series Doses Administered to Patient")

/*
@internal: Date and time of last Typhoid dose
*/
define "Date of Latest Typhoid Dose":
  date from start of "Typhoid Doses Administered to Patient".mostRecent().occurrence.toInterval()

/*
@input: No typhoid primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Typhoid vaccines" and "Type of dose" = "Primary series") = 0
@decision: Typhoid conjugate vaccine (TCV) schedule
@decision: Unconjugated Vi polysaccharide (ViPS) schedule
*/
define "No typhoid primary series doses were administered":
  "Number of Typhoid Primary Series Doses Administered" = 0

/*
@input: One typhoid primary series dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Typhoid vaccines" and "Type of dose" = "Primary series") = 1
@decision: Typhoid conjugate vaccine (TCV) schedule
@decision: Unconjugated Vi polysaccharide (ViPS) schedule
*/
define "One typhoid primary series dose was administered":
  "Number of Typhoid Primary Series Doses Administered" = 1

/*
@input: Client's age is less than 6 months
@pseudocode: Today's date − "Date of birth" < 6 months
@decision: Typhoid conjugate vaccine (TCV) schedule
*/
define "Client's age is less than 6 months":
  Encounter."Current Patient Age In Months" < 6

/*
@input: Client's age is between 6 months and 45 years
@pseudocode: 6 months ≤ Today's date − "Date of birth" < 45 years
@decision: Typhoid conjugate vaccine (TCV) schedule
*/
define "Client's age is between 6 months and 45 years":
  6 <= Encounter."Current Patient Age In Months" 
  and Encounter."Current Patient Age In Years" < 45

/*
@input: Client's age is more than or equal to 45 years
@pseudocode: Today's date − "Date of birth" ≥ 45 years
@decision: Typhoid conjugate vaccine (TCV) schedule
*/
define "Client's age is more than or equal to 45 years":
  Encounter."Current Patient Age In Years" >= 45

/*
@input: Client's age is less than 2 years
@pseudocode: Today's date − "Date of birth" < 2 years
@decision: Unconjugated Vi polysaccharide (ViPS) schedule
*/
define "Client's age is less than 2 years":
  Encounter."Current Patient Age In Years" < 2

/*
@input: Client's age is more than or equal to 2 years
@pseudocode: Today's date − "Date of birth" ≥ 2 years
@decision: Unconjugated Vi polysaccharide (ViPS) schedule
*/
define "Client's age is more than or equal to 2 years":
  Encounter."Current Patient Age In Years" >= 2

/*
@input: Client's age is less than 6 years
@pseudocode: Today's date − "Date of birth" < 6 years
@decision: Live attenuated Ty21a vaccine schedule
*/
define "Client's age is less than 6 years":
  Encounter."Current Patient Age In Years" < 6

/*
@input: Client's age is more than or equal to 6 years
@pseudocode: Today's date − "Date of birth" ≥ 6 years
@decision: Live attenuated Ty21a vaccine schedule
*/
define "Client's age is more than or equal to 6 years":
  Encounter."Current Patient Age In Years" >= 6

/*
@input: Primary series is not complete
@pseudocode: "Completed the primary vaccination series" (where "Vaccine type" = "Typhoid vaccines") ≠ TRUE
@decision: Live attenuated Ty21a vaccine schedule
*/
define "Primary series is not complete":
  not "Primary series is complete"

/*
@input: Primary series is complete
@pseudocode: "Completed the primary vaccination series" (where "Vaccine type" = "Typhoid vaccines") = TRUE
@decision: Live attenuated Ty21a vaccine schedule
*/
define "Primary series is complete":
  "One typhoid primary series dose was administered"
  or Coalesce( 
    "Typhoid Doses Administered to Patient" Dose
    aggregate Result: Encounter."Completed the primary vaccination series Observation".partOf.references(Dose) or Result, 
    false ) 

/*
@input: The latest typhoid dose was administered less than 3 years ago
@pseudocode: Today's date − latest "Date and time of vaccination" (where "Vaccine type" = "Typhoid vaccines") < 3 years
@decision: Unconjugated Vi polysaccharide (ViPS) schedule
*/
define "The latest typhoid dose was administered less than 3 years ago":
  "Date of Latest Typhoid Dose" is not null
    and duration in years between "Date of Latest Typhoid Dose" and Today < 3

/*
@input: The latest typhoid dose was administered more than 3 years ago
@pseudocode: Today's date − latest "Date and time of vaccination" (where "Vaccine type" = "Typhoid vaccines") ≥ 3 years
@decision: Unconjugated Vi polysaccharide (ViPS) schedule
*/
define "The latest typhoid dose was administered more than 3 years ago":
  not "The latest typhoid dose was administered less than 3 years ago"

/*
@input: No live vaccine, other than typhoid, was administered in the past 4 weeks
@pseudocode: Today's date − latest "Date and time of vaccination" (where "Live vaccine" = TRUE AND "Vaccine type" ≠ "Typhoid vaccines") ≥ 4 weeks
@decision: Live attenuated Ty21a vaccine schedule
@note: this is only ever called when Typhoid vaccine is more than 3 years old so no need to limit it to not Typhoid
*/
define "No live vaccine, other than typhoid, was administered in the past 4 weeks":
  Encounter."No live vaccine was administered in the last 4 weeks"

/*
@input: Live vaccine, other than typhoid, was administered in the past 4 weeks
@pseudocode: Today's date − latest "Date and time of vaccination" (where "Live vaccine" = TRUE AND "Vaccine type" ≠ "Typhoid vaccines") < 4 weeks
@decision: Live attenuated Ty21a vaccine schedule
@note: this is only ever called when Typhoid vaccine is more than 3 years old so no need to limit it to not Typhoid
*/
define "Live vaccine, other than typhoid, was administered in the past 4 weeks":
  Encounter."Live vaccine was administered in the last 4 weeks"

Content: application/elm+xml
Encoded data (64552 characters)