Common CQL Artifacts for FHIR (US-Based)
1.0.0-ballot - STU 1 Ballot United States of America flag

Common CQL Artifacts for FHIR (US-Based), published by HL7 International / Clinical Decision Support. This guide is not an authorized publication; it is the continuous build for version 1.0.0-ballot built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/us-cql-ig/ and changes regularly. See the Directory of published versions

: Expression Library for the Example Patient And Coverage Questionnaire - XML Representation

Page standards status: Informative Maturity Level: 3

Raw xml | Download


<Library xmlns="http://hl7.org/fhir">
  <id value="ExamplePatientAndCoverageInitialExpressions"/>
  <text>
    <status value="extensions"/>
    <div xmlns="http://www.w3.org/1999/xhtml">
<div>
    <table class="grid dict">
        
        
        <tr>
            <th scope="row"><b>Title: </b></th>
            <td style="padding-left: 4px;">Expression Library for the Example Patient And Coverage Questionnaire</td>
        </tr>
        

        
        
        <tr>
            <th scope="row"><b>Id: </b></th>
            <td style="padding-left: 4px;">ExamplePatientAndCoverageInitialExpressions</td>
        </tr>
        

        
        
        <tr>
            <th scope="row"><b>Version: </b></th>
            <td style="padding-left: 4px;">1.0.0-ballot</td>
        </tr>
        

        
        <tr>
            <th scope="row"><b>Url: </b></th>
            <td style="padding-left: 4px;"><a href="Library-ExamplePatientAndCoverageInitialExpressions.html">Expression Library for the Example Patient And Coverage Questionnaire</a></td>
        </tr>
        

        

        

        
        <tr>
            <th scope="row"><b>Status: </b></th>
            <td style="padding-left: 4px;">draft</td>
        </tr>
        

        
        <tr>
            <th scope="row"><b>Experimental: </b></th>
            <td style="padding-left: 4px;">true</td>
        </tr>
        

        
        <tr>
            <th scope="row"><b>Type: </b></th>
            <td style="padding-left: 4px;">
                
                    
                        
                        <p style="margin-bottom: 5px;">
                            <b>system: </b> <span><a href="http://terminology.hl7.org/6.5.0/CodeSystem-library-type.html">http://terminology.hl7.org/CodeSystem/library-type</a></span>
                        </p>
                        
                        
                        <p style="margin-bottom: 5px;">
                            <b>code: </b> <span>logic-library</span>
                        </p>
                        
                        
                    
                
                
            </td>
        </tr>
        

        

        
        <tr>
            <th scope="row"><b>Date: </b></th>
            <td style="padding-left: 4px;">2025-09-10 20:00:05+0000</td>
        </tr>
        

        
        <tr>
            <th scope="row"><b>Publisher: </b></th>
            <td style="padding-left: 4px;">HL7 International / Clinical Decision Support</td>
        </tr>
        

        
        <tr>
            <th scope="row"><b>Description: </b></th>
            <td style="padding-left: 4px;"><div><p>This library defines initial expressions for use in populating answers to questions in the Example Patient And Coverage questionnaire.</p>
</div></td>
        </tr>
        

        

        

        

        
        <tr>
            <th scope="row"><b>Jurisdiction: </b></th>
            <td style="padding-left: 4px;">US</td>
        </tr>
        

        

        

        

        

        

        

        

        

        

        
        
        <tr>
          <td colspan="2">
            <table>
              <tr><th><a id="cql-content"><b>Content: </b></a> text/cql</th></tr>
              <tr><td><pre><code class="language-cql">library ExamplePatientAndCoverageInitialExpressions

using USCore version '7.0.0'
using FHIR version '4.0.1'

include hl7.fhir.uv.cql.FHIRHelpers version '4.0.1'
include USCoreCommon called UC
include USCoreElements called UCE

codesystem &quot;Identifier Type&quot;: 'http://terminology.hl7.org/CodeSystem/v2-0203'

