{
  "resourceType": "Library",
  "id": "IMMZD18SHepatitisB4DosesLogic",
  "meta": {
    "profile": [
      "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary",
      "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary",
      "http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library",
      "http://hl7.org/fhir/uv/cql/StructureDefinition/cql-module"
    ]
  },
  "text": {
    "status": "extensions",
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n<div>\n    <table class=\"grid dict\">\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Title: </b></th>\n            <td style=\"padding-left: 4px;\">IMMZD18SHepatitisB4DosesLogic</td>\n        </tr>\n        \n\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Id: </b></th>\n            <td style=\"padding-left: 4px;\">IMMZD18SHepatitisB4DosesLogic</td>\n        </tr>\n        \n\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Version: </b></th>\n            <td style=\"padding-left: 4px;\">0.2.0</td>\n        </tr>\n        \n\n        \n        <tr>\n            <th scope=\"row\"><b>Url: </b></th>\n            <td style=\"padding-left: 4px;\"><a href=\"Library-IMMZD18SHepatitisB4DosesLogic.html\">IMMZD18SHepatitisB4DosesLogic</a></td>\n        </tr>\n        \n\n        \n\n        \n\n        \n        <tr>\n            <th scope=\"row\"><b>Status: </b></th>\n            <td style=\"padding-left: 4px;\">draft</td>\n        </tr>\n        \n\n        \n\n        \n        <tr>\n            <th scope=\"row\"><b>Type: </b></th>\n            <td style=\"padding-left: 4px;\">\n                \n                    \n                        \n                        <p style=\"margin-bottom: 5px;\">\n                            <b>system: </b> <span><a href=\"http://terminology.hl7.org/7.1.0/CodeSystem-library-type.html\">http://terminology.hl7.org/CodeSystem/library-type</a></span>\n                        </p>\n                        \n                        \n                        <p style=\"margin-bottom: 5px;\">\n                            <b>code: </b> <span>logic-library</span>\n                        </p>\n                        \n                        \n                    \n                \n                \n            </td>\n        </tr>\n        \n\n        \n\n        \n        <tr>\n            <th scope=\"row\"><b>Date: </b></th>\n            <td style=\"padding-left: 4px;\">2026-03-29 17:23:09+0000</td>\n        </tr>\n        \n\n        \n        <tr>\n            <th scope=\"row\"><b>Publisher: </b></th>\n            <td style=\"padding-left: 4px;\">WHO</td>\n        </tr>\n        \n\n        \n        <tr>\n            <th scope=\"row\"><b>Description: </b></th>\n            <td style=\"padding-left: 4px;\"><div><p>This library defines decision support logic for the IMMZ.D18.S.Hepatitis B.4-dose schedule table in the Immunization CPG</p>\n</div></td>\n        </tr>\n        \n\n        \n\n        \n\n        \n\n        \n\n        \n\n        \n\n        \n\n        \n\n        \n\n        \n\n        \n        <tr>\n            <th scope=\"row\"><b>Related Artifacts: </b></th>\n            <td style=\"padding-left: 4px;\">\n                \n                \n                \n                <p><b>Dependencies</b></p>\n                <ul>\n                  \n                    <li><a href=\"Library-WHOCommon.html\">WHOCommon</a></li>\n                  \n                    <li><a href=\"Library-IMMZCommon.html\">IMMZCommon</a></li>\n                  \n                    <li><a href=\"Library-IMMZConcepts.html\">IMMZConcepts</a></li>\n                  \n                    <li><a href=\"Library-IMMZEncounterElements.html\">IMMZEncounterElements</a></li>\n                  \n                    <li><a href=\"Library-IMMZD2DTHepatitisBEncounterElements.html\">IMMZD2DTHepatitisBEncounterElements</a></li>\n                  \n                </ul>\n                \n                \n                \n                \n                \n            </td>\n        </tr>\n        \n\n        \n        <tr>\n          <th scope=\"row\"><b>Parameters: </b></th>\n          <td style=\"padding-left: 4px;\">\n            <table class=\"grid-dict\">\n              <tr><th><b>Name</b></th><th><b>Type</b></th><th><b>Min</b></th><th><b>Max</b></th><th><b>In/Out</b></th></tr>\n              \n                <tr><th>Today</th><th>date</th><th>0</th><th>1</th><th>In</th></tr>\n              \n                <tr><th>Patient</th><th>Patient</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>First hepatitis B dose from the primary series was administered</th><th>boolean</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Second hepatitis B dose from the primary series was administered</th><th>boolean</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Third hepatitis B dose from the primary series was administered. The primary series has been completed</th><th>boolean</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 1</th><th>boolean</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 1 Due Date</th><th>date</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 1 Create</th><th>string</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 1 Overdue</th><th>Resource</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 1 Expiration</th><th>Resource</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 2</th><th>boolean</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 2 Due Date</th><th>date</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 2 Create</th><th>string</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 2 Overdue</th><th>Resource</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 2 Expiration</th><th>Resource</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 3</th><th>boolean</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 3 Due Date</th><th>date</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 3 Create</th><th>string</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 3 Overdue</th><th>Resource</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Hepatitis B dose 3 Expiration</th><th>Resource</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n                <tr><th>Test Validation</th><th>Resource</th><th>0</th><th>1</th><th>Out</th></tr>\n              \n            </table>\n          </td>\n        </tr>\n        \n\n        \n\n        \n        \n        <tr>\n          <td colspan=\"2\">\n            <table>\n              <tr><th><a id=\"cql-content\"><b>Content: </b></a> text/cql</th></tr>\n              <tr><td><pre><code class=\"language-cql\">/*\n * Library: IMMZD18SHepatitisB4DosesLogic (IMMZ.D18.S.Hepatitis B.4-dose schedule)\n * Schedule Table: 4-dose schedule (birth dose + 3 primary series doses), on-time start\n */\nlibrary IMMZD18SHepatitisB4DosesLogic\n\nusing FHIR version '4.0.1'\ninclude FHIRHelpers version '4.0.1'\n\ninclude WHOCommon called WC\n\ninclude IMMZCommon called Common\ninclude IMMZConcepts called Concepts\n\ninclude IMMZEncounterElements called IE\ninclude IMMZD2DTHepatitisBEncounterElements called Encounter\n\nparameter Today Date default Today()\n\n\ncontext Patient\n\n\n/*\n@output: Hepatitis B dose 1\n@description: Provision of hepatitis B dose 1\n@trigger: Child's birth\n@pseudo: \n@triggerDate: &quot;Date of birth&quot;\n*/\ndefine &quot;Hepatitis B dose 1&quot;:\n  not &quot;First hepatitis B dose from the primary series was administered&quot;\n    and not &quot;Second hepatitis B dose from the primary series was administered&quot;\n    and not &quot;Third hepatitis B dose from the primary series was administered. The primary series has been completed&quot;\n\n\n/*\n@output: Hepatitis B dose 1 Create\n@create: The following option is considered appropriate: 4 doses, where a monovalent birth dose is followed by 3 (monovalent or combined vaccine) doses, usually given with other routine infant vaccines; the additional dose does not cause any harm. The interval between doses should be at least 4 weeks.\n*/\ndefine &quot;Hepatitis B dose 1 Create&quot;:\n  if &quot;Hepatitis B dose 1&quot;\n  then 'The following option is considered appropriate: 4 doses, where a monovalent birth dose is followed by 3 (monovalent or combined vaccine) doses, usually given with other routine infant vaccines; the additional dose does not cause any harm. The interval between doses should be at least 4 weeks.' + '\nDue Date: ' + ToString(&quot;Hepatitis B dose 1 Due Date&quot;)\n  else ''\n\n\n/*\n@dynamicValue: Hepatitis B dose 1 Due Date\n@pseudocode: &quot;Date of birth&quot; + Member States defined lower limit\n*/\ndefine &quot;Hepatitis B dose 1 Due Date&quot;:\n  if &quot;Hepatitis B dose 1&quot; then Patient.birthDate + (Encounter.HepBLowerLimitWeeks * 1 weeks)\n  else null\n\n\n/*\n@dynamicValue: Hepatitis B dose 1 Overdue\n@pseudocode: To be determined by Member States; however, there is no recommended overdue date.\n*/\ndefine &quot;Hepatitis B dose 1 Overdue&quot;:\n  null\n\n\n/*\n@dynamicValue: Hepatitis B dose 1 Expiration\n@pseudocode: To be determined by Member States; however, there is no recommended expiration date and individuals are always eligible to be vaccinated.\n*/\ndefine &quot;Hepatitis B dose 1 Expiration&quot;:\n  null\n\n  \n/*\n@complete: First hepatitis B dose from the primary series was administered\n@pseudocode: Count of vaccines administered (where &quot;Vaccine type&quot; = &quot;Hepatitis B-containing vaccines&quot; and &quot;Type of dose&quot;= &quot;Primary series&quot;) = 1\n*/\ndefine &quot;First hepatitis B dose from the primary series was administered&quot;:\n  Encounter.&quot;One hepatitis B primary series dose was administered&quot;\n\n\n\n/*\n@output: Hepatitis B dose 2\n@description: Provision of hepatitis B dose 2\n@trigger: First hepatitis B dose from the primary series was administered\n@pseudo: Count of vaccines administered (where &quot;Vaccine type&quot; = &quot;Hepatitis B-containing vaccines&quot; and &quot;Type of dose&quot;= &quot;Primary series&quot;) = 1\n@triggerDate: Latest &quot;Date and time of vaccination&quot; (where &quot;Vaccine type&quot; = &quot;Hepatitis B-containing vaccines&quot;)\n*/\ndefine &quot;Hepatitis B dose 2&quot;:\n  &quot;First hepatitis B dose from the primary series was administered&quot;\n    and not &quot;Second hepatitis B dose from the primary series was administered&quot;\n    and not &quot;Third hepatitis B dose from the primary series was administered. The primary series has been completed&quot;\n\n\n/*\n@output: Hepatitis B dose 2 Create\n@create: The following option is considered appropriate: 4 doses, where a monovalent birth dose is followed by 3 (monovalent or combined vaccine) doses, usually given with other routine infant vaccines; the additional dose does not cause any harm. The interval between doses should be at least 4 weeks.\n*/\ndefine &quot;Hepatitis B dose 2 Create&quot;:\n  if &quot;Hepatitis B dose 2&quot;\n  then 'The following option is considered appropriate: 4 doses, where a monovalent birth dose is followed by 3 (monovalent or combined vaccine) doses, usually given with other routine infant vaccines; the additional dose does not cause any harm. The interval between doses should be at least 4 weeks.' + '\nDue Date: ' + ToString(&quot;Hepatitis B dose 2 Due Date&quot;)\n  else ''\n\n\n/*\n@dynamicValue: Hepatitis B dose 2 Due Date\n@pseudocode: Latest &quot;Date and time of vaccination&quot; (where &quot;Vaccine type&quot; = &quot;Hepatitis B-containing vaccines&quot;) + 4 weeks\n*/\ndefine &quot;Hepatitis B dose 2 Due Date&quot;:\n  if &quot;Hepatitis B dose 2&quot; then Encounter.&quot;Date of Latest Hepatitis B Dose&quot; + 4 weeks\n  else null\n\n\n/*\n@dynamicValue: Hepatitis B dose 2 Overdue\n@pseudocode: To be determined by Member States; however, there is no recommended overdue date.\n*/\ndefine &quot;Hepatitis B dose 2 Overdue&quot;:\n  null\n\n\n/*\n@dynamicValue: Hepatitis B dose 2 Expiration\n@pseudocode: To be determined by Member States; however, there is no recommended expiration date and individuals are always eligible to be vaccinated.\n*/\ndefine &quot;Hepatitis B dose 2 Expiration&quot;:\n  null\n\n  \n/*\n@complete: Second hepatitis B dose from the primary series was administered\n@pseudocode: Count of vaccines administered (where &quot;Vaccine type&quot; = &quot;Hepatitis B-containing vaccines&quot; and &quot;Type of dose&quot;= &quot;Primary series&quot;) = 2\n*/\ndefine &quot;Second hepatitis B dose from the primary series was administered&quot;:\n  Encounter.&quot;Two hepatitis B primary series doses were administered&quot;\n\n\n\n/*\n@output: Hepatitis B dose 3\n@description: Provision of hepatitis B dose 3\n@trigger: Second hepatitis B dose from the primary series was administered\n@pseudo: Count of vaccines administered (where &quot;Vaccine type&quot; = &quot;Hepatitis B-containing vaccines&quot; and &quot;Type of dose&quot;= &quot;Primary series&quot;) = 2\n@triggerDate: Latest &quot;Date and time of vaccination&quot; (where &quot;Vaccine type&quot; = &quot;Hepatitis B-containing vaccines&quot;)\n*/\ndefine &quot;Hepatitis B dose 3&quot;:\n  &quot;Second hepatitis B dose from the primary series was administered&quot;\n    and not &quot;Third hepatitis B dose from the primary series was administered. The primary series has been completed&quot;\n\n\n/*\n@output: Hepatitis B dose 3 Create\n@create: The following option is considered appropriate: 4 doses, where a monovalent birth dose is followed by 3 (monovalent or combined vaccine) doses, usually given with other routine infant vaccines; the additional dose does not cause any harm. The interval between doses should be at least 4 weeks.\n*/\ndefine &quot;Hepatitis B dose 3 Create&quot;:\n  if &quot;Hepatitis B dose 3&quot;\n  then 'The following option is considered appropriate: 4 doses, where a monovalent birth dose is followed by 3 (monovalent or combined vaccine) doses, usually given with other routine infant vaccines; the additional dose does not cause any harm. The interval between doses should be at least 4 weeks.' + '\nDue Date: ' + ToString(&quot;Hepatitis B dose 3 Due Date&quot;)\n  else ''\n\n\n/*\n@dynamicValue: Hepatitis B dose 3 Due Date\n@pseudocode: Latest &quot;Date and time of vaccination&quot; (where &quot;Vaccine type&quot; = &quot;Hepatitis B-containing vaccines&quot;) + 4 weeks\n*/\ndefine &quot;Hepatitis B dose 3 Due Date&quot;:\n  if &quot;Hepatitis B dose 3&quot; then Encounter.&quot;Date of Latest Hepatitis B Dose&quot; + 4 weeks\n  else null\n\n\n/*\n@dynamicValue: Hepatitis B dose 3 Overdue\n@pseudocode: To be determined by Member States; however, there is no recommended overdue date.\n*/\ndefine &quot;Hepatitis B dose 3 Overdue&quot;:\n  null\n\n\n/*\n@dynamicValue: Hepatitis B dose 3 Expiration\n@pseudocode: To be determined by Member States; however, there is no recommended expiration date and individuals are always eligible to be vaccinated.\n*/\ndefine &quot;Hepatitis B dose 3 Expiration&quot;:\n  null\n\n  \n/*\n@complete: Third hepatitis B dose from the primary series was administered. The primary series has been completed\n@pseudocode: &quot;Completed the primary vaccination series&quot; = TRUE (where &quot;Vaccine type&quot; = &quot;Hepatitis B-containing vaccines&quot;)\n*/\ndefine &quot;Third hepatitis B dose from the primary series was administered. The primary series has been completed&quot;:\n  Encounter.&quot;Three hepatitis B primary series doses were administered&quot;\n\n\n\n/*\n@test: Test expected results based on example patients\n*/\ndefine &quot;Test Validation&quot;:\n  case\n    when Patient.id = 'HepatitisB36.2' then &quot;Hepatitis B dose 1&quot;\n    when Patient.id = 'HepatitisB37.2' then &quot;Hepatitis B dose 1&quot;\n    when Patient.id = 'HepatitisB38.2' then &quot;Hepatitis B dose 2&quot;\n    when Patient.id = 'HepatitisB39.2' then &quot;Hepatitis B dose 2&quot;\n    when Patient.id = 'HepatitisB40.2' then &quot;Hepatitis B dose 3&quot;\n    when Patient.id = 'HepatitisB41.2' then &quot;Hepatitis B dose 3&quot;\n    when Patient.id = 'HepatitisB42.1' then not &quot;Hepatitis B dose 3&quot; and &quot;Third hepatitis B dose from the primary series was administered. The primary series has been completed&quot;\n    else 'No test case set'\n  end\n</code></pre></td></tr>\n            </table>\n          </td>\n        </tr>\n        \n        \n        \n        \n        \n        <tr>\n          <td colspan=\"2\">\n            <table>\n              <tr><th><b>Content: </b> application/elm+xml</th></tr>\n              <tr><td><pre><code>Encoded data (83604 characters)</code></pre></td></tr>\n            </table>\n          </td>\n        </tr>\n        \n        \n    </table>\n</div>\n</div>"
  },
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability",
      "valueCode": "computable"
    }
  ],
  "url": "http://smart.who.int/immunizations/Library/IMMZD18SHepatitisB4DosesLogic",
  "version": "0.2.0",
  "name": "IMMZD18SHepatitisB4DosesLogic",
  "title": "IMMZD18SHepatitisB4DosesLogic",
  "status": "draft",
  "experimental": false,
  "type": {
    "coding": [
      {
        "system": "http://terminology.hl7.org/CodeSystem/library-type",
        "code": "logic-library"
      }
    ]
  },
  "date": "2026-03-29T17:23:09+00:00",
  "publisher": "WHO",
  "contact": [
    {
      "name": "WHO",
      "telecom": [
        {
          "system": "url",
          "value": "http://who.int"
        }
      ]
    }
  ],
  "description": "This library defines decision support logic for the IMMZ.D18.S.Hepatitis B.4-dose schedule table in the Immunization CPG",
  "relatedArtifact": [
    {
      "type": "depends-on",
      "display": "Library WC",
      "resource": "http://smart.who.int/immunizations/Library/WHOCommon"
    },
    {
      "type": "depends-on",
      "display": "Library Common",
      "resource": "http://smart.who.int/immunizations/Library/IMMZCommon"
    },
    {
      "type": "depends-on",
      "display": "Library Concepts",
      "resource": "http://smart.who.int/immunizations/Library/IMMZConcepts"
    },
    {
      "type": "depends-on",
      "display": "Library IE",
      "resource": "http://smart.who.int/immunizations/Library/IMMZEncounterElements"
    },
    {
      "type": "depends-on",
      "display": "Library Encounter",
      "resource": "http://smart.who.int/immunizations/Library/IMMZD2DTHepatitisBEncounterElements"
    }
  ],
  "parameter": [
    {
      "name": "Today",
      "use": "in",
      "min": 0,
      "max": "1",
      "type": "date"
    },
    {
      "name": "Patient",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "Patient"
    },
    {
      "name": "First hepatitis B dose from the primary series was administered",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "boolean"
    },
    {
      "name": "Second hepatitis B dose from the primary series was administered",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "boolean"
    },
    {
      "name": "Third hepatitis B dose from the primary series was administered. The primary series has been completed",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "boolean"
    },
    {
      "name": "Hepatitis B dose 1",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "boolean"
    },
    {
      "name": "Hepatitis B dose 1 Due Date",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "date"
    },
    {
      "name": "Hepatitis B dose 1 Create",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "string"
    },
    {
      "name": "Hepatitis B dose 1 Overdue",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "Resource"
    },
    {
      "name": "Hepatitis B dose 1 Expiration",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "Resource"
    },
    {
      "name": "Hepatitis B dose 2",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "boolean"
    },
    {
      "name": "Hepatitis B dose 2 Due Date",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "date"
    },
    {
      "name": "Hepatitis B dose 2 Create",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "string"
    },
    {
      "name": "Hepatitis B dose 2 Overdue",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "Resource"
    },
    {
      "name": "Hepatitis B dose 2 Expiration",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "Resource"
    },
    {
      "name": "Hepatitis B dose 3",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "boolean"
    },
    {
      "name": "Hepatitis B dose 3 Due Date",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "date"
    },
    {
      "name": "Hepatitis B dose 3 Create",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "string"
    },
    {
      "name": "Hepatitis B dose 3 Overdue",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "Resource"
    },
    {
      "name": "Hepatitis B dose 3 Expiration",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "Resource"
    },
    {
      "name": "Test Validation",
      "use": "out",
      "min": 0,
      "max": "1",
      "type": "Resource"
    }
  ],
  "content": [
    {
      "contentType": "text/cql",
      "url": "Library-IMMZD18SHepatitisB4DosesLogic.cql"
    },
    {
      "contentType": "application/elm+xml",
      "url": "Library-IMMZD18SHepatitisB4DosesLogic.elm.xml"
    }
  ]
}
