Quality Measure Implementation Guide, published by HL7 International / Clinical Quality Information. This guide is not an authorized publication; it is the continuous build for version 2.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/fhir-cqm/ and changes regularly. See the Directory of published versions
| Page standards status: Informative |
<Measure xmlns="http://hl7.org/fhir">
<id value="CAUTIRateExample"/>
<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">Example Catheter-Associated Urinary Tract Infection Rate</td>
</tr>
<tr>
<th scope="row" class="row-header">Version</th>
<td class="content-container">2.0.0-ballot</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.26</td>
</tr>
<tr>
<th scope="row" class="row-header">Status</th>
<td class="content-container">Draft</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">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">Description</th>
<td class="content-container"><div><p>Example measure illustrating an approach to representing the Catheter-Associated Urinary Tract Infection (CAUTI) Rate per 1000 indwelling urinary catheter (IUC) days. See https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/blob/master/Source/Cooking%20With%20CQL/93/CAUTI.md for more detailed discussion of the example.</p>
</div></td>
</tr>
<tr>
<th colspan="2" scope="row" class="row-header">Measure Group (Rate) (ID: group-1)</th>
</tr>
<tr>
<th scope="row" class="row-header">Basis</th>
<td class="content-container">Location</td>
</tr>
<tr>
<th scope="row" class="row-header">Scoring</th>
<td class="content-container">
Ratio
</td>
</tr>
<tr>
<th scope="row" class="row-header">Scoring Unit</th>
<td class="content-container">per 1000 catheter days
</td>
</tr>
<tr>
<th scope="row" class="row-header">Initial Population</th>
<td class="content-container">
<em>ID</em>: denominator-initial-population
<br/>
<em>Description</em>: No description provided
<em>Criteria</em>: <a href="#group-1-denominator-initial-population">Denominator Initial Population</a>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Initial Population</th>
<td class="content-container">
<em>ID</em>: numerator-initial-population
<br/>
<em>Description</em>: No description provided
<em>Criteria</em>: <a href="#group-1-numerator-initial-population">Numerator Initial Population</a>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Denominator</th>
<td class="content-container">
<em>ID</em>: denominator
<br/>
<em>Description</em>: No description provided
<em>Criteria</em>: <a href="#group-1-denominator">Denominator</a>
<br/><em>Input Population</em>: denominator-initial-population
</td>
</tr>
<tr>
<th scope="row" class="row-header">Numerator</th>
<td class="content-container">
<em>ID</em>: numerator
<br/>
<em>Description</em>: No description provided
<em>Criteria</em>: <a href="#group-1-numerator">Numerator</a>
<br/><em>Input Population</em>: numerator-initial-population
</td>
</tr>
<tr>
<th scope="row" class="row-header">Measure Observation</th>
<td class="content-container">
<em>ID</em>: denominator-observation
<br/>
<em>Description</em>: No description provided
<em>Criteria</em>: <a href="#group-1-denominator-observation">Denominator Observation</a>
<br/><em>Input Population</em>: denominator
<em>AggregateMethod</em>: sum
</td>
</tr>
<tr>
<th scope="row" class="row-header">Measure Observation</th>
<td class="content-container">
<em>ID</em>: numerator-observation
<br/>
<em>Description</em>: No description provided
<em>Criteria</em>: <a href="#group-1-numerator-observation">Numerator Observation</a>
<br/><em>Input Population</em>: numerator
<em>AggregateMethod</em>: sum
</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-CAUTIRate.html">CAUTI Rate</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: group-1)</th>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Initial Population
</th>
</tr>
<tr>
<td>
<a name="group-1-denominator-initial-population"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Denominator Initial Population":
[Location] L
with Elements."Encounter During Measurement Period" E
such that E.location.location.references(L)</code></pre>
<a href="#cautirate-denominator-initial-population"><em>Definition</em></a>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Initial Population
</th>
</tr>
<tr>
<td>
<a name="group-1-numerator-initial-population"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Numerator Initial Population":
exists (Elements."Encounter During Measurement Period")</code></pre>
<a href="#cautirate-numerator-initial-population"><em>Definition</em></a>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Denominator
</th>
</tr>
<tr>
<td>
<a name="group-1-denominator"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Denominator":
"Denominator Initial Population"</code></pre>
<a href="#cautirate-denominator"><em>Definition</em></a>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Numerator
</th>
</tr>
<tr>
<td>
<a name="group-1-numerator"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Numerator":
"Numerator Initial Population"</code></pre>
<a href="#cautirate-numerator"><em>Definition</em></a>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Measure Observation
</th>
</tr>
<tr>
<td>
<a name="group-1-denominator-observation"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Denominator Observation"():
Sum(
Elements."Catheter Usage During Measurement Period" Usage
return all duration in days of Usage
)</code></pre>
<a href="#cautirate-denominator-observation"><em>Definition</em></a>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Measure Observation
</th>
</tr>
<tr>
<td>
<a name="group-1-numerator-observation"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Numerator Observation"():
Count(Elements."Catheter-Associated UTI")</code></pre>
<a href="#cautirate-numerator-observation"><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> CAUTIElements</td>
</tr>
<tr>
<td>
<a name="cautielements-encounter-during-measurement-period"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Encounter During Measurement Period":
[Encounter] E
where E.period during "Measurement 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> CAUTIElements</td>
</tr>
<tr>
<td>
<a name="cautielements-catheter-inserted-procedure"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Catheter Inserted Procedure":
[Procedure: "Catheter Inserted"] P
where P.status = 'completed'</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> CAUTIElements</td>
</tr>
<tr>
<td>
<a name="cautielements-catheter-removed-procedure"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Catheter Removed Procedure":
[Procedure: "Catheter Removed"] P
where P.status = 'completed'</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> CAUTIElements</td>
</tr>
<tr>
<td>
<a name="cautielements-catheter-usage"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Catheter Usage":
"Catheter Inserted Procedure" I
let catheterRemoved:
First(
"Catheter Removed Procedure" R
where R.performed.toInterval() starts after I.performed.toInterval()
sort by start of performed.toInterval()
)
return Interval[
date from start of I.performed.toInterval(),
date from start of catheterRemoved.performed.toInterval()
]</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> CAUTIElements</td>
</tr>
<tr>
<td>
<a name="cautielements-catheter-usage-during-measurement-period"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Catheter Usage During Measurement Period":
collapse (
"Catheter Usage" Usage
where Usage overlaps "Measurement Period"
return Interval[
Max({start of Usage, start of "Measurement Period"}),
Min({end of Usage, end of "Measurement 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> CAUTIElements</td>
</tr>
<tr>
<td>
<a name="cautielements-urine-culture-with-bacterium"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Urine Culture With Bacterium":
[Observation: "Urine Culture"] O
where O.status = 'final'
and exists (
O.component C
where C.code in "Bacterium Presence"
and C.value >= 10000 '[CFU]/mL'
)</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> CAUTIElements</td>
</tr>
<tr>
<td>
<a name="cautielements-uti"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "UTI":
"Urine Culture With Bacterium" U
let
DOE: date from start of U.effective.toInterval(),
IWP: Interval[DOE - 3 days, DOE + 3 days]
where start of U.effective.toInterval() during "Measurement Period"
return {
urineCultureResult: U,
dateOfEvent: DOE,
infectionWindowPeriod: IWP
}</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> CAUTIElements</td>
</tr>
<tr>
<td>
<a name="cautielements-catheter-associated-uti"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Catheter-Associated UTI":
"UTI" U
where exists (
"Catheter Usage" Usage
where start of Usage before U.dateOfEvent
and end of Usage on or after U.dateOfEvent - 1 day
and duration in days of Usage > 2
)</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> FHIRCommon</td>
</tr>
<tr>
<td>
<a name="fhircommon-references"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Returns true if any of the given references are to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of any of the given references.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(references List<FHIR.Reference>, resource FHIR.Resource):
exists (references R where R.references(resource))</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> FHIRCommon</td>
</tr>
<tr>
<td>
<a name="fhircommon-references"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Returns true if the given reference is to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference FHIR.Reference, resource FHIR.Resource):
resource.id = Last(Split(reference.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> FHIRCommon</td>
</tr>
<tr>
<td>
<a name="fhircommon-tointerval"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in FHIR, allowing this function to be used across any resource.
The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a dateTime, the result a DateTime Interval beginning and ending on that dateTime.
If the input is a Period, the result is a DateTime Interval.
If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing.
If the input is an instant, the result is a DateTime Interval beginning and ending on that instant.
If the input is a string, an error is raised indicating a single interval cannot be computed from a string.
If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age,
and ending immediately prior to when the patient was the given Age plus one year.
If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given
by the low end of the Range, and ending immediately prior to when the patient was the Age given by the
high end of the Range plus one year.
NOTE: Due to the
complexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used
with a Timing or String.
*/
define fluent function toInterval(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>):
case
when choice is FHIR.dateTime then
Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]
when choice is FHIR.Period then
FHIRHelpers.ToInterval(choice as FHIR.Period)
when choice is FHIR.instant then
Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]
when choice is FHIR.Age then
Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),
FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)
when choice is FHIR.Range then
Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),
FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)
when choice is FHIR.Timing then
Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported')
when choice is FHIR.string then
Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported')
else
null as Interval<DateTime>
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> CAUTIRate</td>
</tr>
<tr>
<td>
<a name="cautirate-denominator-initial-population"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Denominator Initial Population":
[Location] L
with Elements."Encounter During Measurement Period" E
such that E.location.location.references(L)</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> CAUTIRate</td>
</tr>
<tr>
<td>
<a name="cautirate-numerator-initial-population"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Numerator Initial Population":
exists (Elements."Encounter During Measurement 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> CAUTIRate</td>
</tr>
<tr>
<td>
<a name="cautirate-numerator"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Numerator":
"Numerator Initial Population"</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> CAUTIRate</td>
</tr>
<tr>
<td>
<a name="cautirate-denominator"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define "Denominator":
"Denominator Initial Population"</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> CAUTIRate</td>
</tr>
<tr>
<td>
<a name="cautirate-denominator-observation"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Denominator Observation"():
Sum(
Elements."Catheter Usage During Measurement Period" Usage
return all duration in days of Usage
)</code></pre>
</td>
</tr>
<tr>
<th scope="row" rowspan="2" class="row-header">
Logic Definition
</th>
<td class="content-container"><em>Library Name:</em> CAUTIRate</td>
</tr>
<tr>
<td>
<a name="cautirate-numerator-observation"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function "Numerator Observation"():
Count(Elements."Catheter-Associated UTI")</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."start" is null then
Interval(period."start".value, period."end".value]
else
Interval[period."start".value, period."end".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 ProcedureStatus): 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-todatetime"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function ToDateTime(value dateTime): 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-todatetime"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function ToDateTime(value instant): 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-todate"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">define function ToDate(value date): 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-toquantity"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity)
value to a CQL Quantity
@comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity
has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`)
an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used.
@seealso: ToCalendarUnit
*/
define function ToQuantity(quantity FHIR.Quantity):
case
when quantity is null then null
when quantity.value is null then null
when quantity.comparator is not null then
Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.')
when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'
or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then
System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }
else
Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')
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> FHIRHelpers</td>
</tr>
<tr>
<td>
<a name="fhirhelpers-tocalendarunit"> </a>
<pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">/*
@description: Converts a UCUM definite duration unit to a CQL calendar duration
unit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities)
topic of the CQL specification.
@comment: Note that for durations above days (or weeks), the conversion is understood to be approximate
*/
define function ToCalendarUnit(unit System.String):
case unit
when 'ms' then 'millisecond'
when 's' then 'second'
when 'min' then 'minute'
when 'h' then 'hour'
when 'd' then 'day'
when 'wk' then 'week'
when 'mo' then 'month'
when 'a' then 'year'
else unit
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> 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 ObservationStatus): 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-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 colspan="2" scope="row" class="row-header"><a name="terminology"> </a>Terminology</th>
</tr>
<tr>
<th scope="row" class="row-header">Value Set</th>
<td class="content-container">
<em>Description</em>: Value set Catheter Inserted
<br/>
<em>Resource</em>: <code>http://example.org/ValueSet/catheter-inserted</code>
<br/>
<em>Canonical URL</em>: <tt>http://example.org/ValueSet/catheter-inserted</tt>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Value Set</th>
<td class="content-container">
<em>Description</em>: Value set Catheter Removed
<br/>
<em>Resource</em>: <code>http://example.org/ValueSet/catheter-removed</code>
<br/>
<em>Canonical URL</em>: <tt>http://example.org/ValueSet/catheter-removed</tt>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Value Set</th>
<td class="content-container">
<em>Description</em>: Value set Urine Culture
<br/>
<em>Resource</em>: <code>http://example.org/ValueSet/urine-culture</code>
<br/>
<em>Canonical URL</em>: <tt>http://example.org/ValueSet/urine-culture</tt>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Value Set</th>
<td class="content-container">
<em>Description</em>: Value set Bacterium Presence
<br/>
<em>Resource</em>: <code>http://example.org/ValueSet/bacterium-presence</code>
<br/>
<em>Canonical URL</em>: <tt>http://example.org/ValueSet/bacterium-presence</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 Elements
<br/>
<em>Resource</em>: <a href="Library-CAUTIElements.html">CAUTI Elements</a>
<br/>
<em>Canonical URL</em>: <tt>http://hl7.org/fhir/uv/cqm/Library/CAUTIElements</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 scope="row" class="row-header">Dependency</th>
<td class="content-container">
<em>Description</em>: Library FHIRCommon
<br/>
<em>Resource</em>: <a href="http://hl7.org/fhir/uv/cql/STU2/Library-FHIRCommon.html">http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0</a>
<br/>
<em>Canonical URL</em>: <tt>http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0</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>: Encounter
<br/>
<em>Profile(s)</em>:
<a href="http://hl7.org/fhir/R4/encounter.html">Encounter</a>
<br/>
<em>Must Support Elements</em>: period, location
<br/>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Data Requirement</th>
<td class="content-container">
<em>Type</em>: Location
<br/>
<em>Profile(s)</em>:
<a href="http://hl7.org/fhir/R4/location.html">Location</a>
<br/>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Data Requirement</th>
<td class="content-container">
<em>Type</em>: Procedure
<br/>
<em>Profile(s)</em>:
<a href="http://hl7.org/fhir/R4/procedure.html">Procedure</a>
<br/>
<em>Must Support Elements</em>: code, status, performed
<br/>
<em>Code Filter(s)</em>:
<br/>
<span class="tab-one"><em>Path</em>: code</span>
<br/>
<span class="tab-one"><em>ValueSet</em>:</span> <code>http://example.org/ValueSet/catheter-removed</code>
<br/>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Data Requirement</th>
<td class="content-container">
<em>Type</em>: Procedure
<br/>
<em>Profile(s)</em>:
<a href="http://hl7.org/fhir/R4/procedure.html">Procedure</a>
<br/>
<em>Must Support Elements</em>: code, status, performed
<br/>
<em>Code Filter(s)</em>:
<br/>
<span class="tab-one"><em>Path</em>: code</span>
<br/>
<span class="tab-one"><em>ValueSet</em>:</span> <code>http://example.org/ValueSet/catheter-inserted</code>
<br/>
</td>
</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/>
</td>
</tr>
<tr>
<th scope="row" class="row-header">Data Requirement</th>
<td class="content-container">
<em>Type</em>: Observation
<br/>
<em>Profile(s)</em>:
<a href="http://hl7.org/fhir/R4/observation.html">Observation</a>
<br/>
<em>Must Support Elements</em>: code, status, component, effective
<br/>
<em>Code Filter(s)</em>:
<br/>
<span class="tab-one"><em>Path</em>: code</span>
<br/>
<span class="tab-one"><em>ValueSet</em>:</span> <code>http://example.org/ValueSet/urine-culture</code>
<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>Denominator Initial Population</td>
<td>Out</td>
<td>0..*</td>
<td>Location</td>
<td/>
</tr>
<tr>
<td>Numerator</td>
<td>Out</td>
<td>0..1</td>
<td>boolean</td>
<td/>
</tr>
<tr>
<td>Denominator</td>
<td>Out</td>
<td>0..*</td>
<td>Location</td>
<td/>
</tr>
<tr>
<td>Numerator Initial Population</td>
<td>Out</td>
<td>0..1</td>
<td>boolean</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-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIElements"/>
</extension>
<extension url="name">
<valueString value="Encounter During Measurement Period"/>
</extension>
<extension url="statement">
<valueString
value="define "Encounter During Measurement Period":
[Encounter] E
where E.period during "Measurement Period""/>
</extension>
<extension url="displaySequence">
<valueInteger value="0"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIRate"/>
</extension>
<extension url="name">
<valueString value="Denominator Initial Population"/>
</extension>
<extension url="statement">
<valueString
value="define "Denominator Initial Population":
[Location] L
with Elements."Encounter During Measurement Period" E
such that E.location.location.references(L)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="1"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIRate"/>
</extension>
<extension url="name">
<valueString value="Numerator Initial Population"/>
</extension>
<extension url="statement">
<valueString
value="define "Numerator Initial Population":
exists (Elements."Encounter During Measurement Period")"/>
</extension>
<extension url="displaySequence">
<valueInteger value="2"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIRate"/>
</extension>
<extension url="name">
<valueString value="Numerator"/>
</extension>
<extension url="statement">
<valueString
value="define "Numerator":
"Numerator Initial Population""/>
</extension>
<extension url="displaySequence">
<valueInteger value="3"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIElements"/>
</extension>
<extension url="name">
<valueString value="Catheter Inserted Procedure"/>
</extension>
<extension url="statement">
<valueString
value="define "Catheter Inserted Procedure":
[Procedure: "Catheter Inserted"] P
where P.status = 'completed'"/>
</extension>
<extension url="displaySequence">
<valueInteger value="4"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIElements"/>
</extension>
<extension url="name">
<valueString value="Catheter Removed Procedure"/>
</extension>
<extension url="statement">
<valueString
value="define "Catheter Removed Procedure":
[Procedure: "Catheter Removed"] P
where P.status = 'completed'"/>
</extension>
<extension url="displaySequence">
<valueInteger value="5"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIElements"/>
</extension>
<extension url="name">
<valueString value="Catheter Usage"/>
</extension>
<extension url="statement">
<valueString
value="define "Catheter Usage":
"Catheter Inserted Procedure" I
let catheterRemoved:
First(
"Catheter Removed Procedure" R
where R.performed.toInterval() starts after I.performed.toInterval()
sort by start of performed.toInterval()
)
return Interval[
date from start of I.performed.toInterval(),
date from start of catheterRemoved.performed.toInterval()
]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="6"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIElements"/>
</extension>
<extension url="name">
<valueString value="Catheter Usage During Measurement Period"/>
</extension>
<extension url="statement">
<valueString
value="define "Catheter Usage During Measurement Period":
collapse (
"Catheter Usage" Usage
where Usage overlaps "Measurement Period"
return Interval[
Max({start of Usage, start of "Measurement Period"}),
Min({end of Usage, end of "Measurement Period"})
]
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="7"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIRate"/>
</extension>
<extension url="name">
<valueString value="Denominator"/>
</extension>
<extension url="statement">
<valueString
value="define "Denominator":
"Denominator Initial Population""/>
</extension>
<extension url="displaySequence">
<valueInteger value="8"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIElements"/>
</extension>
<extension url="name">
<valueString value="Urine Culture With Bacterium"/>
</extension>
<extension url="statement">
<valueString
value="define "Urine Culture With Bacterium":
[Observation: "Urine Culture"] O
where O.status = 'final'
and exists (
O.component C
where C.code in "Bacterium Presence"
and C.value >= 10000 '[CFU]/mL'
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="9"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIElements"/>
</extension>
<extension url="name">
<valueString value="UTI"/>
</extension>
<extension url="statement">
<valueString
value="define "UTI":
"Urine Culture With Bacterium" U
let
DOE: date from start of U.effective.toInterval(),
IWP: Interval[DOE - 3 days, DOE + 3 days]
where start of U.effective.toInterval() during "Measurement Period"
return {
urineCultureResult: U,
dateOfEvent: DOE,
infectionWindowPeriod: IWP
}"/>
</extension>
<extension url="displaySequence">
<valueInteger value="10"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIElements"/>
</extension>
<extension url="name">
<valueString value="Catheter-Associated UTI"/>
</extension>
<extension url="statement">
<valueString
value="define "Catheter-Associated UTI":
"UTI" U
where exists (
"Catheter Usage" Usage
where start of Usage before U.dateOfEvent
and end of Usage on or after U.dateOfEvent - 1 day
and duration in days of Usage > 2
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="11"/>
</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."start" is null then
Interval(period."start".value, period."end".value]
else
Interval[period."start".value, period."end".value]"/>
</extension>
<extension url="displaySequence">
<valueInteger value="12"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="FHIRCommon"/>
</extension>
<extension url="name">
<valueString value="references"/>
</extension>
<extension url="statement">
<valueString
value="/*
@description: Returns true if any of the given references are to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of any of the given references.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(references List<FHIR.Reference>, resource FHIR.Resource):
exists (references R where R.references(resource))"/>
</extension>
<extension url="displaySequence">
<valueInteger value="13"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="FHIRCommon"/>
</extension>
<extension url="name">
<valueString value="references"/>
</extension>
<extension url="statement">
<valueString
value="/*
@description: Returns true if the given reference is to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference FHIR.Reference, resource FHIR.Resource):
resource.id = Last(Split(reference.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="ToString"/>
</extension>
<extension url="statement">
<valueString
value="define function ToString(value string): value.value"/>
</extension>
<extension url="displaySequence">
<valueInteger value="15"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIRate"/>
</extension>
<extension url="name">
<valueString value="Denominator Observation"/>
</extension>
<extension url="statement">
<valueString
value="define function "Denominator Observation"():
Sum(
Elements."Catheter Usage During Measurement Period" Usage
return all duration in days of Usage
)"/>
</extension>
<extension url="displaySequence">
<valueInteger value="16"/>
</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 ProcedureStatus): value.value"/>
</extension>
<extension url="displaySequence">
<valueInteger value="17"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="FHIRCommon"/>
</extension>
<extension url="name">
<valueString value="toInterval"/>
</extension>
<extension url="statement">
<valueString
value="/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in FHIR, allowing this function to be used across any resource.
The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a dateTime, the result a DateTime Interval beginning and ending on that dateTime.
If the input is a Period, the result is a DateTime Interval.
If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing.
If the input is an instant, the result is a DateTime Interval beginning and ending on that instant.
If the input is a string, an error is raised indicating a single interval cannot be computed from a string.
If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age,
and ending immediately prior to when the patient was the given Age plus one year.
If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given
by the low end of the Range, and ending immediately prior to when the patient was the Age given by the
high end of the Range plus one year.
NOTE: Due to the
complexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used
with a Timing or String.
*/
define fluent function toInterval(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>):
case
when choice is FHIR.dateTime then
Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]
when choice is FHIR.Period then
FHIRHelpers.ToInterval(choice as FHIR.Period)
when choice is FHIR.instant then
Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]
when choice is FHIR.Age then
Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),
FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)
when choice is FHIR.Range then
Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),
FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)
when choice is FHIR.Timing then
Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported')
when choice is FHIR.string then
Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported')
else
null as Interval<DateTime>
end"/>
</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="ToDateTime"/>
</extension>
<extension url="statement">
<valueString
value="define function ToDateTime(value dateTime): 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="FHIRHelpers"/>
</extension>
<extension url="name">
<valueString value="ToDateTime"/>
</extension>
<extension url="statement">
<valueString
value="define function ToDateTime(value instant): value.value"/>
</extension>
<extension url="displaySequence">
<valueInteger value="20"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="FHIRHelpers"/>
</extension>
<extension url="name">
<valueString value="ToDate"/>
</extension>
<extension url="statement">
<valueString
value="define function ToDate(value date): value.value"/>
</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="ToQuantity"/>
</extension>
<extension url="statement">
<valueString
value="/*
@description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity)
value to a CQL Quantity
@comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity
has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`)
an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used.
@seealso: ToCalendarUnit
*/
define function ToQuantity(quantity FHIR.Quantity):
case
when quantity is null then null
when quantity.value is null then null
when quantity.comparator is not null then
Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.')
when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'
or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then
System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }
else
Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')
end"/>
</extension>
<extension url="displaySequence">
<valueInteger value="22"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="FHIRHelpers"/>
</extension>
<extension url="name">
<valueString value="ToCalendarUnit"/>
</extension>
<extension url="statement">
<valueString
value="/*
@description: Converts a UCUM definite duration unit to a CQL calendar duration
unit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities)
topic of the CQL specification.
@comment: Note that for durations above days (or weeks), the conversion is understood to be approximate
*/
define function ToCalendarUnit(unit System.String):
case unit
when 'ms' then 'millisecond'
when 's' then 'second'
when 'min' then 'minute'
when 'h' then 'hour'
when 'd' then 'day'
when 'wk' then 'week'
when 'mo' then 'month'
when 'a' then 'year'
else unit
end"/>
</extension>
<extension url="displaySequence">
<valueInteger value="23"/>
</extension>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition">
<extension url="libraryName">
<valueString value="CAUTIRate"/>
</extension>
<extension url="name">
<valueString value="Numerator Observation"/>
</extension>
<extension url="statement">
<valueString
value="define function "Numerator Observation"():
Count(Elements."Catheter-Associated UTI")"/>
</extension>
<extension url="displaySequence">
<valueInteger value="24"/>
</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 ObservationStatus): value.value"/>
</extension>
<extension url="displaySequence">
<valueInteger value="25"/>
</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="26"/>
</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="27"/>
</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 Elements"/>
<resource value="http://hl7.org/fhir/uv/cqm/Library/CAUTIElements"/>
</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="Library FHIRCommon"/>
<resource
value="http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Catheter Inserted"/>
<resource value="http://example.org/ValueSet/catheter-inserted"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Catheter Removed"/>
<resource value="http://example.org/ValueSet/catheter-removed"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Urine Culture"/>
<resource value="http://example.org/ValueSet/urine-culture"/>
</relatedArtifact>
<relatedArtifact>
<type value="depends-on"/>
<display value="Value set Bacterium Presence"/>
<resource value="http://example.org/ValueSet/bacterium-presence"/>
</relatedArtifact>
<parameter>
<name value="Measurement Period"/>
<use value="in"/>
<min value="0"/>
<max value="1"/>
<type value="Period"/>
</parameter>
<parameter>
<name value="Denominator Initial Population"/>
<use value="out"/>
<min value="0"/>
<max value="*"/>
<type value="Location"/>
</parameter>
<parameter>
<name value="Numerator"/>
<use value="out"/>
<min value="0"/>
<max value="1"/>
<type value="boolean"/>
</parameter>
<parameter>
<name value="Denominator"/>
<use value="out"/>
<min value="0"/>
<max value="*"/>
<type value="Location"/>
</parameter>
<parameter>
<name value="Numerator Initial Population"/>
<use value="out"/>
<min value="0"/>
<max value="1"/>
<type value="boolean"/>
</parameter>
<dataRequirement>
<type value="Encounter"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Encounter"/>
<mustSupport value="period"/>
<mustSupport value="location"/>
</dataRequirement>
<dataRequirement>
<type value="Location"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Location"/>
</dataRequirement>
<dataRequirement>
<type value="Procedure"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Procedure"/>
<mustSupport value="code"/>
<mustSupport value="status"/>
<mustSupport value="performed"/>
<codeFilter>
<path value="code"/>
<valueSet value="http://example.org/ValueSet/catheter-removed"/>
</codeFilter>
</dataRequirement>
<dataRequirement>
<type value="Procedure"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Procedure"/>
<mustSupport value="code"/>
<mustSupport value="status"/>
<mustSupport value="performed"/>
<codeFilter>
<path value="code"/>
<valueSet value="http://example.org/ValueSet/catheter-inserted"/>
</codeFilter>
</dataRequirement>
<dataRequirement>
<type value="Patient"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Patient"/>
</dataRequirement>
<dataRequirement>
<type value="Observation"/>
<profile value="http://hl7.org/fhir/StructureDefinition/Observation"/>
<mustSupport value="code"/>
<mustSupport value="status"/>
<mustSupport value="component"/>
<mustSupport value="effective"/>
<codeFilter>
<path value="code"/>
<valueSet value="http://example.org/ValueSet/urine-culture"/>
</codeFilter>
</dataRequirement>
</Library>
</contained>
<extension
url="http://hl7.org/fhir/StructureDefinition/structuredefinition-wg">
<valueCode value="cqi"/>
</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/CAUTIRateExample"/>
<identifier>
<system value="urn:ietf:rfc:3986"/>
<value value="urn:oid:2.16.840.1.113883.4.642.40.61.29.26"/>
</identifier>
<version value="2.0.0-ballot"/>
<name value="CAUTIRateExample"/>
<title value="Example Catheter-Associated Urinary Tract Infection Rate"/>
<status value="draft"/>
<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="Example measure illustrating an approach to representing the Catheter-Associated Urinary Tract Infection (CAUTI) Rate per 1000 indwelling urinary catheter (IUC) days. See https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/blob/master/Source/Cooking%20With%20CQL/93/CAUTI.md for more detailed discussion of the example."/>
<jurisdiction>
<coding>
<system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
<code value="001"/>
</coding>
</jurisdiction>
<topic>
<coding>
<system value="http://loinc.org"/>
<code value="57024-2"/>
<display value="Health Quality Measure Document"/>
</coding>
</topic>
<library value="http://hl7.org/fhir/uv/cqm/Library/CAUTIRate"/>
<group id="group-1">
<extension
url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.linkId">
<valueString value="group-1"/>
</extension>
<extension
url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-populationBasis">
<valueCode value="Location"/>
</extension>
<extension
url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-scoring">
<valueCodeableConcept>
<coding>
<system
value="http://terminology.hl7.org/CodeSystem/measure-scoring"/>
<code value="ratio"/>
<display value="Ratio"/>
</coding>
</valueCodeableConcept>
</extension>
<extension
url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-scoringUnit">
<valueCodeableConcept>
<coding>
<system value="http://unitsofmeasure.org"/>
<code value="/1000.d"/>
<display value="/1000.d"/>
</coding>
<text value="per 1000 catheter days"/>
</valueCodeableConcept>
</extension>
<population id="denominator-initial-population">
<extension
url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
<valueString value="denominator-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="Denominator Initial Population"/>
</criteria>
</population>
<population id="denominator">
<extension
url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
<valueString value="denominator"/>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-criteriaReference">
<valueString value="denominator-initial-population"/>
</extension>
<code>
<coding>
<system
value="http://terminology.hl7.org/CodeSystem/measure-population"/>
<code value="denominator"/>
<display value="Denominator"/>
</coding>
</code>
<criteria>
<language value="text/cql-identifier"/>
<expression value="Denominator"/>
</criteria>
</population>
<population id="denominator-observation">
<extension
url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
<valueString value="denominator-observation"/>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-criteriaReference">
<valueString value="denominator"/>
</extension>
<extension
url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-aggregateMethod">
<valueCode value="sum"/>
</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="Denominator Observation"/>
</criteria>
</population>
<population id="numerator-initial-population">
<extension
url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
<valueString value="numerator-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="Numerator Initial Population"/>
</criteria>
</population>
<population id="numerator">
<extension
url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
<valueString value="numerator"/>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-criteriaReference">
<valueString value="numerator-initial-population"/>
</extension>
<code>
<coding>
<system
value="http://terminology.hl7.org/CodeSystem/measure-population"/>
<code value="numerator"/>
<display value="Numerator"/>
</coding>
</code>
<criteria>
<language value="text/cql-identifier"/>
<expression value="Numerator"/>
</criteria>
</population>
<population id="numerator-observation">
<extension
url="http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId">
<valueString value="numerator-observation"/>
</extension>
<extension
url="http://hl7.org/fhir/StructureDefinition/cqf-criteriaReference">
<valueString value="numerator"/>
</extension>
<extension
url="http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-aggregateMethod">
<valueCode value="sum"/>
</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="Numerator Observation"/>
</criteria>
</population>
</group>
</Measure>