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

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

This library defines decision support logic for the IMMZ.D18.S.Hepatitis B.Delayed start schedule table in the Immunization CPG

Title: IMMZD18SHepatitisB3DelayedLogic
Id: IMMZD18SHepatitisB3DelayedLogic
Version: 0.2.0
Url: IMMZD18SHepatitisB3DelayedLogic
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.D18.S.Hepatitis B.Delayed start schedule table in the Immunization CPG

Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
Todaydate01In
PatientPatient01Out
First hepatitis B dose was administeredboolean01Out
Hepatitis B dose 1boolean01Out
Hepatitis B dose 1 Due Datedate01Out
Hepatitis B dose 1 Overduedate01Out
Hepatitis B dose 1 Createstring01Out
Hepatitis B dose 1 ExpirationResource01Out
Second hepatitis B dose was administeredboolean01Out
Hepatitis B dose 2boolean01Out
Hepatitis B dose 2 Due Datedate01Out
Hepatitis B dose 2 Createstring01Out
Hepatitis B dose 2 OverdueResource01Out
Hepatitis B dose 2 ExpirationResource01Out
Third hepatitis B dose was administered. The primary series has been completedboolean01Out
Hepatitis B dose 3boolean01Out
Hepatitis B dose 3 Due Datedate01Out
Hepatitis B dose 3 Createstring01Out
Hepatitis B dose 3 OverdueResource01Out
Hepatitis B dose 3 ExpirationResource01Out
Test ValidationResource01Out
Content: text/cql

/*
 * Library: IMMZD18SHepatitisB3DelayedLogic (IMMZ.D18.S.Hepatitis B.Delayed start schedule)
 * Schedule Table: 3-dose schedule (no birth dose + 3 doses), delayed start
 */
library IMMZD18SHepatitisB3DelayedLogic

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

include WHOCommon called WC

include IMMZCommon called Common
include IMMZConcepts called Concepts

include IMMZEncounterElements called IE
include IMMZD2DTHepatitisBEncounterElements called Encounter

parameter Today Date default Today()

context Patient


/*
@output: Hepatitis B dose 1
@description: Provision of hepatitis B dose 1
@trigger: Child's birth
@triggerDate: "Date of birth"
*/
define "Hepatitis B dose 1":
  not "First hepatitis B dose was administered"

/*
@output: Hepatitis B dose 1 Create
@create: If delayed or interrupted scheduling of vaccination for children, adolescents and adults, 3 doses are recommended, with the second dose administered at least 1 month after the first, and the third dose 6 months after the first dose.
*/
define "Hepatitis B dose 1 Create":
  if "Hepatitis B dose 1" 
  then 'If delayed or interrupted scheduling of vaccination for children, adolescents and adults, 3 doses are recommended, with the second dose administered at least 1 month after the first, and the third dose 6 months after the first dose.' + '
Due Date: ' + ToString("Hepatitis B dose 1 Due Date") + '
Overdue: ' + ToString("Hepatitis B dose 1 Overdue")
  else ''

/*
@dynamicValue: Hepatitis B dose 1 Due Date
@pseudocode: "Date of birth"
*/
define "Hepatitis B dose 1 Due Date":
  if "Hepatitis B dose 1" then Patient.birthDate
  else null

/*
@dynamicValue: Hepatitis B dose 1 Overdue
@pseudocode: Today's date − "Date of birth" > Member States defined lower limit
*/
define "Hepatitis B dose 1 Overdue":
  Patient.birthDate + (Encounter.HepBLowerLimitWeeks * 1 weeks)

/*
@dynamicValue: Hepatitis B dose 1 Expiration
@pseudocode: To be determined by Member States; however, there is no recommended expiration date and individuals are always eligible to be vaccinated.
*/
define "Hepatitis B dose 1 Expiration":
  null

/*
@complete: First hepatitis B dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Hepatitis B-containing vaccines") = 1
*/
define "First hepatitis B dose was administered":
  Encounter."One hepatitis B primary series dose was administered"

/*
@output: Hepatitis B dose 2
@description: Provision of hepatitis B dose 2
@trigger: First hepatitis B dose was administered
Count of vaccines administered (where "Vaccine type" = "Hepatitis B-containing vaccines") = 1
@triggerDate: Latest "Date and time of vaccination" (where "Vaccine type" = "Hepatitis B-containing vaccines")
*/
define "Hepatitis B dose 2":
  "First hepatitis B dose was administered"
  and not "Second hepatitis B dose was administered"

