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

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

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

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

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

code: logic-library

Date: 2025-11-10 23:31:43+0000
Publisher: WHO
Description:

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

Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
Todaydate01In
EncounterIdstring01In
PatientPatient01Out
Pneumococcal Doses Administered to PatientImmunization0*Out
Pneumococcal Primary Series Doses Administered to PatientImmunization0*Out
Number of Pneumococcal Primary Series Doses Administeredinteger01Out
The client's age is less than 6 weeksboolean01Out
No pneumococcal primary series doses were administeredboolean01Out
The client's age is between 6 weeks and 5 yearsboolean01Out
One pneumococcal primary series dose was administeredboolean01Out
The client's age is less than or equal to 5 yearsboolean01Out
Date of First Pneumococcal Dosedate01Out
The first pneumococcal dose was administered within 24 months post birthboolean01Out
Date of Latest Pneumococcal Dosedate01Out
The latest pneumococcal dose was administered less than 8 weeks agoboolean01Out
The latest pneumococcal dose was administered more than 8 weeks agoboolean01Out
The first pneumococcal dose was administered after 24 months post birthboolean01Out
Client is at high risk for pneumococcal infectionboolean01Out
Client is not at high risk for pneumococcal infectionboolean01Out
Two pneumococcal primary series doses were administeredboolean01Out
Pneumococcal Booster Series Doses Administered to PatientImmunization0*Out
Number of Pneumococcal Booster Series Doses Administeredinteger01Out
No pneumococcal booster dose was administeredboolean01Out
The first pneumococcal dose was administered within 12 months post birthboolean01Out
The first pneumococcal dose was administered after 12 months post birthboolean01Out
One pneumococcal booster dose was administeredboolean01Out
The client's age is less than 12 monthsboolean01Out
Client's HIV status is positiveboolean01Out
Client had preterm birthboolean01Out
The client's age is more than or equal to 12 months and less than 24 monthsboolean01Out
The latest pneumococcal dose was administered within 12 months post birthboolean01Out
The latest pneumococcal dose was administered after 12 months post birthboolean01Out
Client's HIV status is negative or unknownboolean01Out
Client did not have preterm birthboolean01Out
The client's age is more than or equal to 24 monthsboolean01Out
Two pneumococcal booster doses were administeredboolean01Out
The client's age is more than 5 yearsboolean01Out
The client's age is less than or equal to five yearsboolean01Out
The latest pneumococcal dose was administered less than 4 weeks agoboolean01Out
The latest pneumococcal dose was administered more than 4 weeks agoboolean01Out
The first pneumococcal dose was administered at 12–24 months post birthboolean01Out
Three pneumococcal primary series doses were administeredboolean01Out
The client's age is less than 24 monthsboolean01Out
Content: text/cql

/*
  * Library: IMMZD2DTPneumococcalEncounterElements
  */
library IMMZD2DTPneumococcalEncounterElements

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 IMMZD2DTPneumococcalElements called PneumococcalElements

parameter Today Date default Today()
parameter EncounterId String

context Patient

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

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

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

/*
@input: The client's age is less than 6 weeks
@pseudocode: Today's date − "Date of birth" < 6 weeks
@code: The client's age is less than 6 weeks-40
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The client's age is less than 6 weeks":
  Encounter."Current Patient Age In Weeks" < 6

/*
@input: No pneumococcal primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Pneumococcal vaccines" and "Type of dose" = "Primary series") = 0
@code: No pneumococcal primary series doses were administered-121
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "No pneumococcal primary series doses were administered":
  "Number of Pneumococcal Primary Series Doses Administered" = 0

/*
@input: The client's age is between 6 weeks and 5 years
@pseudocode: 6 weeks ≤ Today's date − "Date of birth" ≤ 5 years
@code: The client's age is between 6 weeks and 5 years-50
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The client's age is between 6 weeks and 5 years":
  6 <= Encounter."Current Patient Age In Weeks"
  and Encounter."Current Patient Age In Years" <= 5

/*
@input: One pneumococcal primary series dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Pneumococcal vaccines" and "Type of dose" = "Primary series") = 1
@code: One pneumococcal primary series dose was administered-121
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "One pneumococcal primary series dose was administered":
  "Number of Pneumococcal Primary Series Doses Administered" = 1

/*
@input: The client's age is less than or equal to 5 years
@pseudocode: 'Today's date − "Date of birth" ≤ 5 years
@code: The client's age is less than or equal to 5 years-41
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
*/
define "The client's age is less than or equal to 5 years":
  Encounter."Current Patient Age In Years" <= 5

/*
@input: The first pneumococcal dose was administered within 24 months post birth
@pseudocode: "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") − "Date of birth" < 24 months
@code: The first pneumococcal dose was administered within 24 months post birth-109
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
*/
define "The first pneumococcal dose was administered within 24 months post birth":
  AgeInMonthsAt("Date of First Pneumococcal Dose") < 24

