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

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

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

Title: IMMZD2DTPolioEncounterElements
Id: IMMZD2DTPolioEncounterElements
Version: 0.2.0
Url: IMMZD2DTPolioEncounterElements
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 Polio used throughout the Immunization CPG

Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
Todaydate01In
EncounterIdstring01In
PatientPatient01Out
Polio Doses Administered to PatientImmunization0*Out
bOPV Doses Administered to PatientImmunization0*Out
IPV Doses Administered to PatientImmunization0*Out
Date of Latest Polio Dosedate01Out
Date of Latest bOPV Dosedate01Out
Date of Latest IPV Dosedate01Out
Polio Dose 0 Doses Administered to PatientImmunization0*Out
Number of Polio Dose 0 Doses Administeredinteger01Out
bOPV birth dose (a zero dose) was not administeredboolean01Out
bOPV birth dose (a zero dose) was administeredboolean01Out
Polio Primary Series Doses Administered to PatientImmunization0*Out
Date of First Primary Series Polio Dosedate01Out
Number of Polio Primary Series Doses Administeredinteger01Out
No poliovirus primary series doses were administeredboolean01Out
One poliovirus primary series dose was administeredboolean01Out
Two poliovirus primary series doses were administeredboolean01Out
Three poliovirus primary series doses were administeredboolean01Out
Four poliovirus primary series doses were administeredboolean01Out
Five poliovirus primary series doses were administeredboolean01Out
Polio bOPV Primary Series Doses Administered to PatientImmunization0*Out
Polio IPV Primary Series Doses Administered to PatientImmunization0*Out
Number of Polio bOPV Primary Series Doses Administeredinteger01Out
Number of Polio IPV Primary Series Doses Administeredinteger01Out
The poliovirus dose administered is bOPVboolean01Out
The poliovirus dose administered is IPVboolean01Out
The two doses administered are bOPVboolean01Out
From the two doses administered one is bOPV and one is IPVboolean01Out
The two doses administered are IPVboolean01Out
The three doses administered are bOPVboolean01Out
From the three doses administered, one is IPV and two are bOPVboolean01Out
From the three doses administered, one is bOPV and two are IPVboolean01Out
From the four doses administered, one is IPV and three are bOPVboolean01Out
From the four doses administered, two are IPV and two are bOPVboolean01Out
Polio Booster Series Doses Administered to PatientImmunization0*Out
Number of Polio Booster Series Doses Administeredinteger01Out
No polio booster dose was administeredboolean01Out
Polio booster dose was administeredboolean01Out
Client's age is less than 1 weekboolean01Out
Client's age is more than or equal to 1 weekboolean01Out
Client's age is less than 6 weeksboolean01Out
Client's age is between 6 weeks and 3 monthsboolean01Out
Client's age is more than 3 monthsboolean01Out
Client's age is between 6 weeks and 14 weeksboolean01Out
Client's age is more than or equal to 14 weeksboolean01Out
Client's age is less than 14 weeksboolean01Out
Client's age is less than 8 weeksboolean01Out
Client's age is more than or equal to 8 weeksboolean01Out
Client's age is more than or equal to 6 weeksboolean01Out
The latest bOPV dose was administered less than 4 weeks agoboolean01Out
The latest bOPV dose was administered more than 4 weeks agoboolean01Out
The latest IPV dose was administered less than 4 months agoboolean01Out
The latest IPV dose was administered more than 4 months agoboolean01Out
The latest poliovirus dose was administered less than 4 weeks agoboolean01Out
The latest poliovirus dose was administered more than 4 weeks agoboolean01Out
Client's age was more than 6 weeks when the primary series was startedboolean01Out
Client's age was 6 weeks when the primary series was startedboolean01Out
The latest poliovirus dose was administered less than 6 months agoboolean01Out
The latest poliovirus dose was administered more than 6 months agoboolean01Out
Content: text/cql

/*
  * Library: IMMZD2DTPolioEncounterElements
  */
library IMMZD2DTPolioEncounterElements

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 IMMZD2DTPolioElements called PolioElements

