<?xml version='1.0' encoding='UTF-8'?>
<Library xmlns="http://hl7.org/fhir" xmlns:html="http://www.w3.org/1999/xhtml">
  <id value="IMMZD18SSeasonalinfluenzaSeasonalInfluenzaLogic" />
  <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-d04cf7fd-15eb-423d-b86e-889f944cbf47.html): Unable to Parse HTML - node 'code' has unexpected content ' ' (last text = '/*
 * Library: IMMZD18SSeasonalinfluenzaSeasonalInfluenzaLogic (IMMZ.D18.S.Seasonal influenza schedule)
 * Schedule Table: Inactivated trivalent and quadrivalent vaccines, 2-dose schedule for children aged under 9 years
 */
library IMMZD18SSeasonalinfluenzaSeasonalInfluenzaLogic

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

parameter Today Date default Today()


context Patient


/*
@output: Seasonal influenza dose 1
@description: Provision of the seasonal influenza vaccine dose 1
@trigger: Child's birth
@pseudo: 
@triggerDate: "Date of birth"
*/
define "Seasonal influenza dose 1":
  Encounter."No seasonal influenza primary series doses were administered"
  and not "First seasonal influenza dose from the primary series was administered"


/*
@output: Seasonal influenza dose 1 Create
@create: Influenza vaccines are safe and effective in children from 6 months of age
*/
define "Seasonal influenza dose 1 Create":
  if "Seasonal influenza dose 1"
  then 'Influenza vaccines are safe and effective in children from 6 months of age' + '
Due Date: ' + ToString("Seasonal influenza dose 1 Due Date")
  else ''


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


/*
@dynamicValue: Seasonal influenza dose 1 Overdue
@pseudocode: To be determined by Member States; however, there is no recommended overdue date and individuals are always eligible to be vaccinated
*/
define "Seasonal influenza dose 1 Overdue":
  null


/*
@dynamicValue: Seasonal influenza 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 "Seasonal influenza dose 1 Expiration":
  null

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



/*
@output: Seasonal influenza dose 2
@description: Provision of the seasonal influenza vaccine dose 2
@trigger: First seasonal influenza dose from the primary series was administered and client is less than 9 years
@pseudo: Count of vaccines administered (where "Vaccine type" = "Seasonal influenza vaccines" and "Type of dose" = "Primary series") = 1 AND (Today's date − "Date of birth" ' at line 240 column 175</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/IMMZD18SSeasonalinfluenzaSeasonalInfluenzaLogic" />
  <version value="0.2.0" />
  <name value="IMMZD18SSeasonalinfluenzaSeasonalInfluenzaLogic" />
  <title value="IMMZD18SSeasonalinfluenzaSeasonalInfluenzaLogic" />
  <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.Seasonal influenza 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/IMMZD2DTSeasonalinfluenzaEncounterElements" />
  </relatedArtifact>
  <content>
    <contentType value="text/cql" />
    <url value="Library-IMMZD18SSeasonalinfluenzaSeasonalInfluenzaLogic.cql" /></content>
  <content>
    <contentType value="application/elm+xml" />
    <url value="Library-IMMZD18SSeasonalinfluenzaSeasonalInfluenzaLogic.elm.xml" /></content>
</Library>