Clinical Quality Language Specification
1.5.3 - Release 1 Errata 2

Clinical Quality Language Specification, published by Clinical Decision Support WG. This guide is not an authorized publication; it is the continuous build for version 1.5.3 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/cql/ and changes regularly. See the Directory of published versions

Binary: Related Context Retrieve Example ELM Library (XML)

    
<?xml version="1.0" encoding="UTF-8"?>
<library xmlns="urn:hl7-org:elm:r1" xmlns:t="urn:hl7-org:elm-types:r1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:fhir="http://hl7.org/fhir" xmlns:qdm43="urn:healthit-gov:qdm:v4_3" xmlns:qdm53="urn:healthit-gov:qdm:v5_3" xmlns:a="urn:hl7-org:cql-annotations:r1">
   <identifier id="Example.RelatedContextRetrieve" system="http://example.org/measures" version="0.1.0"/>
   <schemaIdentifier id="urn:hl7-org:elm" version="r1"/>
   <usings>
      <def localIdentifier="System" uri="urn:hl7-org:elm-types:r1"/>
      <def localIdentifier="QDM" uri="urn:healthit-gov:qdm:v5_5" version="5.5"/>
   </usings>
   <codeSystems>
      <def name="SNOMED" id="1.2.3.4.5" accessLevel="Public"/>
   </codeSystems>
   <valueSets>
      <def name="Estimated Due Date Exam" id="TBD" accessLevel="Public"/>
      <def name="Live Delivery" id="TBD" accessLevel="Public"/>
   </valueSets>
   <codes>
      <def name="Mother Relationship" id="Mother" accessLevel="Public">
         <codeSystem name="SNOMED"/>
      </def>
   </codes>
   <statements>
      <def name="Patient" context="Patient">
         <expression xsi:type="SingletonFrom">
            <operand xmlns:ns0="urn:healthit-gov:qdm:v5_5" dataType="ns0:Patient" templateId="Patient" xsi:type="Retrieve"/>
         </expression>
      </def>
      <def name="Mother" context="Patient" accessLevel="Public">
         <expression xsi:type="SingletonFrom">
            <operand xmlns:ns1="urn:healthit-gov:qdm:v5_5" dataType="ns1:RelatedPerson" codeProperty="code" xsi:type="Retrieve">
               <codes xsi:type="ToList">
                  <operand name="Mother Relationship" xsi:type="CodeRef"/>
               </codes>
            </operand>
         </expression>
      </def>
      <def name="Birth Date" context="Patient" accessLevel="Public">
         <expression xsi:type="Start">
            <operand path="relevantPeriod" xsi:type="Property">
               <source xsi:type="Last">
                  <source xsi:type="Query">
                     <source alias="Delivery">
                        <expression xmlns:ns2="urn:healthit-gov:qdm:v5_5" dataType="ns2:PositiveEncounterPerformed" templateId="PositiveEncounterPerformed" codeProperty="code" xsi:type="Retrieve">
                           <codes name="Live Delivery" xsi:type="ValueSetRef"/>
                        </expression>
                     </source>
                     <sort>
                        <by direction="asc" xsi:type="ByExpression">
                           <expression xsi:type="Start">
                              <operand name="relevantPeriod" xsi:type="IdentifierRef"/>
                           </expression>
                        </by>
                     </sort>
                  </source>
               </source>
            </operand>
         </expression>
      </def>
      <def name="Estimated Due Date" context="Patient" accessLevel="Public">
         <expression strict="false" xsi:type="As">
            <operand path="result" xsi:type="Property">
               <source xsi:type="Last">
                  <source xsi:type="Query">
                     <source alias="Exam">
                        <expression xmlns:ns3="urn:healthit-gov:qdm:v5_5" dataType="ns3:PositivePhysicalExamPerformed" templateId="PositivePhysicalExamPerformed" codeProperty="code" xsi:type="Retrieve">
                           <codes name="Estimated Due Date Exam" xsi:type="ValueSetRef"/>
                           <context path="linkedPatientId" xsi:type="Property">
                             <source name="Mother" xsi:type="ExpressionRef"/>
                           </context>
                        </expression>
                     </source>
                     <where xsi:type="SameAs">
                        <operand xsi:type="End">
                           <operand path="relevantPeriod" scope="Exam" xsi:type="Property"/>
                        </operand>
                        <operand xsi:type="Subtract">
                           <operand name="Birth Date" xsi:type="ExpressionRef"/>
                           <operand value="1" unit="year" xsi:type="Quantity"/>
                        </operand>
                     </where>
                     <sort>
                        <by direction="asc" xsi:type="ByExpression">
                           <expression xsi:type="Start">
                              <operand name="relevantPeriod" xsi:type="IdentifierRef"/>
                           </expression>
                        </by>
                     </sort>
                  </source>
               </source>
            </operand>
            <asTypeSpecifier name="t:DateTime" xsi:type="NamedTypeSpecifier"/>
         </expression>
      </def>
      <def name="Gestational Age in Days at Birth" context="Patient" accessLevel="Public">
         <expression xsi:type="TruncatedDivide">
            <operand xsi:type="Subtract">
               <operand valueType="t:Integer" value="280" xsi:type="Literal"/>
               <operand precision="Day" xsi:type="DurationBetween">
                  <operand name="Estimated Due Date" xsi:type="ExpressionRef"/>
                  <operand name="Birth Date" xsi:type="ExpressionRef"/>
               </operand>
            </operand>
            <operand valueType="t:Integer" value="7" xsi:type="Literal"/>
         </expression>
      </def>
   </statements>
</library>