/*
@input: The latest pneumococcal dose was administered less than 8 weeks ago
@pseudocode: Today's date − "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") < 8 weeks
@code: The latest pneumococcal dose was administered less than 8 weeks ago-104
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The latest pneumococcal dose was administered less than 8 weeks ago":
  "Date of Latest Pneumococcal Dose" is not null
    and duration in weeks between "Date of Latest Pneumococcal Dose" and Today < 8

/*
@input: The latest pneumococcal dose was administered more than 8 weeks ago
@pseudocode: Today's date − "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") ≥ 8 weeks
@code: The latest pneumococcal dose was administered more than 8 weeks ago-104
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The latest pneumococcal dose was administered more than 8 weeks ago":
  not "The latest pneumococcal dose was administered less than 8 weeks ago"

/*
@input: The first pneumococcal dose was administered after 24 months post birth
@pseudocode: "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") − "Date of birth" ≥ 24 months
@code: The first pneumococcal dose was administered after 24 months post birth-109
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The first pneumococcal dose was administered after 24 months post birth":
  AgeInMonthsAt("Date of First Pneumococcal Dose") >= 24

/*
@input: Client is at high risk for pneumococcal infection
@pseudocode: "At high risk for pneumococcal infection" = TRUE
@code: Client is at high risk for pneumococcal infection-48
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "Client is at high risk for pneumococcal infection":
  Encounter."Client is at high risk for pneumococcal infection"

/*
@input: Client is not at high risk for pneumococcal infection
@pseudocode: "At high risk for pneumococcal infection" = FALSE
@code: Client is not at high risk for pneumococcal infection-49
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "Client is not at high risk for pneumococcal infection":
  Encounter."Client is not at high risk for pneumococcal infection"

/*
@input: Two pneumococcal primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Pneumococcal vaccines" and "Type of dose" = "Primary series") = 2
@code: Two pneumococcal primary series doses were administered-121
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "Two pneumococcal primary series doses were administered":
  "Number of Pneumococcal Primary Series Doses Administered" = 2

/*
@input: No pneumococcal booster dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Pneumococcal vaccines" and "Type of dose" = "Booster dose") = 0
@code: No pneumococcal booster dose was administered-119
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "No pneumococcal booster dose was administered":
  "Number of Pneumococcal Booster Series Doses Administered" = 0

/*
@input: The first pneumococcal dose was administered within 12 months post birth
@pseudocode: "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines" AND "Dose number" = 1) − "Date of birth" < 12 months
@code: The first pneumococcal dose was administered within 12 months post birth-131
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The first pneumococcal dose was administered within 12 months post birth":
  AgeInMonthsAt("Date of First Pneumococcal Dose") < 12

/*
@input: The first pneumococcal dose was administered after 12 months post birth
@pseudocode: "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines" AND "Dose number" = 1) − "Date of birth" ≥ 12 months
@code: The first pneumococcal dose was administered after 12 months post birth-131
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The first pneumococcal dose was administered after 12 months post birth":
  AgeInMonthsAt("Date of First Pneumococcal Dose") >= 12

/*
@input: One pneumococcal booster dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Pneumococcal vaccines" and "Type of dose" = "Booster dose") = 1
@code: One pneumococcal booster dose was administered-119
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "One pneumococcal booster dose was administered":
  "Number of Pneumococcal Booster Series Doses Administered" = 1

/*
@input: The client's age is less than 12 months
@pseudocode: Today's date − "Date of birth" < 12 months
@code: The client's age is less than 12 months-42
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
*/
define "The client's age is less than 12 months":
  Encounter."Current Patient Age In Months" < 12

/*
@input: Client's HIV status is positive
@pseudocode: "HIV status" = "HIV-positive"
@code: Client's HIV status is positive-29
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "Client's HIV status is positive":
  Encounter."Client's HIV status is positive"

/*
@input: Client had preterm birth
@pseudocode: "Preterm birth" = TRUE
@code: Client had preterm birth-22
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "Client had preterm birth":
  Encounter."Client was a premature infant at birth"

/*
@input: The client's age is more than or equal to 12 months and less than 24 months
@pseudocode: 12 months ≤ Today's date − "Date of birth" < 24 months
@code: The client's age is more than or equal to 12 months and less than 24 months-54
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
*/
define "The client's age is more than or equal to 12 months and less than 24 months":
  12 <= Encounter."Current Patient Age In Months"
  and Encounter."Current Patient Age In Months" < 24