code &quot;Member Number&quot;: 'MB' from &quot;Identifier Type&quot;
code &quot;Subscriber Number&quot;: 'SN' from &quot;Identifier Type&quot;

parameter &quot;Coverage&quot; FHIR.Coverage
parameter &quot;ServiceRequest&quot; FHIR.ServiceRequest

context Patient

define &quot;Retrieve Service Request test parameter&quot;:
  // The VSCode extension doesn't support parameters
  // When executing CQL with the VSCode extension retrieve the resource specific for the test case
  //   the list of resource ids match the resources from the test case folders
  singleton from ([FHIR.ServiceRequest] SR where SR.id in { 
    'minimal-service-request-example'
  })

define &quot;Service Request&quot;:
  Coalesce(
    ServiceRequest,
    &quot;Retrieve Service Request test parameter&quot;
  )

define &quot;Retrieve Coverage test parameter&quot;:
  // The VSCode extension doesn't support parameters
  // When executing CQL with the VSCode extension retrieve the resource specific for the test case
  //   the list of resource ids match the resources from the test case folders
  singleton from ([FHIR.Coverage] CV where CV.id in { 
    'minimal-coverage-example'
  })

define &quot;Member Coverage&quot;:
  Coalesce(
    Coverage,
    &quot;Retrieve Coverage test parameter&quot;
  )

define &quot;Patient Name&quot;:
  UCE.&quot;Name - First Middle(s) Last&quot;

define &quot;Date of Birth&quot;:
  Patient.birthDate

define &quot;Birth Sex&quot;:
  Patient.birthsex

define &quot;Medical Record Number&quot;:
  UCE.&quot;Medical Record Number&quot;

define &quot;Phone Number&quot;:
  UC.Mobile(Patient.telecom).value

define &quot;Email Address&quot;:
  UC.Email(Patient.telecom).value

define &quot;Address&quot;:
  (singleton from Patient.address).line

define &quot;City&quot;:
  Patient.address.city

define &quot;State&quot;:
  Patient.address.state

define &quot;Postal Code&quot;:
  Patient.address.postalCode

// Coverage
// define &quot;Coverage&quot;:
//   First(clinical C where C is FHIR.Coverage)

// TODO: is there a need to check for coverage period and order? 
//       also, do we need to check that the payor organization is the same as the source of the prior auth form?
define &quot;Member ID&quot;:
  UCE.MemberID(&quot;Member Coverage&quot;).value

// TODO: is there a need to check for coverage period and order?
//       also do we need to check that the payor organization is the same as the source of the prior auth form?
define &quot;Policy Number&quot;:
  UCE.PolicyNumber(&quot;Member Coverage&quot;).value

define &quot;Requesting Provider&quot;:
  UCE.RequestingProvider(&quot;Service Request&quot;)

define &quot;Requesting Provider Name&quot;:
  &quot;Requesting Provider&quot;.name.family

define &quot;Requesting Provider Phone&quot;:
  UC.Work(&quot;Requesting Provider&quot;.telecom).value

define &quot;Requesting Provider Address&quot;:
  (singleton from &quot;Requesting Provider&quot;.address).line

define &quot;Requesting Provider NPI&quot;:
  &quot;Requesting Provider&quot;.identifier I 
  where I.system = 'http://hl7.org/fhir/sid/us-npi'
  return I.value

define &quot;Requesting Provider Fax&quot;:
  &quot;Requesting Provider&quot;.telecom T
  where T.system = 'fax'
  return T.value

define &quot;Servicing Provider&quot;:
  UCE.ServicingProvider(&quot;Service Request&quot;)

define &quot;Servicing Provider Name&quot;:
  &quot;Servicing Provider&quot;.name

define &quot;Servicing Provider Phone&quot;:
  UC.Work(&quot;Servicing Provider&quot;.telecom).value

define &quot;Servicing Provider Address&quot;:
  (singleton from &quot;Servicing Provider&quot;.address).text

