<?xml version='1.0' encoding='UTF-8'?>
<Library xmlns="http://hl7.org/fhir" xmlns:html="http://www.w3.org/1999/xhtml">
  <id value="IMMZD18SPneumococcal3DosesLogic" />
  <meta>
    <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary" />
    <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary" />
    <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library" />
    <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-module" />
  </meta>
  <text>
    <status value="extensions" /><html:div><html:p><html:b style="color: maroon">Exception parsing generated Narrative (see /tmp/liquid-fa22f550-9744-4f22-91fc-b774b757bf39.html): Unable to Parse HTML - node 'code' has unexpected content ' ' (last text = '/*
 * Library: IMMZD18SPneumococcal3DosesLogic (IMMZ.D18.S.Pneumococcal.3 doses schedule)
 * Schedule Table: 3 primary doses (3p+0) schedule
 */
library IMMZD18SPneumococcal3DosesLogic

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 IMMZD2DTPneumococcalEncounterElements called Encounter

parameter Today Date default Today()


context Patient


/*
@output: Pneumococcal dose 1
@description: Provision of the pneumococcal dose 1
@trigger: Child's birth
@pseudo: 
@triggerDate: "Date of birth"
*/
define "Pneumococcal dose 1":
  Encounter."The client's age is less than or equal to 5 years"
  and Encounter."No pneumococcal primary series doses were administered"


/*
@output: Pneumococcal dose 1 Create
@create: Pneumococcal dose 1 should be provided if the client is older than 6 weeks
*/
define "Pneumococcal dose 1 Create":
  if "Pneumococcal dose 1"
  then 'Pneumococcal dose 1 should be provided if the client is older than 6 weeks' + '
Due Date: ' + ToString("Pneumococcal dose 1 Due Date")
  else ''


/*
@dynamicValue: Pneumococcal dose 1 Due Date
@pseudocode: "Date of birth" + 6 weeks
*/
define "Pneumococcal dose 1 Due Date":
  if "Pneumococcal dose 1" then Patient.birthDate + 6 weeks
  else null


/*
@dynamicValue: Pneumococcal dose 1 Overdue
@pseudocode: To be determined by Member States; however, there is no recommended overdue date. WHO does not currently have recommendations on the use of pneumococcal vaccine in individuals aged over 5 years.
*/
define "Pneumococcal dose 1 Overdue":
  null


/*
@dynamicValue: Pneumococcal dose 1 Expiration
@pseudocode: To be determined by Member States; however, there is no recommended expiration date. WHO does not currently have recommendations on the use of pneumococcal vaccine in individuals aged over 5 years.
*/
define "Pneumococcal dose 1 Expiration":
  null

  
/*
@complete: First pneumococcal dose from the primary series was administered
@pseudocode: Count of vaccines administered (where "Vaccine type" = "Pneumococcal vaccines" and "Type of dose" = "Primary series") = 1
*/
define "First pneumococcal dose from the primary series was administered":
  Encounter."One pneumococcal primary series dose was administered"



/*
@output: Pneumococcal dose 2, first within 24m
@description: Provision of the pneumococcal dose 2
@trigger: First pneumococcal dose from the primary series was administered to client, who is less than or equal to 5 years of age, within 24 months post birth
@pseudo: Today's date − "Date of birth" ≤ 5 years AND Count of vaccines administered (where "Vaccine type" = "Pneumococcal vaccines" and "Type of dose" = "Primary series") = 1 AND "Date and time of vaccination" (where "Vaccine type" = "Pneumococcal vaccines") − "Date of birth" ' at line 240 column 280</html:b></html:p></html:div>
  </text>
  <extension url="http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability">
    <valueCode value="computable" />
  </extension>
  <url value="http://smart.who.int/immunizations/Library/IMMZD18SPneumococcal3DosesLogic" />
  <version value="0.2.0" />
  <name value="IMMZD18SPneumococcal3DosesLogic" />
  <title value="IMMZD18SPneumococcal3DosesLogic" />
  <status value="draft" />
  <experimental value="false" />
  <type>
    <coding>
      <system value="http://terminology.hl7.org/CodeSystem/library-type" />
      <code value="logic-library" />
    </coding>
  </type>
  <date value="2026-11-19T08:10:32+00:00" />
  <publisher value="WHO" />
  <contact>
    <name value="WHO" />
    <telecom>
      <system value="url" />
      <value value="http://who.int" />
    </telecom>
  </contact>
  <description value="This library defines decision support logic for the IMMZ.D18.S.Pneumococcal.3 doses schedule table in the Immunization CPG" />
  <relatedArtifact>
    <type value="depends-on" />
    <display value="Library WC" />
    <resource value="http://smart.who.int/immunizations/Library/WHOCommon" />
  </relatedArtifact>
  <relatedArtifact>
    <type value="depends-on" />
    <display value="Library Common" />
    <resource value="http://smart.who.int/immunizations/Library/IMMZCommon" />
  </relatedArtifact>
  <relatedArtifact>
    <type value="depends-on" />
    <display value="Library Concepts" />
    <resource value="http://smart.who.int/immunizations/Library/IMMZConcepts" />
  </relatedArtifact>
  <relatedArtifact>
    <type value="depends-on" />
    <display value="Library IE" />
    <resource value="http://smart.who.int/immunizations/Library/IMMZEncounterElements" />
  </relatedArtifact>
  <relatedArtifact>
    <type value="depends-on" />
    <display value="Library Encounter" />
    <resource value="http://smart.who.int/immunizations/Library/IMMZD2DTPneumococcalEncounterElements" />
  </relatedArtifact>
  <content>
    <contentType value="text/cql" />
    <url value="Library-IMMZD18SPneumococcal3DosesLogic.cql" /></content>
  <content>
    <contentType value="application/elm+xml" />
    <url value="Library-IMMZD18SPneumococcal3DosesLogic.elm.xml" /></content>
</Library>