<?xml version="1.0" encoding="UTF-8"?><library xmlns="urn:hl7-org:elm:r1" xmlns:a="urn:hl7-org:cql-annotations:r1" xmlns:fhir="http://hl7.org/fhir" xmlns:t="urn:hl7-org:elm-types:r1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" localId="0"><annotation signatureLevel="Overloads" translatorOptions="EnableAnnotations,EnableLocators,DisableListDemotion,DisableListPromotion" translatorVersion="4.9.0" xsi:type="a:CqlToElmInfo"/><annotation errorSeverity="warning" errorType="semantic" message="An operand identifier reference is hiding another identifier of the same name." xsi:type="a:CqlToElmError"/><annotation errorSeverity="warning" errorType="semantic" message="An operand identifier reference is hiding another identifier of the same name." xsi:type="a:CqlToElmError"/><annotation errorSeverity="warning" errorType="semantic" message="An operand identifier reference is hiding another identifier of the same name." xsi:type="a:CqlToElmError"/><annotation xsi:type="a:Annotation"><a:s r="289"><a:s>/*
 * Library: IMMZD2DTHepatitisBBirthDoseLogic (IMMZ.D2.DT.Hepatitis B.Birth dose)
 * Rule: Determine if the client is due for a hepatitis B vaccination according to the national immunization schedule
 * Decision Table: Birth dose administration
 * Trigger: IMMZ.D2 Determine required vaccination(s) if any
 */