define &quot;Servicing Provider NPI&quot;:
  &quot;Servicing Provider&quot;.identifier I 
  where I.system = 'http://hl7.org/fhir/sid/us-npi'
  return I.value

define &quot;Servicing Provider Fax&quot;:
  &quot;Servicing Provider&quot;.telecom T
  where T.system = 'fax'
  return T.value</code></pre></td></tr>
            </table>
          </td>
        </tr>
        
        
        
        
        
        <tr>
          <td colspan="2">
            <table>
              <tr><th><b>Content: </b> application/elm+xml</th></tr>
              <tr><td><pre><code/></pre></td></tr>
            </table>
          </td>
        </tr>
        
        
    </table>
</div>
</div>
  </text>
  <extension
             url="http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm">
    <valueInteger value="3"/>
  </extension>
  <extension
             url="http://hl7.org/fhir/StructureDefinition/structuredefinition-wg">
    <valueCode value="cds"/>
  </extension>
  <extension
             url="http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status">
    <valueCode value="informative"/>
  </extension>
  <url
       value="http://hl7.org/fhir/us/cql/Library/ExamplePatientAndCoverageInitialExpressions"/>
  <version value="1.0.0-ballot"/>
  <name value="ExamplePatientAndCoverageInitialExpressions"/>
  <title
         value="Expression Library for the Example Patient And Coverage Questionnaire"/>
  <status value="draft"/>
  <experimental value="true"/>
  <type>
    <coding>
      <system value="http://terminology.hl7.org/CodeSystem/library-type"/>
      <code value="logic-library"/>
    </coding>
  </type>
  <date value="2025-09-10T20:00:05+00:00"/>
  <publisher value="HL7 International / Clinical Decision Support"/>
  <contact>
    <telecom>
      <system value="url"/>
      <value value="http://www.hl7.org/Special/committees/dss"/>
    </telecom>
  </contact>
  <description
               value="This library defines initial expressions for use in populating answers to questions in the Example Patient And Coverage questionnaire."/>
  <jurisdiction>
    <coding>
      <system value="urn:iso:std:iso:3166"/>
      <code value="US"/>
      <display value="United States of America"/>
    </coding>
  </jurisdiction>
  <content>
    <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S5TZXJ2aWNpbmdQcm92aWRlcigiU2VydmljZSBSZXF1ZXN0IikKCmRlZmluZSAiU2VydmljaW5nIFByb3ZpZGVyIE5hbWUiOgogICJTZXJ2aWNpbmcgUHJvdmlkZXIiLm5hbWUKCmRlZmluZSAiU2VydmljaW5nIFByb3ZpZGVyIFBob25lIjoKICBVQy5Xb3JrKCJTZXJ2aWNpbmcgUHJvdmlkZXIiLnRlbGVjb20pLnZhbHVlCgpkZWZpbmUgIlNlcnZpY2luZyBQcm92aWRlciBBZGRyZXNzIjoKICAoc2luZ2xldG9uIGZyb20gIlNlcnZpY2luZyBQcm92aWRlciIuYWRkcmVzcykudGV4dAoKZGVmaW5lICJTZXJ2aWNpbmcgUHJvdmlkZXIgTlBJIjoKICAiU2VydmljaW5nIFByb3ZpZGVyIi5pZGVudGlmaWVyIEkgCiAgd2hlcmUgSS5zeXN0ZW0gPSAnaHR0cDovL2hsNy5vcmcvZmhpci9zaWQvdXMtbnBpJwogIHJldHVybiBJLnZhbHVlCgpkZWZpbmUgIlNlcnZpY2luZyBQcm92aWRlciBGYXgiOgogICJTZXJ2aWNpbmcgUHJvdmlkZXIiLnRlbGVjb20gVAogIHdoZXJlIFQuc3lzdGVtID0gJ2ZheCcKICByZXR1cm4gVC52YWx1ZQ=="/>
  </content>
  <content>
    <contentType value="application/elm+xml"/>
  </content>
</Library>