parameter Today Date default Today()
parameter EncounterId String

context Patient

/*
@internal: Polio containing Doses Administered to Patient
*/
define "Polio Doses Administered to Patient":
  PolioElements."Polio Doses Administered to Patient".onOrBefore(Today)

/*
@internal: bOPV Doses Administered to Patient
*/
define "bOPV Doses Administered to Patient":
  "Polio Doses Administered to Patient" I
  where I.typeOfDose() ~ Concepts."bOPV"

/*
@internal: IPV Doses Administered to Patient
*/
define "IPV Doses Administered to Patient":
  "Polio Doses Administered to Patient" I
  where I.typeOfDose() ~ Concepts."IPV"

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

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

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

/*
@internal: Polio containing Doses Administered to Patient that are in the Dose 0 (Birth) series
*/
define "Polio Dose 0 Doses Administered to Patient":
  PolioElements."Polio Dose 0 Doses Administered to Patient".onOrBefore(Today)

/*
@internal: Number of Polio Dose 0 doses
*/
define "Number of Polio Dose 0 Doses Administered":
  Count("Polio Dose 0 Doses Administered to Patient")

/*
@input: bOPV birth dose (a zero dose) was not administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Dose 0" AND "Birth dose" = TRUE) = 0
*/
define "bOPV birth dose (a zero dose) was not administered":
  "Number of Polio Dose 0 Doses Administered" = 0

/*
@input: bOPV birth dose (a zero dose) was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Dose 0" AND "Birth dose" = TRUE) = 1
*/
define "bOPV birth dose (a zero dose) was administered":
  "Number of Polio Dose 0 Doses Administered" = 1

/*
@internal: Polio containing Doses Administered to Patient that are in the Primary series
*/
define "Polio Primary Series Doses Administered to Patient":
  PolioElements."Polio Primary Series Doses Administered to Patient".onOrBefore(Today)

/*
@internal: Date and time of first Primary Series Polio dose
*/
define "Date of First Primary Series Polio Dose":
  date from start of "Polio Primary Series Doses Administered to Patient".earliest().occurrence.toInterval()

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

/*
@input: No poliovirus primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Primary series") = 0
*/
define "No poliovirus primary series doses were administered":
  "Number of Polio Primary Series Doses Administered" = 0

/*
@input: One poliovirus primary series dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Primary series") = 1
*/
define "One poliovirus primary series dose was administered":
  "Number of Polio Primary Series Doses Administered" = 1

/*
@input: Two poliovirus primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Primary series") = 2
*/
define "Two poliovirus primary series doses were administered":
  "Number of Polio Primary Series Doses Administered" = 2

/*
@input: Three poliovirus primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Primary series") = 3
*/
define "Three poliovirus primary series doses were administered":
  "Number of Polio Primary Series Doses Administered" = 3

/*
@input: Four poliovirus primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Primary series") = 4
*/
define "Four poliovirus primary series doses were administered":
  "Number of Polio Primary Series Doses Administered" = 4

/*
@input: Five poliovirus primary series doses were administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Primary series") = 5
*/
define "Five poliovirus primary series doses were administered":
  "Number of Polio Primary Series Doses Administered" = 5

/*
@internal: Polio bOPV  Doses Administered to Patient that are in the Primary series
*/
define "Polio bOPV Primary Series Doses Administered to Patient":
  "Polio Primary Series Doses Administered to Patient" I
  where I.typeOfDose() ~ Concepts."bOPV" 

/*
@internal: Polio IPV Doses Administered to Patient that are in the Primary series
*/
define "Polio IPV Primary Series Doses Administered to Patient":
  "Polio Primary Series Doses Administered to Patient" I
  where I.typeOfDose() ~ Concepts."IPV" 

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

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

/*
@input: The poliovirus dose administered is bOPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 1
*/
define "The poliovirus dose administered is bOPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 1

/*
@input: The poliovirus dose administered is IPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 0
*/
define "The poliovirus dose administered is IPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 0

/*
@input: The two doses administered are bOPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 2
*/
define "The two doses administered are bOPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 2