library IMMZD2DTHepatitisBBirthDoseLogic</a:s></a:s></annotation><identifier id="IMMZD2DTHepatitisBBirthDoseLogic" system="http://smart.who.int/immunizations"/><schemaIdentifier id="urn:hl7-org:elm" version="r1"/><usings><def localId="1" localIdentifier="System" uri="urn:hl7-org:elm-types:r1" version="1.0.0"/><def localId="206" localIdentifier="FHIR" locator="9:1-9:26" uri="http://hl7.org/fhir" version="4.0.1"><annotation xsi:type="a:Annotation"><a:s r="206"><a:s>using </a:s><a:s><a:s>FHIR</a:s></a:s><a:s> version '4.0.1'</a:s></a:s></annotation></def></usings><includes><def localId="208" localIdentifier="FHIRHelpers" locator="10:1-10:35" path="http://hl7.org/fhir/FHIRHelpers" version="4.0.1"><annotation xsi:type="a:Annotation"><a:s r="208"><a:s>include </a:s><a:s><a:s>FHIRHelpers</a:s></a:s><a:s> version '4.0.1'</a:s></a:s></annotation></def><def localId="210" localIdentifier="Encounter" locator="12:1-12:60" path="http://smart.who.int/immunizations/IMMZD2DTHepatitisBEncounterElements"><annotation xsi:type="a:Annotation"><a:s r="210"><a:s>include </a:s><a:s><a:s>IMMZD2DTHepatitisBEncounterElements</a:s></a:s><a:s> called Encounter</a:s></a:s></annotation></def></includes><parameters><def accessLevel="Public" localId="212" locator="14:1-14:36" name="Today"><annotation xsi:type="a:Annotation"><a:s r="212"><a:s>parameter Today </a:s><a:s r="216"><a:s>Date</a:s></a:s><a:s> default </a:s><a:s r="215"><a:s>Today()</a:s></a:s></a:s></annotation><default localId="215" locator="14:30-14:36" xsi:type="Today"/><parameterTypeSpecifier localId="216" locator="14:17-14:20" name="t:Date" xsi:type="NamedTypeSpecifier"/></def></parameters><contexts><def localId="221" locator="16:1-16:15" name="Patient"/></contexts><statements><def context="Patient" localId="219" locator="16:1-16:15" name="Patient"><expression localId="220" xsi:type="SingletonFrom"><operand dataType="fhir:Patient" localId="218" locator="16:1-16:15" templateId="http://hl7.org/fhir/StructureDefinition/Patient" xsi:type="Retrieve"/></expression></def><def accessLevel="Public" context="Patient" localId="229" locator="37:1-39:81" name="Client is due for hepatitis B monovalent vaccine"><annotation xsi:type="a:Annotation"><a:t name="output" value="Client is due for hepatitis B monovalent vaccine"/><a:t name="pseudocode" value="&#34;Immunization recommendation status&#34; = &#34;Due&#34; (where &#34;Type of hepatitis B dose&#34; = &#34;Hepatitis B monovalent vaccine&#34;)"/><a:s r="229"><a:s>/*
@output: Client is due for hepatitis B monovalent vaccine
@pseudocode: "Immunization recommendation status" = "Due" (where "Type of hepatitis B dose" = "Hepatitis B monovalent vaccine")
*/
define "Client is due for hepatitis B monovalent vaccine":
  </a:s><a:s r="230"><a:s r="232"><a:s r="231"><a:s>Encounter</a:s></a:s><a:s>.</a:s><a:s r="232"><a:s>"Hepatitis B birth dose was not administered"</a:s></a:s></a:s><a:s>
    and </a:s><a:s r="234"><a:s r="233"><a:s>Encounter</a:s></a:s><a:s>.</a:s><a:s r="234"><a:s>"Client's age is less than {Member States defined upper limit}"</a:s></a:s></a:s></a:s></a:s></annotation><expression localId="230" locator="38:3-39:81" xsi:type="And"><operand libraryName="Encounter" localId="232" locator="38:3-38:57" name="Hepatitis B birth dose was not administered" xsi:type="ExpressionRef"/><operand libraryName="Encounter" localId="234" locator="39:9-39:81" name="Client's age is less than {Member States defined upper limit}" xsi:type="ExpressionRef"/></expression></def><def accessLevel="Public" context="Patient" localId="238" locator="45:1-46:107" name="Client is due for hepatitis B monovalent vaccine Guidance"><annotation xsi:type="a:Annotation"><a:t name="output" value="Client is due for hepatitis B monovalent vaccine Guidance"/><a:t name="guidance" value="Should vaccinate client with hepatitis B birth dose, as a monovalent dose. Check for contraindications."/><a:s r="238"><a:s>/*
@output: Client is due for hepatitis B monovalent vaccine Guidance
@guidance: Should vaccinate client with hepatitis B birth dose, as a monovalent dose. Check for contraindications.
*/
define "Client is due for hepatitis B monovalent vaccine Guidance":
  </a:s><a:s r="239"><a:s>'Should vaccinate client with hepatitis B birth dose, as a monovalent dose. Check for contraindications.'</a:s></a:s></a:s></annotation><expression localId="239" locator="46:3-46:107" value="Should vaccinate client with hepatitis B birth dose, as a monovalent dose. Check for contraindications." valueType="t:String" xsi:type="Literal"/></def><def accessLevel="Public" context="Patient" localId="245" locator="52:1-54:81" name="Client should follow delayed-start decision logic"><annotation xsi:type="a:Annotation"><a:t name="output" value="Client should follow delayed-start decision logic"/><a:t name="pseudocode"/><a:s r="245"><a:s>/*
@output: Client should follow delayed-start decision logic
@pseudocode: 
*/
define "Client should follow delayed-start decision logic":
  </a:s><a:s r="246"><a:s r="248"><a:s r="247"><a:s>Encounter</a:s></a:s><a:s>.</a:s><a:s r="248"><a:s>"Hepatitis B birth dose was not administered"</a:s></a:s></a:s><a:s>
    and </a:s><a:s r="250"><a:s r="249"><a:s>Encounter</a:s></a:s><a:s>.</a:s><a:s r="250"><a:s>"Client's age is more than {Member States defined upper limit}"</a:s></a:s></a:s></a:s></a:s></annotation><expression localId="246" locator="53:3-54:81" xsi:type="And"><operand libraryName="Encounter" localId="248" locator="53:3-53:57" name="Hepatitis B birth dose was not administered" xsi:type="ExpressionRef"/><operand libraryName="Encounter" localId="250" locator="54:9-54:81" name="Client's age is more than {Member States defined upper limit}" xsi:type="ExpressionRef"/></expression></def><def accessLevel="Public" context="Patient" localId="254" locator="60:1-61:77" name="Client should follow delayed-start decision logic Guidance"><annotation xsi:type="a:Annotation"><a:t name="output" value="Client should follow delayed-start decision logic Guidance"/><a:t name="guidance" value="The client has a delayed start. Please follow the delayed start schedule."/><a:s r="254"><a:s>/*
@output: Client should follow delayed-start decision logic Guidance
@guidance: The client has a delayed start. Please follow the delayed start schedule.
*/
define "Client should follow delayed-start decision logic Guidance":
  </a:s><a:s r="255"><a:s>'The client has a delayed start. Please follow the delayed start schedule.'</a:s></a:s></a:s></annotation><expression localId="255" locator="61:3-61:77" value="The client has a delayed start. Please follow the delayed start schedule." valueType="t:String" xsi:type="Literal"/></def><def accessLevel="Public" context="Patient" localId="261" locator="67:1-68:53" name="Client is not due for the hepatitis B birth dose"><annotation xsi:type="a:Annotation"><a:t name="output" value="Client is not due for the hepatitis B birth dose"/><a:t name="pseudocode" value="&#34;Immunization recommendation status&#34; = &#34;Not due&#34;"/><a:s r="261"><a:s>/*
@output: Client is not due for the hepatitis B birth dose
@pseudocode: "Immunization recommendation status" = "Not due"
*/
define "Client is not due for the hepatitis B birth dose":
  </a:s><a:s r="263"><a:s r="262"><a:s>Encounter</a:s></a:s><a:s>.</a:s><a:s r="263"><a:s>"Hepatitis B birth dose was administered"</a:s></a:s></a:s></a:s></annotation><expression libraryName="Encounter" localId="263" locator="68:3-68:53" name="Hepatitis B birth dose was administered" xsi:type="ExpressionRef"/></def><def accessLevel="Public" context="Patient" localId="267" locator="74:1-75:93" name="Client is not due for the hepatitis B birth dose Guidance"><annotation xsi:type="a:Annotation"><a:t name="output" value="Client is not due for the hepatitis B birth dose Guidance"/><a:t name="guidance" value="Hepatitis B birth dose was already administered. Check hepatitis B immunization schedule."/><a:s r="267"><a:s>/*
@output: Client is not due for the hepatitis B birth dose Guidance
@guidance: Hepatitis B birth dose was already administered. Check hepatitis B immunization schedule.
*/
define "Client is not due for the hepatitis B birth dose Guidance":
  </a:s><a:s r="268"><a:s>'Hepatitis B birth dose was already administered. Check hepatitis B immunization schedule.'</a:s></a:s></a:s></annotation><expression localId="268" locator="75:3-75:93" value="Hepatitis B birth dose was already administered. Check hepatitis B immunization schedule." valueType="t:String" xsi:type="Literal"/></def><def accessLevel="Public" context="Patient" localId="224" locator="22:1-28:5" name="Guidance"><annotation xsi:type="a:Annotation"><a:t name="dynamicValue" value="Guidance"/><a:s r="224"><a:s>/*
@dynamicValue: Guidance
*/
define "Guidance":
  </a:s><a:s r="225"><a:s>case 
    </a:s><a:s r="226"><a:s>when </a:s><a:s r="235"><a:s>"Client is due for hepatitis B monovalent vaccine"</a:s></a:s><a:s> then </a:s><a:s r="241"><a:s>"Client is due for hepatitis B monovalent vaccine Guidance"</a:s></a:s></a:s><a:s>
    </a:s><a:s r="242"><a:s>when </a:s><a:s r="251"><a:s>"Client should follow delayed-start decision logic"</a:s></a:s><a:s> then </a:s><a:s r="257"><a:s>"Client should follow delayed-start decision logic Guidance"</a:s></a:s></a:s><a:s>
    </a:s><a:s r="258"><a:s>when </a:s><a:s r="264"><a:s>"Client is not due for the hepatitis B birth dose"</a:s></a:s><a:s> then </a:s><a:s r="270"><a:s>"Client is not due for the hepatitis B birth dose Guidance"</a:s></a:s></a:s><a:s> 
    else </a:s><a:s r="271"><a:s>''</a:s></a:s><a:s>
  end</a:s></a:s></a:s></annotation><expression localId="225" locator="23:3-28:5" xsi:type="Case"><caseItem localId="226" locator="24:5-24:124"><when localId="235" locator="24:10-24:59" name="Client is due for hepatitis B monovalent vaccine" xsi:type="ExpressionRef"/><then localId="241" locator="24:66-24:124" name="Client is due for hepatitis B monovalent vaccine Guidance" xsi:type="ExpressionRef"/></caseItem><caseItem localId="242" locator="25:5-25:126"><when localId="251" locator="25:10-25:60" name="Client should follow delayed-start decision logic" xsi:type="ExpressionRef"/><then localId="257" locator="25:67-25:126" name="Client should follow delayed-start decision logic Guidance" xsi:type="ExpressionRef"/></caseItem><caseItem localId="258" locator="26:5-26:124"><when localId="264" locator="26:10-26:59" name="Client is not due for the hepatitis B birth dose" xsi:type="ExpressionRef"/><then localId="270" locator="26:66-26:124" name="Client is not due for the hepatitis B birth dose Guidance" xsi:type="ExpressionRef"/></caseItem><else localId="271" locator="27:10-27:11" value="" valueType="t:String" xsi:type="Literal"/></expression></def><def accessLevel="Public" context="Patient" localId="275" locator="30:1-31:45" name="Has Guidance"><annotation xsi:type="a:Annotation"><a:s r="275"><a:s>define "Has Guidance":
  </a:s><a:s r="276"><a:s r="279"><a:s r="277"><a:s>"Guidance"</a:s></a:s><a:s> is not null</a:s></a:s><a:s> and </a:s><a:s r="286"><a:s r="281"><a:s>"Guidance"</a:s></a:s><a:s> != </a:s><a:s r="282"><a:s>''</a:s></a:s></a:s></a:s></a:s></annotation><expression localId="276" locator="31:3-31:45" xsi:type="And"><operand localId="279" locator="31:3-31:24" xsi:type="Not"><operand localId="278" locator="31:3-31:24" xsi:type="IsNull"><operand localId="277" locator="31:3-31:12" name="Guidance" xsi:type="ExpressionRef"/></operand></operand><operand localId="286" locator="31:30-31:45" xsi:type="Not"><operand localId="280" locator="31:30-31:45" xsi:type="Equal"><signature localId="284" name="t:String" xsi:type="NamedTypeSpecifier"/><signature localId="285" name="t:String" xsi:type="NamedTypeSpecifier"/><operand localId="281" locator="31:30-31:39" name="Guidance" xsi:type="ExpressionRef"/><operand localId="282" locator="31:44-31:45" value="" valueType="t:String" xsi:type="Literal"/></operand></operand></expression></def><def accessLevel="Public" context="Patient" localId="289" locator="81:1-87:5" name="Test Validation"><annotation xsi:type="a:Annotation"><a:t name="test" value="Test expected results based on example patients"/><a:s r="289"><a:s>/*
@test: Test expected results based on example patients
*/
define "Test Validation":
  </a:s><a:s r="290"><a:s>case
    </a:s><a:s r="291"><a:s>when </a:s><a:s r="292"><a:s r="294"><a:s r="293"><a:s>Patient</a:s></a:s><a:s>.</a:s><a:s r="294"><a:s>id</a:s></a:s></a:s><a:s> = </a:s><a:s r="295"><a:s>'HepatitisB08.2'</a:s></a:s></a:s><a:s> then </a:s><a:s r="301"><a:s r="302"><a:s>"Client is due for hepatitis B monovalent vaccine"</a:s></a:s><a:s> and </a:s><a:s r="303"><a:s r="304"><a:s>"Guidance"</a:s></a:s><a:s> = </a:s><a:s r="305"><a:s>'Should vaccinate client with hepatitis B birth dose, as a monovalent dose. Check for contraindications.'</a:s></a:s></a:s></a:s></a:s><a:s>
    </a:s><a:s r="309"><a:s>when </a:s><a:s r="310"><a:s r="312"><a:s r="311"><a:s>Patient</a:s></a:s><a:s>.</a:s><a:s r="312"><a:s>id</a:s></a:s></a:s><a:s> = </a:s><a:s r="313"><a:s>'HepatitisB09.2'</a:s></a:s></a:s><a:s> then </a:s><a:s r="319"><a:s r="320"><a:s>"Client should follow delayed-start decision logic"</a:s></a:s><a:s> and </a:s><a:s r="321"><a:s r="322"><a:s>"Guidance"</a:s></a:s><a:s> = </a:s><a:s r="323"><a:s>'The client has a delayed start. Please follow the delayed start schedule.'</a:s></a:s></a:s></a:s></a:s><a:s>
    </a:s><a:s r="327"><a:s>when </a:s><a:s r="328"><a:s r="330"><a:s r="329"><a:s>Patient</a:s></a:s><a:s>.</a:s><a:s r="330"><a:s>id</a:s></a:s></a:s><a:s> = </a:s><a:s r="331"><a:s>'HepatitisB10.1'</a:s></a:s></a:s><a:s> then </a:s><a:s r="337"><a:s r="338"><a:s>"Client is not due for the hepatitis B birth dose"</a:s></a:s><a:s> and </a:s><a:s r="339"><a:s r="340"><a:s>"Guidance"</a:s></a:s><a:s> = </a:s><a:s r="341"><a:s>'Hepatitis B birth dose was already administered. Check hepatitis B immunization schedule.'</a:s></a:s></a:s></a:s></a:s><a:s>
    else </a:s><a:s r="345"><a:s>'No test case set'</a:s></a:s><a:s>
  end</a:s></a:s></a:s></annotation><expression localId="290" locator="82:3-87:5" xsi:type="Case"><caseItem localId="291" locator="83:5-83:217"><when localId="292" locator="83:10-83:38" xsi:type="Equal"><signature localId="299" name="t:String" xsi:type="NamedTypeSpecifier"/><signature localId="300" name="t:String" xsi:type="NamedTypeSpecifier"/><operand libraryName="FHIRHelpers" localId="297" name="ToString" xsi:type="FunctionRef"><signature localId="298" name="fhir:string" xsi:type="NamedTypeSpecifier"/><operand localId="294" locator="83:10-83:19" path="id" xsi:type="Property"><source localId="293" locator="83:10-83:16" name="Patient" xsi:type="ExpressionRef"/></operand></operand><operand localId="295" locator="83:23-83:38" value="HepatitisB08.2" valueType="t:String" xsi:type="Literal"/></when><then localId="347" xsi:type="As"><operand localId="301" locator="83:45-83:217" xsi:type="And"><operand localId="302" locator="83:45-83:94" name="Client is due for hepatitis B monovalent vaccine" xsi:type="ExpressionRef"/><operand localId="303" locator="83:100-83:217" xsi:type="Equal"><signature localId="307" name="t:String" xsi:type="NamedTypeSpecifier"/><signature localId="308" name="t:String" xsi:type="NamedTypeSpecifier"/><operand localId="304" locator="83:100-83:109" name="Guidance" xsi:type="ExpressionRef"/><operand localId="305" locator="83:113-83:217" value="Should vaccinate client with hepatitis B birth dose, as a monovalent dose. Check for contraindications." valueType="t:String" xsi:type="Literal"/></operand></operand><asTypeSpecifier localId="348" xsi:type="ChoiceTypeSpecifier"><choice localId="349" name="t:Boolean" xsi:type="NamedTypeSpecifier"/><choice localId="350" name="t:String" xsi:type="NamedTypeSpecifier"/></asTypeSpecifier></then></caseItem><caseItem localId="309" locator="84:5-84:188"><when localId="310" locator="84:10-84:38" xsi:type="Equal"><signature localId="317" name="t:String" xsi:type="NamedTypeSpecifier"/><signature localId="318" name="t:String" xsi:type="NamedTypeSpecifier"/><operand libraryName="FHIRHelpers" localId="315" name="ToString" xsi:type="FunctionRef"><signature localId="316" name="fhir:string" xsi:type="NamedTypeSpecifier"/><operand localId="312" locator="84:10-84:19" path="id" xsi:type="Property"><source localId="311" locator="84:10-84:16" name="Patient" xsi:type="ExpressionRef"/></operand></operand><operand localId="313" locator="84:23-84:38" value="HepatitisB09.2" valueType="t:String" xsi:type="Literal"/></when><then localId="351" xsi:type="As"><operand localId="319" locator="84:45-84:188" xsi:type="And"><operand localId="320" locator="84:45-84:95" name="Client should follow delayed-start decision logic" xsi:type="ExpressionRef"/><operand localId="321" locator="84:101-84:188" xsi:type="Equal"><signature localId="325" name="t:String" xsi:type="NamedTypeSpecifier"/><signature localId="326" name="t:String" xsi:type="NamedTypeSpecifier"/><operand localId="322" locator="84:101-84:110" name="Guidance" xsi:type="ExpressionRef"/><operand localId="323" locator="84:114-84:188" value="The client has a delayed start. Please follow the delayed start schedule." valueType="t:String" xsi:type="Literal"/></operand></operand><asTypeSpecifier localId="352" xsi:type="ChoiceTypeSpecifier"><choice localId="353" name="t:Boolean" xsi:type="NamedTypeSpecifier"/><choice localId="354" name="t:String" xsi:type="NamedTypeSpecifier"/></asTypeSpecifier></then></caseItem><caseItem localId="327" locator="85:5-85:203"><when localId="328" locator="85:10-85:38" xsi:type="Equal"><signature localId="335" name="t:String" xsi:type="NamedTypeSpecifier"/><signature localId="336" name="t:String" xsi:type="NamedTypeSpecifier"/><operand libraryName="FHIRHelpers" localId="333" name="ToString" xsi:type="FunctionRef"><signature localId="334" name="fhir:string" xsi:type="NamedTypeSpecifier"/><operand localId="330" locator="85:10-85:19" path="id" xsi:type="Property"><source localId="329" locator="85:10-85:16" name="Patient" xsi:type="ExpressionRef"/></operand></operand><operand localId="331" locator="85:23-85:38" value="HepatitisB10.1" valueType="t:String" xsi:type="Literal"/></when><then localId="355" xsi:type="As"><operand localId="337" locator="85:45-85:203" xsi:type="And"><operand localId="338" locator="85:45-85:94" name="Client is not due for the hepatitis B birth dose" xsi:type="ExpressionRef"/><operand localId="339" locator="85:100-85:203" xsi:type="Equal"><signature localId="343" name="t:String" xsi:type="NamedTypeSpecifier"/><signature localId="344" name="t:String" xsi:type="NamedTypeSpecifier"/><operand localId="340" locator="85:100-85:109" name="Guidance" xsi:type="ExpressionRef"/><operand localId="341" locator="85:113-85:203" value="Hepatitis B birth dose was already administered. Check hepatitis B immunization schedule." valueType="t:String" xsi:type="Literal"/></operand></operand><asTypeSpecifier localId="356" xsi:type="ChoiceTypeSpecifier"><choice localId="357" name="t:Boolean" xsi:type="NamedTypeSpecifier"/><choice localId="358" name="t:String" xsi:type="NamedTypeSpecifier"/></asTypeSpecifier></then></caseItem><else localId="359" xsi:type="As"><operand localId="345" locator="86:10-86:27" value="No test case set" valueType="t:String" xsi:type="Literal"/><asTypeSpecifier localId="360" xsi:type="ChoiceTypeSpecifier"><choice localId="361" name="t:Boolean" xsi:type="NamedTypeSpecifier"/><choice localId="362" name="t:String" xsi:type="NamedTypeSpecifier"/></asTypeSpecifier></else></expression></def></statements></library>