/*
@input: The latest pneumococcal dose was administered within 12 months post birth
@pseudocode: Latest "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") − "Date of birth" < 12 months
@code: The latest pneumococcal dose was administered within 12 months post birth-116
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The latest pneumococcal dose was administered within 12 months post birth":
  AgeInMonthsAt("Date of Latest Pneumococcal Dose") < 12

/*
@input: The latest pneumococcal dose was administered after 12 months post birth
@pseudocode: Latest "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") − "Date of birth" ≥ 12 months
@code: The latest pneumococcal dose was administered after 12 months post birth-116
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The latest pneumococcal dose was administered after 12 months post birth":
  AgeInMonthsAt("Date of Latest Pneumococcal Dose") >= 12

/*
@input: Client's HIV status is negative or unknown
@pseudocode: "HIV status" ≠ "HIV-positive"
@code: Client's HIV status is negative or unknown-29
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "Client's HIV status is negative or unknown":
  Encounter."Client's HIV status is negative or unknown"

/*
@input: Client did not have preterm birth
@pseudocode: "Preterm birth" ≠ TRUE
@code: Client did not have preterm birth-22
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "Client did not have preterm birth":
  Encounter."Client was not a premature infant at birth"

/*
@input: The client's age is more than or equal to 24 months
@pseudocode: Today's date − "Date of birth" ≥ 24 months
@code: The client's age is more than or equal to 24 months-42
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The client's age is more than or equal to 24 months":
  Encounter."Current Patient Age In Months" >= 24

/*
@input: Two pneumococcal booster doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Pneumococcal vaccines" and "Type of dose" = "Booster dose") = 2
@code: Two pneumococcal booster doses were administered-119
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
*/
define "Two pneumococcal booster doses were administered":
  "Number of Pneumococcal Booster Series Doses Administered" = 2

/*
@input: The client's age is more than 5 years
@pseudocode: Today's date − "Date of birth" > 5 years
@code: The client's age is more than 5 years-40
@decision: IMMZ.D2.DT.Pneumococcal.2 doses with booster dose: 2 primary doses with a booster dose (2p+1)
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The client's age is more than 5 years":
  Encounter."Current Patient Age In Months" > 5

/*
@input: The client's age is less than or equal to five years
@pseudocode: Today's date − "Date of birth" ≤ 5 years
@code: The client's age is less than or equal to five years-40
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The client's age is less than or equal to five years":
  "The client's age is less than or equal to 5 years"

/*
@input: The latest pneumococcal dose was administered less than 4 weeks ago
@pseudocode: Today's date − "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") < 4 weeks
@code: The latest pneumococcal dose was administered less than 4 weeks ago-104
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The latest pneumococcal dose was administered less than 4 weeks ago":
  "Date of Latest Pneumococcal Dose" is not null
    and duration in weeks between "Date of Latest Pneumococcal Dose" and Today < 4

/*
@input: The latest pneumococcal dose was administered more than 4 weeks ago
@pseudocode: Today's date − "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") ≥ 4 weeks
@code: The latest pneumococcal dose was administered more than 4 weeks ago-104
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The latest pneumococcal dose was administered more than 4 weeks ago":
  not "The latest pneumococcal dose was administered less than 4 weeks ago"

/*
@input: The first pneumococcal dose was administered at 12–24 months post birth
@pseudocode: 12 months ≤ "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") − "Date of birth" < 24 months
@code: The first pneumococcal dose was administered at 12–24 months post birth-121
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The first pneumococcal dose was administered at 12–24 months post birth":
  AgeInMonthsAt("Date of First Pneumococcal Dose") >= 12
  and AgeInMonthsAt("Date of First Pneumococcal Dose") < 24

/*
@input: Three pneumococcal primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Pneumococcal vaccines" and "Type of dose" = "Primary series") = 3
@code: Three pneumococcal primary series doses were administered-121
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "Three pneumococcal primary series doses were administered":
  "Number of Pneumococcal Primary Series Doses Administered" = 3

/*
@input: The client's age is less than 24 months
@pseudocode: Today's date − "Date of birth" < 24 months
@code: The client's age is less than 24 months-42
@decision: IMMZ.D2.DT.Pneumococcal.3 doses: 3 primary doses (3p+0)
*/
define "The client's age is less than 24 months":
  Encounter."Current Patient Age In Months" < 24

/*
@internal: Date of First Pneumococcal Dose
*/
define "Date of First Pneumococcal Dose":
  date from start of "Pneumococcal Doses Administered to Patient".earliest().occurrence.toInterval()

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

/*
@internal: Pneumococcal Booster Series Doses Administered to Patient
*/
define "Pneumococcal Booster Series Doses Administered to Patient":
  "Pneumococcal Doses Administered to Patient".seriesBooster()

/*
@internal: Number of Pneumococcal Booster Series Doses Administered
*/
define "Number of Pneumococcal Booster Series Doses Administered":
  Count("Pneumococcal Booster Series Doses Administered to Patient")
Content: application/elm+xml
Encoded data (131144 characters)