/*
@input: From the two doses administered one is bOPV and one is IPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 1
*/
define "From the two doses administered one is bOPV and one is IPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 1

/*
@input: The two doses administered are IPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 0
*/
define "The two doses administered are IPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 0

/*
@input: The three doses administered are bOPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 3
*/
define "The three doses administered are bOPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 3

/*
@input: From the three doses administered, one is IPV and two are bOPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 2
*/
define "From the three doses administered, one is IPV and two are bOPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 2

/*
@input: From the three doses administered, one is bOPV and two are IPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 1
*/
define "From the three doses administered, one is bOPV and two are IPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 1

/*
@input: From the four doses administered, one is IPV and three are bOPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 3
*/
define "From the four doses administered, one is IPV and three are bOPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 3

/*
@input: From the four doses administered, two are IPV and two are bOPV
@pseudocode: Count of vaccines administered (where "Type of poliovirus dose" = "bOPV" and "Type of dose" = "Primary series") = 2
*/
define "From the four doses administered, two are IPV and two are bOPV":
  "Number of Polio bOPV Primary Series Doses Administered" = 2

/*
@internal: Polio containing Doses Administered to Patient that are in the Booster series
*/
define "Polio Booster Series Doses Administered to Patient":
  PolioElements."Polio Booster Series Doses Administered to Patient".onOrBefore(Today)
/*
@internal: Number of Polio Booster Series doses
*/
define "Number of Polio Booster Series Doses Administered":
  Count("Polio Booster Series Doses Administered to Patient")

/*
@input: No polio booster dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Booster dose") = 0
*/
define "No polio booster dose was administered":
  "Number of Polio Booster Series Doses Administered" = 0

/*
@input: Polio booster dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of dose" = "Booster dose") = 1
*/
define "Polio booster dose was administered":
  "Number of Polio Booster Series Doses Administered" = 1
  
/*
@input: Client's age is less than 1 week
@pseudocode: Today's date − "Date of birth" < 1 week
*/
define "Client's age is less than 1 week":
  Encounter."Current Patient Age In Weeks" < 1

/*
@input: Client's age is more than or equal to 1 week
@pseudocode: Today's date − "Date of birth" ≥ 1 week
*/
define "Client's age is more than or equal to 1 week":
  Encounter."Current Patient Age In Weeks" >= 1

/*
@input: Client's age is less than 6 weeks
@pseudocode: Today's date − "Date of birth" < 6 weeks
*/
define "Client's age is less than 6 weeks":
  Encounter."Current Patient Age In Weeks" < 6

/*
@input: Client's age is between 6 weeks and 3 months
@pseudocode: 6 weeks ≤ Today's date − "Date of birth" ≤ 3 months
*/
define "Client's age is between 6 weeks and 3 months":
  6 <= Encounter."Current Patient Age In Weeks" 
  and Encounter."Current Patient Age In Months" <= 3

/*
@input: Client's age is more than 3 months
@pseudocode: Today's date − "Date of birth" > 3 months
*/
define "Client's age is more than 3 months":
  Encounter."Current Patient Age In Months" > 3

/*
@input: Client's age is between 6 weeks and 14 weeks
@pseudocode: 6 weeks ≤ Today's date − "Date of birth" < 14 weeks
*/
define "Client's age is between 6 weeks and 14 weeks":
  6 <= Encounter."Current Patient Age In Weeks" 
  and Encounter."Current Patient Age In Weeks" < 14

/*
@input: Client's age is more than or equal to 14 weeks
@pseudocode: Today's date − "Date of birth" ≥ 14 weeks
*/
define "Client's age is more than or equal to 14 weeks":
  Encounter."Current Patient Age In Weeks" >= 14

/*
@input: Client's age is less than 14 weeks
@pseudocode: Today's date − "Date of birth" < 14 weeks
*/
define "Client's age is less than 14 weeks":
  Encounter."Current Patient Age In Weeks" < 14