/*
@output: Hepatitis B dose 2 Create
@create: If delayed or interrupted scheduling of vaccination for children, adolescents and adults, 3 doses are recommended, with the second dose administered at least 1 month after the first, and the third dose 6 months after the first dose.
*/
define "Hepatitis B dose 2 Create":
  if "Hepatitis B dose 2" 
  then 'If delayed or interrupted scheduling of vaccination for children, adolescents and adults, 3 doses are recommended, with the second dose administered at least 1 month after the first, and the third dose 6 months after the first dose.' + '
Due Date: ' + ToString("Hepatitis B dose 2 Due Date")
  else ''

/*
@dynamicValue: Hepatitis B dose 2 Due Date
@pseudocode: Latest "Date and time of vaccination" (where "Vaccine type" = "Hepatitis B-containing vaccines") + 1 month
*/
define "Hepatitis B dose 2 Due Date":
  if "Hepatitis B dose 2" then Encounter."Date of Latest Hepatitis B Dose" + 1 month
  else null

/*
@dynamicValue: Hepatitis B dose 2 Overdue
@pseudocode: To be determined by Member States; however, there is no recommended overdue date.
*/
define "Hepatitis B dose 2 Overdue":
  null

/*
@dynamicValue: Hepatitis B dose 2 Expiration
@pseudocode: To be determined by Member States; however, there is no recommended expiration date and individuals are always eligible to be vaccinated.
*/
define "Hepatitis B dose 2 Expiration":
  null

/*
@complete: Second hepatitis B dose was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Hepatitis B-containing vaccines") = 2
*/
define "Second hepatitis B dose was administered":
  Encounter."Two hepatitis B primary series doses were administered" 

/*
@output: Hepatitis B dose 3
@description: Provision of hepatitis B dose 3
@trigger: Second hepatitis B dose was administered
Count of vaccines administered (where "Vaccine type" = "Hepatitis B-containing vaccines") = 2
@triggerDate: "Date and time of vaccination" (where "Vaccine type" = "Hepatitis B-containing vaccines" and "Dose number" = 1)
*/
define "Hepatitis B dose 3":
  "Second hepatitis B dose was administered"
  and not "Third hepatitis B dose was administered. The primary series has been completed"

/*
@output: Hepatitis B dose 3 Create
@create: If delayed or interrupted scheduling of vaccination for children, adolescents and adults, 3 doses are recommended, with the second dose administered at least 1 month after the first, and the third dose 6 months after the first dose.
*/
define "Hepatitis B dose 3 Create":
  if "Hepatitis B dose 3" 
  then 'If delayed or interrupted scheduling of vaccination for children, adolescents and adults, 3 doses are recommended, with the second dose administered at least 1 month after the first, and the third dose 6 months after the first dose.' + '
Due Date: ' + ToString("Hepatitis B dose 3 Due Date")
  else ''

/*
@dynamicValue: Hepatitis B dose 3 Due Date
@pseudocode: "Date and time of vaccination" (where "Vaccine type" = "Hepatitis B-containing vaccines" and "Dose number" = 1) + 6 months
*/
define "Hepatitis B dose 3 Due Date":
  if "Hepatitis B dose 3" then Encounter."Date of First Hepatitis B Dose" + 6 months
  else null

/*
@dynamicValue: Hepatitis B dose 3 Overdue
@pseudocode: To be determined by Member States; however, there is no recommended overdue date.
*/
define "Hepatitis B dose 3 Overdue":
  null

/*
@dynamicValue: Hepatitis B dose 3 Expiration
@pseudocode: To be determined by Member States; however, there is no recommended expiration date and individuals are always eligible to be vaccinated.
*/
define "Hepatitis B dose 3 Expiration":
  null

/*
@complete: Third hepatitis B dose was administered. The primary series has been completed
@pseudocode: "Completed the primary vaccination series" = TRUE (where "Vaccine type" = "Hepatitis B-containing vaccines")
*/
define "Third hepatitis B dose was administered. The primary series has been completed":
  Encounter."Three hepatitis B primary series doses were administered" 

/*
@test: Test expected results based on example patients
*/
define "Test Validation":
  case
    when Patient.id = '50.Agt1d' then "Hepatitis B dose 1"
    when Patient.id = '51.D1HBltww' then "Hepatitis B dose 2"
    when Patient.id = '52.D1HBgt4w' then "Hepatitis B dose 2"
    when Patient.id = '53.D2HBlt4w' then "Hepatitis B dose 3"
    when Patient.id = '54.D2HBgt4wFDlt6m' then "Hepatitis B dose 3"
    when Patient.id = '55.D2HBgt4wFDgt6m' then "Hepatitis B dose 3"
    when Patient.id = '56.D3' then not "Hepatitis B dose 3" and "Third hepatitis B dose was administered. The primary series has been completed"
    else 'No test case set'
  end
Content: application/elm+xml
Encoded data (80032 characters)