Quality Measure Implementation Guide
2.0.0-ballot - STU 2 Ballot

Quality Measure Implementation Guide - Downloaded Version null See the Directory of published versions

## : EXM Measure

Page standards status: Informative

Raw xml | Download

    <Measure xmlns="http://hl7.org/fhir">
      <id value="EXMLogic-FHIR"/>
      <meta>
        <profile
                 value="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-cvmeasure"/>
        <profile
                 value="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-computablemeasure"/>
        <profile
                 value="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-executablemeasure"/>
        <profile
                 value="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-cqlmeasure"/>
        <profile
                 value="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-elmmeasure"/>
        <profile
                 value="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-computablemeasure"/>
      </meta>
      <language value="en"/>
      <text>
        <status value="extensions"/>
        <div xmlns="http://www.w3.org/1999/xhtml">
      <table class="narrative-table">
        <tbody>
    <tr>

    <th colspan="2" scope="row" class="row-header">Metadata</th>

    </tr>

    <tr>

    <th scope="row" class="row-header">Title</th>

    <td class="content-container">EXM Measure</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Version</th>

    <td class="content-container">2.0.0</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Identifier</th>

    <td class="content-container">EXM</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Identifier</th>

    <td class="content-container">urn:oid:2.16.840.1.113883.4.642.40.61.29.9</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Effective Period</th>

    <td class="content-container">2018-01-01 + 1 year(s)</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Approval Date</th>

    <td class="content-container">2019-02-17</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Last Review Date</th>

    <td class="content-container">2019-02-17</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Experimental</th>

    <td class="content-container">true</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Use Context</th>

    <td class="content-container">
        Clinical Venue

     =
        EC

    </td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Jurisdiction</th>

    <td class="content-container">
        001 from <a href="http://unstats.un.org/unsd/methods/m49/m49.htm">http://unstats.un.org/unsd/methods/m49/m49.htm</a>

    </td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Topic</th>

    <td class="content-container">Health Quality Measure Document
    </td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Steward (Publisher)</th>

    <td class="content-container">HL7 International / Clinical Quality Information</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Developer</th>

    <td class="content-container">Example Measure Content Developer</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Description</th>

    <td class="content-container"><div><p>An example FHIR-based measure</p>
    </div></td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Purpose</th>

    <td class="content-container"><div><p>This measure has been developed to support improvement in clinical care.</p>
    </div></td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Copyright</th>

    <td class="content-container"><div><p>Example Copyright Statement</p>
    </div></td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Disclaimer</th>

    <td class="content-container"><div><p>Example disclaimer</p>
    </div></td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Measure Basis</th>

    <td class="content-container">Encounter</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Measure Scoring</th>

    <td class="content-container">
        Continuous Variable

    </td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Measure Scoring Precision</th>

    <td class="content-container">2</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Improvement Notation</th>

    <td class="content-container">
        Increased score indicates improvement

    </td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Measure Type</th>

    <td class="content-container">
        process from <a href="http://terminology.hl7.org/7.1.0/CodeSystem-measure-type.html">http://terminology.hl7.org/CodeSystem/measure-type</a>

    </td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Risk Adjustment</th>

    <td class="content-container">Risk adjustment for this measure is performed by...</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Rate Aggregation</th>

    <td class="content-container">Rate aggregation for this measure is performed by...</td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Rationale</th>

    <td class="content-container"><div><p>The purpose of this measure is to show how all the elements of a FHIR-based quality measure are represented.</p>
    </div></td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Clinical Recommendation Statement</th>

    <td class="content-container"><div><p>The clinical recommendation statement for this measure is...</p>
    </div></td>

    </tr>

    <tr>

    <th scope="row" class="row-header">Guidance (Usage)</th>

    <td class="content-container">Users of this measure should be aware that this is intentionally simplified to show specific aspects of a measure.</td>

    </tr>

        <tr>

    <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: primary)</th>

    </tr>

    <tr>

    <th scope="row" class="row-header">Stratifier</th>

      <td class="content-container">

          <em>ID</em>: stratifier-1

            <br/>

            <em>Code</em>: <span title="Codes:">Stratifier 1</span>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Stratifier</th>

      <td class="content-container">

          <em>ID</em>: stratifier-2

            <br/>

            <em>Code</em>: <span title="Codes:">Stratifier 2</span>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Stratifier</th>

      <td class="content-container">

          <em>ID</em>: stratifier-3

            <br/>

            <em>Code</em>: <span title="Codes:">Stratifier 3</span>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Stratifier</th>

      <td class="content-container">

          <em>ID</em>: stratifier-4

            <br/>

            <em>Code</em>: <span title="Codes:">Stratifier 4</span>

      </td>
    </tr>

      <tr>

    <th colspan="2" scope="row" class="row-header">Supplemental Data Elements</th>

    </tr>

    <tr>

    <th scope="row" class="row-header">Supplemental Data Element</th>

      <td class="content-container">

          <em>ID</em>: sde-ethnicity

          <br/>

              <em>Usage Code</em>: <span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-data-usage supplemental-data}">Supplemental Data</span>

            <br/>

          <em>Description</em>: No description provided

            <br/>

              <em>Logic Definition</em>: <a href="#exmlogic-sde-ethnicity">SDE Ethnicity</a>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Supplemental Data Element</th>

      <td class="content-container">

          <em>ID</em>: sde-race

          <br/>

              <em>Usage Code</em>: <span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-data-usage supplemental-data}">Supplemental Data</span>

            <br/>

          <em>Description</em>: No description provided

            <br/>

              <em>Logic Definition</em>: <a href="#exmlogic-sde-race">SDE Race</a>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Supplemental Data Element</th>

      <td class="content-container">

          <em>ID</em>: sde-payer

          <br/>

              <em>Usage Code</em>: <span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-data-usage supplemental-data}">Supplemental Data</span>

            <br/>

          <em>Description</em>: No description provided

            <br/>

              <em>Logic Definition</em>: <a href="#exmlogic-sde-payer">SDE Payer</a>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Supplemental Data Element</th>

      <td class="content-container">

          <em>ID</em>: sde-sex

          <br/>

              <em>Usage Code</em>: <span title="Codes:{http://terminology.hl7.org/CodeSystem/measure-data-usage supplemental-data}">Supplemental Data</span>

            <br/>

          <em>Description</em>: No description provided

            <br/>

              <em>Logic Definition</em>: <a href="#exmlogic-sde-sex">SDE Sex</a>

      </td>
    </tr>

    <tr>

    <th colspan="2" scope="row" class="row-header">Measure Logic</th>

    </tr>

    <tr>

    <th scope="row" class="row-header">Primary Library</th>

    <td class="content-container"><a href="Library-EXMLogic.html">Example Logic Library</a></td>

    </tr>

    <tr>
      <th scope="row" class="row-header">Contents</th>
      <td class="content-container">
        <em><a href="#population-criteria">Population Criteria</a></em>
        <br/>
        <em><a href="#definitions">Logic Definitions</a></em>
        <br/>
        <em><a href="#terminology">Terminology</a></em>
        <br/>
        <em><a href="#dependencies">Dependencies</a></em>
        <br/>
        <em><a href="#data-requirements">Data Requirements</a></em>
        <br/>
        <em><a href="#parameters">Parameters</a></em>
        <br/>
      </td>
    </tr>

      <tr>

    <th colspan="2" scope="row" class="row-header"><a name="population-criteria"> </a>Population Criteria</th>

    </tr>

        <tr>

    <th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: primary)</th>

    </tr>

                <tr>
      <th scope="row" rowspan="2" class="row-header">

        Stratifier

      </th>
    </tr>
    <tr>

      <td>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Stratifier 1&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where not (PrincipalDiagnosis(Encounter).code in &quot;Psychiatric/Mental Health Patient&quot;)</code></pre>

          <a href="#exmlogic-stratifier-1"><em>Definition</em></a>

      </td>

    </tr>

                <tr>
      <th scope="row" rowspan="2" class="row-header">

        Stratifier

      </th>
    </tr>
    <tr>

      <td>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Stratifier 2&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where PrincipalDiagnosis(Encounter).code in &quot;Psychiatric/Mental Health Patient&quot;</code></pre>

          <a href="#exmlogic-stratifier-2"><em>Definition</em></a>

      </td>

    </tr>

                <tr>
      <th scope="row" rowspan="2" class="row-header">

        Stratifier

      </th>
    </tr>
    <tr>

      <td>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Stratifier 3&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where PrincipalDiagnosis(Encounter) is null</code></pre>

          <a href="#exmlogic-stratifier-3"><em>Definition</em></a>

      </td>

    </tr>

                <tr>
      <th scope="row" rowspan="2" class="row-header">

        Stratifier

      </th>
    </tr>
    <tr>

      <td>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Stratifier 4&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where PrincipalDiagnosis(Encounter) is null</code></pre>

          <a href="#exmlogic-stratifier-4"><em>Definition</em></a>

      </td>

    </tr>

      <tr>

    <th colspan="2" scope="row" class="row-header"><a name="definitions"> </a>Logic Definitions</th>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-sde-sex"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Sex&quot;:
      case
        when Patient.gender = 'male' then Code { code: 'M', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Male' }
        when Patient.gender = 'female' then Code { code: 'F', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Female' }
        else null
      end</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-inpatient-encounter"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Inpatient Encounter&quot; :
      [&quot;Encounter&quot;] Encounter
        where LengthInDays(Encounter.period) &lt;= 120
          and Encounter.period ends during &quot;Measurement Period&quot;</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-stratifier-3"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Stratifier 3&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where PrincipalDiagnosis(Encounter) is null</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-stratifier-4"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Stratifier 4&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where PrincipalDiagnosis(Encounter) is null</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-sde-payer"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Payer&quot;:
        [Coverage: type in &quot;Payer&quot;] Payer
          return {
            code: Payer.type,
            period: Payer.period
          }</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-initial-population"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Initial Population&quot; :
      &quot;Inpatient Encounter&quot; Encounter</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-sde-ethnicity"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Ethnicity&quot;:
      (flatten (
        Patient.extension Extension
          where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity'
            return Extension.extension
      )) E
        where E.url = 'ombCategory'
          or E.url = 'detailed'
        return E.value as Coding</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-sde-race"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;SDE Race&quot;:
      (flatten (
        Patient.extension Extension
          where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race'
            return Extension.extension
      )) E
        where E.url = 'ombCategory'
          or E.url = 'detailed'
        return E.value as Coding</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-measure-population"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Measure Population&quot; :
      &quot;Initial Population&quot;</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-stratifier-1"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Stratifier 1&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where not (PrincipalDiagnosis(Encounter).code in &quot;Psychiatric/Mental Health Patient&quot;)</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-stratifier-2"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define &quot;Stratifier 2&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where PrincipalDiagnosis(Encounter).code in &quot;Psychiatric/Mental Health Patient&quot;</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-lengthindays"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function &quot;LengthInDays&quot;(Value Interval&lt;DateTime&gt;):
    	difference in days between start of Value and end of Value</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-principaldiagnosis"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function &quot;PrincipalDiagnosis&quot;(Encounter Encounter):
    	(singleton from (Encounter.diagnosis D where D.use ~ ToConcept(&quot;Billing&quot;) and D.rank.value = 1)) PD
    		return singleton from ([Condition: id in &quot;GetId&quot;(PD.condition.reference)])</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-getid"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function &quot;GetId&quot;(uri String):
    	Last(Split(uri, '/'))</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-measure-observation"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function &quot;Measure Observation&quot; (Encounter &quot;Encounter&quot; ) :
      duration in minutes of &quot;Related ED Visit&quot;(Encounter).period</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> EXMLogic</td>

    </tr>
    <tr>

      <td>

          <a name="exmlogic-related-ed-visit"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">//Measure Observation
    define function &quot;Related ED Visit&quot; (Encounter &quot;Encounter&quot; ) :
      Last([&quot;Encounter&quot; : &quot;Emergency Department Visit&quot;] ED
        where ED.status = 'finished'
          and ED.period ends 1 hour or less before start of Encounter.period
        sort by start of period )</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> FHIRHelpers</td>

    </tr>
    <tr>

      <td>

          <a name="fhirhelpers-tostring"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function ToString(value AdministrativeGender): value.value</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> FHIRHelpers</td>

    </tr>
    <tr>

      <td>

          <a name="fhirhelpers-tointerval"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
    @description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)
    value to a CQL DateTime Interval
    @comment: If the start value of the given period is unspecified, the starting
    boundary of the resulting interval will be open (meaning the start of the interval
    is unknown, as opposed to interpreted as the beginning of time).
    */
    define function ToInterval(period FHIR.Period):
        if period is null then
            null
        else
            if period.&quot;start&quot; is null then
                Interval(period.&quot;start&quot;.value, period.&quot;end&quot;.value]
            else
                Interval[period.&quot;start&quot;.value, period.&quot;end&quot;.value]</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> FHIRHelpers</td>

    </tr>
    <tr>

      <td>

          <a name="fhirhelpers-toconcept"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
    @description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
    */
    define function ToConcept(concept FHIR.CodeableConcept):
        if concept is null then
            null
        else
            System.Concept {
                codes: concept.coding C return ToCode(C),
                display: concept.text.value
            }</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> FHIRHelpers</td>

    </tr>
    <tr>

      <td>

          <a name="fhirhelpers-tocode"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
    @description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
    */
    define function ToCode(coding FHIR.Coding):
        if coding is null then
            null
        else
            System.Code {
              code: coding.code.value,
              system: coding.system.value,
              version: coding.version.value,
              display: coding.display.value
            }</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> FHIRHelpers</td>

    </tr>
    <tr>

      <td>

          <a name="fhirhelpers-tostring"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function ToString(value string): value.value</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> FHIRHelpers</td>

    </tr>
    <tr>

      <td>

          <a name="fhirhelpers-tostring"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function ToString(value uri): value.value</code></pre>
      </td>

    </tr>

    <tr>
      <th scope="row" rowspan="2" class="row-header">
        Logic Definition
      </th>

      <td class="content-container"><em>Library Name:</em> FHIRHelpers</td>

    </tr>
    <tr>

      <td>

          <a name="fhirhelpers-tostring"> </a>

        <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function ToString(value EncounterStatus): value.value</code></pre>
      </td>

    </tr>

      <tr>

    <th colspan="2" scope="row" class="row-header"><a name="terminology"> </a>Terminology</th>

    </tr>

    <tr>

    <th scope="row" class="row-header">Code System</th>

      <td class="content-container">

        <em>Description</em>: Code system Diagnosis Role

        <br/>

        <em>Resource</em>: <a href="http://terminology.hl7.org/7.1.0/CodeSystem-diagnosis-role.html">Diagnosis Role</a>
        <br/>
        <em>Canonical URL</em>: <tt>http://terminology.hl7.org/CodeSystem/diagnosis-role</tt>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Value Set</th>

      <td class="content-container">

        <em>Description</em>: Value set Payer

        <br/>

        <em>Resource</em>: <a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.114222.4.11.3591/expansion">Payer Type</a>
        <br/>
        <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591</tt>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Value Set</th>

      <td class="content-container">

        <em>Description</em>: Value set Emergency Department Visit

        <br/>

        <em>Resource</em>: <a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.292/expansion">Emergency Department Visit</a>
        <br/>
        <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292</tt>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Value Set</th>

      <td class="content-container">

        <em>Description</em>: Value set Psychiatric/Mental Health Patient

        <br/>

        <em>Resource</em>: <a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.299/expansion">Psychiatric/Mental Health Diagnosis</a>
        <br/>
        <em>Canonical URL</em>: <tt>http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.299</tt>

      </td>
    </tr>

      <tr>
        <th scope="row" class="row-header">Direct Reference Code</th>
        <td class="content-container">

            <em>Display</em>: Billing
            <br/>

          <em>Code</em>: billing
          <br/>
          <em>System</em>: <tt>http://terminology.hl7.org/CodeSystem/diagnosis-role</tt>
        </td>
      </tr>

      <tr>

    <th colspan="2" scope="row" class="row-header"><a name="dependencies"> </a>Dependencies</th>

    </tr>

    <tr>

    <th scope="row" class="row-header">Dependency</th>

      <td class="content-container">

        <em>Description</em>: FHIR model information

        <br/>

        <em>Resource</em>: <a href="http://hl7.org/fhir/uv/cql/STU2/Library-FHIR-ModelInfo.html">http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1</a>
        <br/>
        <em>Canonical URL</em>: <tt>http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1</tt>

      </td>
    </tr>

    <tr>

    <th scope="row" class="row-header">Dependency</th>

      <td class="content-container">

        <em>Description</em>: Library FHIRHelpers

        <br/>

        <em>Resource</em>: <a href="http://hl7.org/fhir/uv/cql/STU2/Library-FHIRHelpers.html">http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1</a>
        <br/>
        <em>Canonical URL</em>: <tt>http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1</tt>

      </td>
    </tr>

      <tr>

    <th colspan="2" scope="row" class="row-header"><a name="data-requirements"> </a>Data Requirements</th>

    </tr>

    <tr>
      <th scope="row" class="row-header">Data Requirement</th>
      <td class="content-container">
        <em>Type</em>: Patient
        <br/>

        <em>Profile(s)</em>:

        <a href="http://hl7.org/fhir/R4/patient.html">Patient</a>
        <br/>

        <em>Must Support Elements</em>: url, extension, value
        <br/>

      </td>
    </tr>

    <tr>
      <th scope="row" class="row-header">Data Requirement</th>
      <td class="content-container">
        <em>Type</em>: Encounter
        <br/>

        <em>Profile(s)</em>:

        <a href="http://hl7.org/fhir/R4/encounter.html">Encounter</a>
        <br/>

        <em>Must Support Elements</em>: type, status, period, use, rank, rank.value, condition, condition.reference
        <br/>

        <em>Code Filter(s)</em>:
        <br/>

        <span class="tab-one"><em>Path</em>: type</span>
        <br/>

        <span class="tab-one"><em>ValueSet</em>:</span> <a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.292/expansion">Emergency Department Visit</a>
        <br/>

      </td>
    </tr>

    <tr>
      <th scope="row" class="row-header">Data Requirement</th>
      <td class="content-container">
        <em>Type</em>: Encounter
        <br/>

        <em>Profile(s)</em>:

        <a href="http://hl7.org/fhir/R4/encounter.html">Encounter</a>
        <br/>

        <em>Must Support Elements</em>: period, use, rank, rank.value, condition, condition.reference
        <br/>

      </td>
    </tr>

    <tr>
      <th scope="row" class="row-header">Data Requirement</th>
      <td class="content-container">
        <em>Type</em>: Condition
        <br/>

        <em>Profile(s)</em>:

        <a href="http://hl7.org/fhir/R4/condition.html">Condition</a>
        <br/>

        <em>Must Support Elements</em>: id
        <br/>

        <em>Code Filter(s)</em>:
        <br/>

        <span class="tab-one"><em>Path</em>: id</span>
        <br/>

      </td>
    </tr>

    <tr>
      <th scope="row" class="row-header">Data Requirement</th>
      <td class="content-container">
        <em>Type</em>: Coverage
        <br/>

        <em>Profile(s)</em>:

        <a href="http://hl7.org/fhir/R4/coverage.html">Coverage</a>
        <br/>

        <em>Must Support Elements</em>: type, period
        <br/>

        <em>Code Filter(s)</em>:
        <br/>

        <span class="tab-one"><em>Path</em>: type</span>
        <br/>

        <span class="tab-one"><em>ValueSet</em>:</span> <a href="https://vsac.nlm.nih.gov/valueset/2.16.840.1.114222.4.11.3591/expansion">Payer Type</a>
        <br/>

      </td>
    </tr>

      <tr>

    <th colspan="2" scope="row" class="row-header"><a name="parameters"> </a>Parameters</th>

    </tr>

      <tr>

    <th scope="row" class="row-header"/>

      <td class="content-container">
        <table>
          <thead>
            <tr>
              <td><em>Name</em></td>
              <td><em>Use</em></td>
              <td><em>Card.</em></td>
              <td><em>Type</em></td>
              <td><em>Documentation</em></td>
            </tr>
          </thead>
          <tbody>

            <tr>
              <td>Measurement Period</td>
              <td>In</td>
              <td>0..1</td>
              <td>Period</td>
              <td/>
            </tr>

            <tr>
              <td>SDE Sex</td>
              <td>Out</td>
              <td>0..1</td>
              <td>Coding</td>
              <td/>
            </tr>

            <tr>
              <td>Stratifier 3</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Encounter</td>
              <td/>
            </tr>

            <tr>
              <td>Stratifier 4</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Encounter</td>
              <td/>
            </tr>

            <tr>
              <td>SDE Payer</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Resource</td>
              <td/>
            </tr>

            <tr>
              <td>Initial Population</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Encounter</td>
              <td/>
            </tr>

            <tr>
              <td>SDE Ethnicity</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Coding</td>
              <td/>
            </tr>

            <tr>
              <td>SDE Race</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Coding</td>
              <td/>
            </tr>

            <tr>
              <td>Measure Population</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Encounter</td>
              <td/>
            </tr>

            <tr>
              <td>Stratifier 1</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Encounter</td>
              <td/>
            </tr>

            <tr>
              <td>Stratifier 2</td>
              <td>Out</td>
              <td>0..*</td>
              <td>Encounter</td>
              <td/>
            </tr>

          </tbody>
        </table>
      </td>
    </tr>

    <tr>
      <th colspan="2" scope="row" class="row-header">Generated using version 0.5.4 of the sample-content-ig Liquid templates</th>
    </tr>

        </tbody>
      </table>
    </div>
      </text>
      <contained>
        <Library>
          <id value="effective-data-requirements"/>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
            <valueCoding>
              <system
                      value="http://terminology.hl7.org/CodeSystem/diagnosis-role"/>
              <code value="billing"/>
              <display value="Billing"/>
            </valueCoding>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="SDE Sex"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;SDE Sex&quot;:
      case
        when Patient.gender = 'male' then Code { code: 'M', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Male' }
        when Patient.gender = 'female' then Code { code: 'F', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Female' }
        else null
      end"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="0"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="Inpatient Encounter"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;Inpatient Encounter&quot; :
      [&quot;Encounter&quot;] Encounter
        where LengthInDays(Encounter.period) &lt;= 120
          and Encounter.period ends during &quot;Measurement Period&quot;"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="1"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="Stratifier 3"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;Stratifier 3&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where PrincipalDiagnosis(Encounter) is null"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="2"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="Stratifier 4"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;Stratifier 4&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where PrincipalDiagnosis(Encounter) is null"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="3"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="SDE Payer"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;SDE Payer&quot;:
        [Coverage: type in &quot;Payer&quot;] Payer
          return {
            code: Payer.type,
            period: Payer.period
          }"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="4"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="Initial Population"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;Initial Population&quot; :
      &quot;Inpatient Encounter&quot; Encounter"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="5"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="SDE Ethnicity"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;SDE Ethnicity&quot;:
      (flatten (
        Patient.extension Extension
          where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity'
            return Extension.extension
      )) E
        where E.url = 'ombCategory'
          or E.url = 'detailed'
        return E.value as Coding"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="6"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="SDE Race"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;SDE Race&quot;:
      (flatten (
        Patient.extension Extension
          where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race'
            return Extension.extension
      )) E
        where E.url = 'ombCategory'
          or E.url = 'detailed'
        return E.value as Coding"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="7"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="Measure Population"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;Measure Population&quot; :
      &quot;Initial Population&quot;"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="8"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="Stratifier 1"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;Stratifier 1&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where not (PrincipalDiagnosis(Encounter).code in &quot;Psychiatric/Mental Health Patient&quot;)"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="9"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="Stratifier 2"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define &quot;Stratifier 2&quot; :
      &quot;Inpatient Encounter&quot; Encounter
        where PrincipalDiagnosis(Encounter).code in &quot;Psychiatric/Mental Health Patient&quot;"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="10"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="FHIRHelpers"/>
            </extension>
            <extension url="name">
              <valueString value="ToString"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define function ToString(value AdministrativeGender): value.value"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="11"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="LengthInDays"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define function &quot;LengthInDays&quot;(Value Interval&lt;DateTime&gt;):
    	difference in days between start of Value and end of Value"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="12"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="FHIRHelpers"/>
            </extension>
            <extension url="name">
              <valueString value="ToInterval"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="/*
    @description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)
    value to a CQL DateTime Interval
    @comment: If the start value of the given period is unspecified, the starting
    boundary of the resulting interval will be open (meaning the start of the interval
    is unknown, as opposed to interpreted as the beginning of time).
    */
    define function ToInterval(period FHIR.Period):
        if period is null then
            null
        else
            if period.&quot;start&quot; is null then
                Interval(period.&quot;start&quot;.value, period.&quot;end&quot;.value]
            else
                Interval[period.&quot;start&quot;.value, period.&quot;end&quot;.value]"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="13"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="PrincipalDiagnosis"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define function &quot;PrincipalDiagnosis&quot;(Encounter Encounter):
    	(singleton from (Encounter.diagnosis D where D.use ~ ToConcept(&quot;Billing&quot;) and D.rank.value = 1)) PD
    		return singleton from ([Condition: id in &quot;GetId&quot;(PD.condition.reference)])"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="14"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="FHIRHelpers"/>
            </extension>
            <extension url="name">
              <valueString value="ToConcept"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="/*
    @description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
    */
    define function ToConcept(concept FHIR.CodeableConcept):
        if concept is null then
            null
        else
            System.Concept {
                codes: concept.coding C return ToCode(C),
                display: concept.text.value
            }"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="15"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="FHIRHelpers"/>
            </extension>
            <extension url="name">
              <valueString value="ToCode"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="/*
    @description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
    */
    define function ToCode(coding FHIR.Coding):
        if coding is null then
            null
        else
            System.Code {
              code: coding.code.value,
              system: coding.system.value,
              version: coding.version.value,
              display: coding.display.value
            }"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="16"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="GetId"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define function &quot;GetId&quot;(uri String):
    	Last(Split(uri, '/'))"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="17"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="FHIRHelpers"/>
            </extension>
            <extension url="name">
              <valueString value="ToString"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define function ToString(value string): value.value"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="18"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="FHIRHelpers"/>
            </extension>
            <extension url="name">
              <valueString value="ToString"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define function ToString(value uri): value.value"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="19"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="Measure Observation"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define function &quot;Measure Observation&quot; (Encounter &quot;Encounter&quot; ) :
      duration in minutes of &quot;Related ED Visit&quot;(Encounter).period"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="20"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="EXMLogic"/>
            </extension>
            <extension url="name">
              <valueString value="Related ED Visit"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="//Measure Observation
    define function &quot;Related ED Visit&quot; (Encounter &quot;Encounter&quot; ) :
      Last([&quot;Encounter&quot; : &quot;Emergency Department Visit&quot;] ED
        where ED.status = 'finished'
          and ED.period ends 1 hour or less before start of Encounter.period
        sort by start of period )"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="21"/>
            </extension>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
            <extension url="libraryName">
              <valueString value="FHIRHelpers"/>
            </extension>
            <extension url="name">
              <valueString value="ToString"/>
            </extension>
            <extension url="statement">
              <valueString
                           value="define function ToString(value EncounterStatus): value.value"/>
            </extension>
            <extension url="displaySequence">
              <valueInteger value="22"/>
            </extension>
          </extension>
          <name value="EffectiveDataRequirements"/>
          <status value="active"/>
          <type>
            <coding>
              <system value="http://terminology.hl7.org/CodeSystem/library-type"/>
              <code value="module-definition"/>
            </coding>
          </type>
          <relatedArtifact>
            <type value="depends-on"/>
            <display value="FHIR model information"/>
            <resource
                      value="http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1"/>
          </relatedArtifact>
          <relatedArtifact>
            <type value="depends-on"/>
            <display value="Library FHIRHelpers"/>
            <resource
                      value="http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1"/>
          </relatedArtifact>
          <relatedArtifact>
            <type value="depends-on"/>
            <display value="Code system Diagnosis Role"/>
            <resource
                      value="http://terminology.hl7.org/CodeSystem/diagnosis-role"/>
          </relatedArtifact>
          <relatedArtifact>
            <type value="depends-on"/>
            <display value="Value set Payer"/>
            <resource
                      value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"/>
          </relatedArtifact>
          <relatedArtifact>
            <type value="depends-on"/>
            <display value="Value set Emergency Department Visit"/>
            <resource
                      value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"/>
          </relatedArtifact>
          <relatedArtifact>
            <type value="depends-on"/>
            <display value="Value set Psychiatric/Mental Health Patient"/>
            <resource
                      value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.299"/>
          </relatedArtifact>
          <parameter>
            <name value="Measurement Period"/>
            <use value="in"/>
            <min value="0"/>
            <max value="1"/>
            <type value="Period"/>
          </parameter>
          <parameter>
            <name value="SDE Sex"/>
            <use value="out"/>
            <min value="0"/>
            <max value="1"/>
            <type value="Coding"/>
          </parameter>
          <parameter>
            <name value="Stratifier 3"/>
            <use value="out"/>
            <min value="0"/>
            <max value="*"/>
            <type value="Encounter"/>
          </parameter>
          <parameter>
            <name value="Stratifier 4"/>
            <use value="out"/>
            <min value="0"/>
            <max value="*"/>
            <type value="Encounter"/>
          </parameter>
          <parameter>
            <name value="SDE Payer"/>
            <use value="out"/>
            <min value="0"/>
            <max value="*"/>
            <type value="Resource"/>
          </parameter>
          <parameter>
            <name value="Initial Population"/>
            <use value="out"/>
            <min value="0"/>
            <max value="*"/>
            <type value="Encounter"/>
          </parameter>
          <parameter>
            <name value="SDE Ethnicity"/>
            <use value="out"/>
            <min value="0"/>
            <max value="*"/>
            <type value="Coding"/>
          </parameter>
          <parameter>
            <name value="SDE Race"/>
            <use value="out"/>
            <min value="0"/>
            <max value="*"/>
            <type value="Coding"/>
          </parameter>
          <parameter>
            <name value="Measure Population"/>
            <use value="out"/>
            <min value="0"/>
            <max value="*"/>
            <type value="Encounter"/>
          </parameter>
          <parameter>
            <name value="Stratifier 1"/>
            <use value="out"/>
            <min value="0"/>
            <max value="*"/>
            <type value="Encounter"/>
          </parameter>
          <parameter>
            <name value="Stratifier 2"/>
            <use value="out"/>
            <min value="0"/>
            <max value="*"/>
            <type value="Encounter"/>
          </parameter>
          <dataRequirement>
            <type value="Patient"/>
            <profile value="http://hl7.org/fhir/StructureDefinition/Patient"/>
            <mustSupport value="url"/>
            <mustSupport value="extension"/>
            <mustSupport value="value"/>
          </dataRequirement>
          <dataRequirement>
            <type value="Encounter"/>
            <profile value="http://hl7.org/fhir/StructureDefinition/Encounter"/>
            <mustSupport value="type"/>
            <mustSupport value="status"/>
            <mustSupport value="period"/>
            <mustSupport value="use"/>
            <mustSupport value="rank"/>
            <mustSupport value="rank.value"/>
            <mustSupport value="condition"/>
            <mustSupport value="condition.reference"/>
            <codeFilter>
              <path value="type"/>
              <valueSet
                        value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"/>
            </codeFilter>
          </dataRequirement>
          <dataRequirement>
            <type value="Encounter"/>
            <profile value="http://hl7.org/fhir/StructureDefinition/Encounter"/>
            <mustSupport value="period"/>
            <mustSupport value="use"/>
            <mustSupport value="rank"/>
            <mustSupport value="rank.value"/>
            <mustSupport value="condition"/>
            <mustSupport value="condition.reference"/>
          </dataRequirement>
          <dataRequirement>
            <type value="Condition"/>
            <profile value="http://hl7.org/fhir/StructureDefinition/Condition"/>
            <mustSupport value="id"/>
            <codeFilter>
              <path value="id"/>
            </codeFilter>
          </dataRequirement>
          <dataRequirement>
            <type value="Coverage"/>
            <profile value="http://hl7.org/fhir/StructureDefinition/Coverage"/>
            <mustSupport value="type"/>
            <mustSupport value="period"/>
            <codeFilter>
              <path value="type"/>
              <valueSet
                        value="http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"/>
            </codeFilter>
          </dataRequirement>
        </Library>
      </contained>
      <extension
                 url="http://hl7.org/fhir/StructureDefinition/cqf-artifactComment">
        <extension url="type">
          <valueCode value="documentation"/>
        </extension>
        <extension url="text">
          <valueMarkdown value="This illustrates an example comment"/>
        </extension>
      </extension>
      <extension
                 url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-populationBasis">
        <valueCode value="Encounter"/>
      </extension>
      <extension
                 url="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-softwaresystem">
        <valueReference>🔗
          <reference value="Device/software-system-example"/>
        </valueReference>
      </extension>
      <extension
                 url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-scoringPrecision">
        <valuePositiveInt value="2"/>
      </extension>
      <extension
                 url="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements">
        <valueCanonical value="#effective-data-requirements"/>
      </extension>
      <url value="http://hl7.org/fhir/uv/cqm/Measure/EXMLogic-FHIR"/>
      <identifier>
        <system value="http://example.org/fhir/cqi/ecqm/Measure/Identifier/exm"/>
        <value value="EXM"/>
      </identifier>
      <identifier>
        <system value="urn:ietf:rfc:3986"/>
        <value value="urn:oid:2.16.840.1.113883.4.642.40.61.29.9"/>
      </identifier>
      <version value="2.0.0"/>
      <name value="MeasureEXM"/>
      <title value="EXM Measure"/>
      <status value="active"/>
      <experimental value="true"/>
      <date value="2025-08-13"/>
      <publisher value="HL7 International / Clinical Quality Information"/>
      <contact>
        <telecom>
          <system value="url"/>
          <value value="http://www.hl7.org/Special/committees/cqi"/>
        </telecom>
      </contact>
      <description value="An example FHIR-based measure"/>
      <useContext>
        <code>
          <system
                  value="http://terminology.hl7.org/CodeSystem/usage-context-type"/>
          <code value="venue"/>
          <display value="Clinical Venue"/>
        </code>
        <valueCodeableConcept>
          <coding>
            <system
                    value="http://hl7.org/fhir/uv/cqm/CodeSystem/intended-venue-codes"/>
            <code value="ec"/>
            <display value="EC"/>
          </coding>
        </valueCodeableConcept>
      </useContext>
      <jurisdiction>
        <coding>
          <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
          <code value="001"/>
        </coding>
      </jurisdiction>
      <purpose
               value="This measure has been developed to support improvement in clinical care."/>
      <usage
             value="Users of this measure should be aware that this is intentionally simplified to show specific aspects of a measure."/>
      <copyright value="Example Copyright Statement"/>
      <approvalDate value="2019-02-17"/>
      <lastReviewDate value="2019-02-17"/>
      <effectivePeriod>
        <extension
                   url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-effectivePeriodAnchor">
          <valueDateTime value="2018-01-01"/>
        </extension>
        <extension
                   url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-effectivePeriodDuration">
          <valueDuration>
            <value value="1"/>
            <system value="http://unitsofmeasure.org"/>
            <code value="a"/>
          </valueDuration>
        </extension>
        <start value="2018-01-01"/>
        <end value="2018-12-31"/>
      </effectivePeriod>
      <topic>
        <coding>
          <system value="http://loinc.org"/>
          <code value="57024-2"/>
        </coding>
        <text value="Health Quality Measure Document"/>
      </topic>
      <author>
        <name value="Example Measure Content Developer"/>
      </author>
      <library value="http://hl7.org/fhir/uv/cqm/Library/EXMLogic"/>
      <disclaimer value="Example disclaimer"/>
      <scoring>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/measure-scoring"/>
          <code value="continuous-variable"/>
          <display value="Continuous Variable"/>
        </coding>
      </scoring>
      <type>
        <coding>
          <system value="http://terminology.hl7.org/CodeSystem/measure-type"/>
          <code value="process"/>
        </coding>
      </type>
      <riskAdjustment
                      value="Risk adjustment for this measure is performed by..."/>
      <rateAggregation
                       value="Rate aggregation for this measure is performed by..."/>
      <rationale
                 value="The purpose of this measure is to show how all the elements of a FHIR-based quality measure are represented."/>
      <clinicalRecommendationStatement
                                       value="The clinical recommendation statement for this measure is..."/>
      <improvementNotation>
        <coding>
          <system
                  value="http://terminology.hl7.org/CodeSystem/measure-improvement-notation"/>
          <code value="increase"/>
          <display value="Increased score indicates improvement"/>
        </coding>
      </improvementNotation>
      <guidance
                value="Additional guidance provided to help communicate the intent of the measure"/>
      <group id="group-1">
        <extension
                   url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.linkId">
          <valueString value="primary"/>
        </extension>
        <code>
          <coding>
            <system value="http://example.org/group"/>
            <code value="group"/>
            <display value="group-1"/>
          </coding>
        </code>
        <population id="initial-population-1">
          <extension
                     url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
            <valueString value="primary-exmlogic-initial-population"/>
          </extension>
          <code>
            <coding>
              <system
                      value="http://terminology.hl7.org/CodeSystem/measure-population"/>
              <code value="initial-population"/>
              <display value="Initial Population"/>
            </coding>
          </code>
          <criteria>
            <language value="text/cql-identifier"/>
            <expression value="Initial Population"/>
          </criteria>
        </population>
        <population id="measure-population">
          <extension
                     url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
            <valueString value="primary-exmlogic-measure-population"/>
          </extension>
          <code>
            <coding>
              <system
                      value="http://terminology.hl7.org/CodeSystem/measure-population"/>
              <code value="measure-population"/>
              <display value="Measure Population"/>
            </coding>
          </code>
          <criteria>
            <language value="text/cql-identifier"/>
            <expression value="Measure Population"/>
          </criteria>
        </population>
        <population id="measure-observation">
          <extension
                     url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
            <valueString value="primary-exmlogic-measure-observation"/>
          </extension>
          <extension
                     url="http://hl7.org/fhir/StructureDefinition/cqf-criteriaReference">
            <valueString value="measure-population"/>
          </extension>
          <extension
                     url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-aggregateMethod">
            <valueCode value="median"/>
          </extension>
          <code>
            <coding>
              <system
                      value="http://terminology.hl7.org/CodeSystem/measure-population"/>
              <code value="measure-observation"/>
              <display value="Measure Observation"/>
            </coding>
          </code>
          <criteria>
            <language value="text/cql-identifier"/>
            <expression value="Measure Observation"/>
          </criteria>
        </population>
        <stratifier id="stratifier-1">
          <extension
                     url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.stratifier.linkId">
            <valueString value="primary-exmlogic-stratification-1"/>
          </extension>
          <extension
                     url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-appliesTo">
            <valueCodeableConcept>
              <coding>
                <system
                        value="http://terminology.hl7.org/CodeSystem/measure-population"/>
                <code value="initial-population"/>
                <display value="Initial Population"/>
              </coding>
              <text value="initial-population"/>
            </valueCodeableConcept>
          </extension>
          <code>
            <text value="Stratifier 1"/>
          </code>
          <criteria>
            <language value="text/cql-identifier"/>
            <expression value="Stratifier 1"/>
          </criteria>
        </stratifier>
        <stratifier id="stratifier-2">
          <extension
                     url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.stratifier.linkId">
            <valueString value="primary-exmlogic-stratification-2"/>
          </extension>
          <extension
                     url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-appliesTo">
            <valueCodeableConcept>
              <coding>
                <system
                        value="http://terminology.hl7.org/CodeSystem/measure-population"/>
                <code value="initial-population"/>
                <display value="Initial Population"/>
              </coding>
              <text value="initial-population"/>
            </valueCodeableConcept>
          </extension>
          <code>
            <text value="Stratifier 2"/>
          </code>
          <criteria>
            <language value="text/cql-identifier"/>
            <expression value="Stratifier 2"/>
          </criteria>
        </stratifier>
        <stratifier id="stratifier-3">
          <extension
                     url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.stratifier.linkId">
            <valueString value="primary-exmlogic-stratification-3"/>
          </extension>
          <extension
                     url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-appliesTo">
            <valueCodeableConcept>
              <coding>
                <system
                        value="http://terminology.hl7.org/CodeSystem/measure-population"/>
                <code value="initial-population"/>
                <display value="Initial Population"/>
              </coding>
              <text value="initial-population"/>
            </valueCodeableConcept>
          </extension>
          <code>
            <text value="Stratifier 3"/>
          </code>
          <criteria>
            <language value="text/cql-identifier"/>
            <expression value="Stratifier 3"/>
          </criteria>
        </stratifier>
        <stratifier id="stratifier-4">
          <extension
                     url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.stratifier.linkId">
            <valueString value="primary-exmlogic-stratification-4"/>
          </extension>
          <extension
                     url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-appliesTo">
            <valueCodeableConcept>
              <coding>
                <system
                        value="http://terminology.hl7.org/CodeSystem/measure-population"/>
                <code value="initial-population"/>
                <display value="Initial Population"/>
              </coding>
              <text value="initial-population"/>
            </valueCodeableConcept>
          </extension>
          <code>
            <text value="Stratifier 4"/>
          </code>
          <criteria>
            <language value="text/cql-identifier"/>
            <expression value="Stratifier 4"/>
          </criteria>
        </stratifier>
      </group>
      <supplementalData id="sde-ethnicity">
        <extension
                   url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.supplementalData.linkId">
          <valueString value="primary-sde-ethnicity"/>
        </extension>
        <usage>
          <coding>
            <system
                    value="http://terminology.hl7.org/CodeSystem/measure-data-usage"/>
            <code value="supplemental-data"/>
          </coding>
        </usage>
        <criteria>
          <language value="text/cql-identifier"/>
          <expression value="SDE Ethnicity"/>
        </criteria>
      </supplementalData>
      <supplementalData id="sde-race">
        <extension
                   url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.supplementalData.linkId">
          <valueString value="primary-sde-race"/>
        </extension>
        <usage>
          <coding>
            <system
                    value="http://terminology.hl7.org/CodeSystem/measure-data-usage"/>
            <code value="supplemental-data"/>
          </coding>
        </usage>
        <criteria>
          <language value="text/cql-identifier"/>
          <expression value="SDE Race"/>
        </criteria>
      </supplementalData>
      <supplementalData id="sde-payer">
        <extension
                   url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.supplementalData.linkId">
          <valueString value="primary-sde-payer"/>
        </extension>
        <usage>
          <coding>
            <system
                    value="http://terminology.hl7.org/CodeSystem/measure-data-usage"/>
            <code value="supplemental-data"/>
          </coding>
        </usage>
        <criteria>
          <language value="text/cql-identifier"/>
          <expression value="SDE Payer"/>
        </criteria>
      </supplementalData>
      <supplementalData id="sde-sex">
        <extension
                   url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.supplementalData.linkId">
          <valueString value="primary-sde-sex"/>
        </extension>
        <usage>
          <coding>
            <system
                    value="http://terminology.hl7.org/CodeSystem/measure-data-usage"/>
            <code value="supplemental-data"/>
          </coding>
        </usage>
        <criteria>
          <language value="text/cql-identifier"/>
          <expression value="SDE Sex"/>
        </criteria>
      </supplementalData>
    </Measure>