/*
@input: Client's age is less than 8 weeks
@pseudocode: Today's date − "Date of birth" < 8 weeks
*/
define "Client's age is less than 8 weeks":
  Encounter."Current Patient Age In Weeks" < 8

/*
@input: Client's age is more than or equal to 8 weeks
@pseudocode: Today's date − "Date of birth" ≥ 8 weeks
*/
define "Client's age is more than or equal to 8 weeks":
  Encounter."Current Patient Age In Weeks" >= 8

/*
@input: Client's age is more than or equal to 6 weeks
@pseudocode: Today's date − "Date of birth" ≥ 6 weeks
*/
define "Client's age is more than or equal to 6 weeks":
  Encounter."Current Patient Age In Weeks" >= 6

/*
@input: The latest bOPV dose was administered less than 4 weeks ago
@pseudocode: Today's date − Latest "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of poliovirus dose" = "bOPV") < 4 weeks
*/
define "The latest bOPV dose was administered less than 4 weeks ago":
  "Date of Latest bOPV Dose" is not null
    and duration in weeks between "Date of Latest bOPV Dose" and Today < 4

/*
@input: The latest bOPV dose was administered more than 4 weeks ago
@pseudocode: Today's date − Latest "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of poliovirus dose" = "bOPV") ≥ 4 weeks
*/
define "The latest bOPV dose was administered more than 4 weeks ago":
  not("The latest bOPV dose was administered less than 4 weeks ago")

/*
@input: The latest IPV dose was administered less than 4 months ago
@pseudocode: Today's date − Latest "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of poliovirus dose" = "IPV") < 4 months
*/
define "The latest IPV dose was administered less than 4 months ago":
  "Date of Latest IPV Dose" is not null
    and duration in months between "Date of Latest IPV Dose" and Today < 4
/*
@input: The latest IPV dose was administered more than 4 months ago
@pseudocode: Today's date − Latest "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines" and "Type of poliovirus dose" = "IPV") ≥ 4 months
*/
define "The latest IPV dose was administered more than 4 months ago":
  not("The latest IPV dose was administered less than 4 months ago")

/*
@input: The latest poliovirus dose was administered less than 4 weeks ago
@pseudocode: Today's date − Latest "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines") < 4 weeks
*/
define "The latest poliovirus dose was administered less than 4 weeks ago":
  "Date of Latest Polio Dose" is not null
    and duration in weeks between "Date of Latest Polio Dose" and Today < 4
    
/*
@input: The latest poliovirus dose was administered more than 4 weeks ago
@pseudocode: Today's date − Latest "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines") ≥ 4 weeks
*/
define "The latest poliovirus dose was administered more than 4 weeks ago":
  not("The latest poliovirus dose was administered less than 4 weeks ago")

/*
@input: Client's age was more than 6 weeks when the primary series was started
@pseudocode: "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines" AND "Dose number" = 1) − "Date of birth" > 6 weeks
@note: Dose number doesn't seem correct for this in case birth dose was given so using the series to determine primary series.
*/
define "Client's age was more than 6 weeks when the primary series was started":
  AgeInWeeksAt("Date of First Primary Series Polio Dose") > 6

/*
@input: Client's age was 6 weeks when the primary series was started
@pseudocode: "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines" AND "Dose number" = 1) − "Date of birth" = 6 weeks
*/
define "Client's age was 6 weeks when the primary series was started":
  AgeInWeeksAt("Date of First Primary Series Polio Dose") = 6

/*
@input: The latest poliovirus dose was administered less than 6 months ago
@pseudocode: Today's date − Latest "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines") < 6 months
*/
define "The latest poliovirus dose was administered less than 6 months ago":
  "Date of Latest Polio Dose" is not null
    and duration in months between "Date of Latest Polio Dose" and Today < 6
/*
@input: The latest poliovirus dose was administered more than 6 months ago
@pseudocode: Today's date − Latest "Date and time of vaccination" (where "Vaccine type" = "Poliovirus-containing vaccines") ≥ 6 months
*/
define "The latest poliovirus dose was administered more than 6 months ago":
  not("The latest poliovirus dose was administered less than 6 months ago")


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