Draft dQM CMS Content Implementation Guide
2025.1.0 - CI Build

Draft dQM CMS Content Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2025.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/dqm-content-cms-2025/ and changes regularly. See the Directory of published versions

Measure: HIV Annual Retention in CareFHIR

Official URL: https://madie.cms.gov/Measure/CMS1157FHIRHIVRetention Version: 1.0.000
Active as of 2026-01-16 Responsible: Health Resources & Services Administration Computable Name: CMS1157FHIRHIVRetention
Other Identifiers: Short Name: CMS1157FHIR (use: usual, ), UUID:03878bb8-1209-4f3f-91f6-52b655092251 (use: official, ), UUID:36e79353-69dd-4ca6-8d94-49fca9c67ca2 (use: official, ), Publisher: 1157FHIR (use: official, )

Copyright/Legal: This measure was developed by the Health Resources and Services Administration of the U.S. Department for Health and Human Services. It is in the public domain.

Citation of HRSA as the source of the original measure is appreciated. Any modified versions may not be represented as approved, endorsed, or authorized by HRSA or HHS. 42 U.S.C. Section 1320b-10. Users of modified versions should clearly explain how they deviate from HRSA’s original measure.

Limited proprietary coding is contained in the Measure specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets.

CPT(R) contained in the Measure specifications is copyright 2004-2024 American Medical Association. LOINC(R) is copyright 2004-2024 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. ICD-10 is copyright 2024 World Health Organization. All Rights Reserved.

Due to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM].

Percentage of patients, regardless of age, with a diagnosis of Human Immunodeficiency Virus (HIV) during the first 240 days of the measurement period or before the measurement period who had at least two eligible encounters or at least one eligible encounter and one HIV viral load test that were at least 90 days apart within the measurement period

Metadata
Title HIV Annual Retention in CareFHIR
Version 1.0.000
Short Name CMS1157FHIR
GUID (Version Independent) urn:uuid:03878bb8-1209-4f3f-91f6-52b655092251
GUID (Version Specific) urn:uuid:36e79353-69dd-4ca6-8d94-49fca9c67ca2
CMS Identifier 1157FHIR
Effective Period 2026-01-01 through 2026-12-31
Steward (Publisher) Health Resources & Services Administration
Developer Health Resources & Services Administration
Description

Percentage of patients, regardless of age, with a diagnosis of Human Immunodeficiency Virus (HIV) during the first 240 days of the measurement period or before the measurement period who had at least two eligible encounters or at least one eligible encounter and one HIV viral load test that were at least 90 days apart within the measurement period

Copyright

This measure was developed by the Health Resources and Services Administration of the U.S. Department for Health and Human Services. It is in the public domain.

Citation of HRSA as the source of the original measure is appreciated. Any modified versions may not be represented as approved, endorsed, or authorized by HRSA or HHS. 42 U.S.C. Section 1320b-10. Users of modified versions should clearly explain how they deviate from HRSA's original measure.

Limited proprietary coding is contained in the Measure specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets.

CPT(R) contained in the Measure specifications is copyright 2004-2024 American Medical Association. LOINC(R) is copyright 2004-2024 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2024 International Health Terminology Standards Development Organisation. ICD-10 is copyright 2024 World Health Organization. All Rights Reserved.

Due to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM].

Disclaimer

These performance measures are not clinical guidelines and do not establish a standard of medical care, and have not been tested for all potential applications.

THE MEASURES AND SPECIFICATIONS ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.

Due to technical limitations, registered trademarks are indicated by (R) or [R] and unregistered trademarks are indicated by (TM) or [TM].

Rationale

The HIV "continuum of care" is the process of HIV testing, linkage to HIV care, initiation of antiretroviral therapy (ART), adherence to treatment, retention in care, and virologic suppression (Gardner et al 2011). Poor retention in care is associated with lower rates of ART use (Giordano et al 2003), delayed viral suppression (Crawford et al 2014), and increased risk of mortality (Giordano et al., 2007; Mugavero et al., 2009). This measure will help providers direct their attention and quality improvement efforts towards improving retention in care.

Clinical Recommendation Statement

"Retention in care should be routinely monitored. There are various ways to measure retention, including measures based on attended visits over a defined period of time (constancy measures) and measures based on missed visits. Both approaches are valid and independently predict survival. Missed visits and a prolonged time since the last visit are relatively easy to measure and should trigger efforts to retain or re-engage a person in care. Constancy measures (e.g., at least two visits that are at least 90 days apart over 1 year or at least one visit every 6 months over the last 2 years) can be used as clinic quality assurance measures" (Panel on Antiretroviral Guidelines for Adults and Adolescents, 2022, p. L-4).

"Poor retention in HIV care is associated with greater risk of death. Poor retention is more common in people who use substances, have serious mental health problems, have unmet socioeconomic needs (e.g., housing, food, transportation), lack financial resources or health insurance, have schedules that complicate adherence, have been recently incarcerated, or face stigma. At the provider and health system level, low trust in providers and a poor patient-provider relationship have been associated with lower retention, as has lower satisfaction with the clinic experience. Availability of appointments and timeliness of appointments (i.e., long delay from the request for an appointment to the appointment's date) and scheduling convenience are also factors" (Panel on Antiretroviral Guidelines for Adults and Adolescents, 2022, p. L-3).

"Recommendation 2: Systematic monitoring of retention in HIV care is recommended for all patients (II A): Retention in care is associated with improved individual health outcomes, including HIV biomarker and clinical variables, and may reduce community-level viral burden, with implications for secondary prevention. Although monitoring retention is routinely recommended, specific details, such as retention measures to be used and desired visit frequency, vary among jurisdictions and programs and should be in harmony with national and international guidelines. Many retention measures (for example, visit adherence, gaps in care, and visits per interval of time) and data sources (for example, surveillance, medical records, and administrative databases) have been used and may be applied in accordance with local resources and standards of care. As with monitoring of linkage, integration of data sources may enhance monitoring of retention" (Thompson et al., 2012, p. 4).

Citation

Crawford, T. N., Sanderson, W. T., & Thornton, A. (2014). Impact of Poor Retention in HIV Medical Care on Time to Viral Load Suppression. Journal of the International Association of Providers of AIDS Care (JIAPAC), 13(3), 242--249. https://doi.org/10.1177/2325957413491431.

Citation

Gardner, E. M., McLees, M. P., Steiner, J. F., Del Rio, C., & Burman, W. J. (2011). The spectrum of engagement in HIV care and its relevance to test-and-treat strategies for prevention of HIV infection. Clinical Infectious Diseases: An Official Publication of the Infectious Diseases Society of America, 52(6), 793--800. https://doi.org/10.1093/cid/ciq243.

Citation

Giordano, T. P., Gifford, A. L., White, A. C., Suarez-Almazor, M. E., Rabeneck, L., Hartman, C., Backus, L. I., Mole, L. A., & Morgan, R. O. (2007). Retention in care: A challenge to survival with HIV infection. Clinical Infectious Diseases: An Official Publication of the Infectious Diseases Society of America, 44(11), 1493-1499. https://doi.org/10.1086/516778.

Citation

Giordano, T. P., White, A. C., Sajja, P., Graviss, E. A., Arduino, R. C., Adu-Oppong, A., Lahart, C. J., & Visnegarwala, F. (2003). Factors associated with the use of highly active antiretroviral therapy in patients newly entering care in an urban clinic. Journal of Acquired Immune Deficiency Syndromes (JAIDS), 32(4), 399-405. https://doi.org/10.1097/00126334-200304010-00009

Citation

Mugavero, M. J., Lin, H.-Y., Willig, J. H., Westfall, A. O., Ulett, K. B., Routman, J. S., Abroms, S., Raper, J. L., Saag, M. S., & Allison, J. J. (2009). Missed visits and mortality among patients establishing initial outpatient HIV treatment. Clinical Infectious Diseases: An Official Publication of the Infectious Diseases Society of America, 48(2), 248--256. https://doi.org/10.1086/595705

Citation

Panel on Antiretroviral Guidelines for Adults and Adolescents. "Guidelines for the Use of Antiretroviral Agents in Adults and Adolescents with HIV." Washington, DC: U.S. Department of Health and Human Services, 2022. Available at https://clinicalinfo.hiv.gov/sites/default/files/guidelines/documents/adult-adolescent-arv/guidelines-adult-adolescent-arv.pdf Updated September 21, 2022. Accessed December 15, 2022.

Citation

Thompson, M. A., Mugavero, M. J., Amico, K. R., Cargill, V. A., Chang, L. W., Gross, R., Orrell, C., Altice, F. L., Bangsberg, D. R., Bartlett, J. G., Beckwith, C. G., Dowshen, N., Gordon, C. M., Horn, T., Kumar, P., Scott, J. D., Stirratt, M. J., Remien, R. H., Simoni, J. M., & Nachega, J. B. (2012). Guidelines for improving entry into and retention in care and antiretroviral adherence for persons with HIV: evidence-based recommendations from an International Association of Physicians in AIDS Care panel. Annals of internal medicine, 156(11), 817-294. https://doi.org/10.7326/0003-4819-156-11-201206050-00419

Definition Month: To maintain consistency from year to year, this measure defines one month as equal to 30 days, three months as equal to 90 days and eight months as equal to 240 days
Guidance (Usage) A patient would be included in the measure numerator if they have either two eligible encounters or one eligible encounter and one viral load test at least 90 days apart from each other. The encounter or encounters that cause a patient to be included in the numerator do not need to include the encounter that caused the patient to be included in the denominator. Only patients with an eligible encounter in the first eight months are included in this measure to allow for sufficient time to complete a second eligible encounter or viral load laboratory within the 12-month measurement period and at least 90 days after the initial encounter. This eCQM is a patient-based measure. This measure is to be submitted a minimum of once per measurement period for patients with a diagnosis of HIV during the first eight months of the measurement period. This FHIR-based measure has been derived from the QDM-based measure CMS1157v2. Please refer to the HL7 QI-Core Implementation Guide (https://hl7.org/fhir/us/qicore/STU6/) for more information on QI-Core and mapping recommendations from QDM to QI-Core STU 6 (https://hl7.org/fhir/us/qicore/STU6/qdm-to-qicore.html).
Measure Group (Rate) (ID: Group_1)
Basis boolean
Scoring Proportion
Improvement Notation Increased score indicates improvement
Type Process
Initial Population ID: InitialPopulation_1
Description:

All patients, regardless of age, with a diagnosis of HIV during the first 240 days of the measurement period or before the measurement period who had at least one eligible encounter during the first 240 days of the measurement period

Criteria: Initial Population
Denominator ID: Denominator_1
Description:

Equals Initial Population

Criteria: Denominator
Numerator ID: Numerator_1
Description:

Number of patients who had at least one eligible encounter and one HIV viral load test at least 90 days apart during the measurement period, or who had at least two eligible encounters at least 90 days apart during the measurement period

Criteria: Numerator
<p>For every patient evaluated by this measure also identify payer, race, ethnicity and sex</p>
Supplemental Data Elements
Supplemental Data Element ID: sde-ethnicity
Usage Code: Supplemental Data
Description: SDE Ethnicity
Logic Definition: SDE Ethnicity
Supplemental Data Element ID: sde-payer
Usage Code: Supplemental Data
Description: SDE Payer
Logic Definition: SDE Payer
Supplemental Data Element ID: sde-race
Usage Code: Supplemental Data
Description: SDE Race
Logic Definition: SDE Race
Supplemental Data Element ID: sde-sex
Usage Code: Supplemental Data
Description: SDE Sex
Logic Definition: SDE Sex
Measure Logic
Primary Library https://madie.cms.gov/Library/CMS1157FHIRHIVRetention
Contents Population Criteria
Logic Definitions
Terminology
Dependencies
Data Requirements
Parameters
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
define "Initial Population":
  "Has Active HIV Diagnosis Starts On or Before First 240 Days of Measurement Period"
    and "Has Qualifying Encounter During First 240 Days of Measurement Period"
Definition
Denominator
define "Denominator":
  "Initial Population"
Definition
Numerator
define "Numerator":
  "Has One Encounter With HIV and One Viral Load Test At Least 90 Days Apart"
    or "Has Two Encounters With HIV At Least 90 Days Apart"
Definition
Logic Definitions
Logic Definition Library Name: SupplementalDataElements
define "SDE Sex":
  case
    when Patient.sex() = '248153007' then "Male (finding)"
    when Patient.sex() = '248152002' then "Female (finding)"
    else null
  end
Logic Definition Library Name: SupplementalDataElements
define "SDE Payer":
  [USQualityCore.Coverage: type in "Payer Type"] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }
Logic Definition Library Name: SupplementalDataElements
define "SDE Ethnicity":
  (Patient.ethnicity()) E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }
Logic Definition Library Name: SupplementalDataElements
define "SDE Race":
  (Patient.race()) R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "SDE Sex":
  SDE."SDE Sex"
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "Encounter During Measurement Period With HIV":
  ( ( ["Encounter": "Office Visit"]
      union ["Encounter": "Outpatient Consultation"]
      union ["Encounter": "Annual Wellness Visit"]
      union ["Encounter": "Face-to-Face Interaction"]
      union ["Encounter": "Home Healthcare Services"]
      union ["Encounter": "Preventive Care Services Established Office Visit, 18 and Up"]
      union ["Encounter": "Preventive Care Services Initial Office Visit, 18 and Up"]
      union ["Encounter": "Preventive Care Services, Initial Office Visit, 0 to 17"]
      union ["Encounter": "Preventive Care, Established Office Visit, 0 to 17"]
      union ["Encounter": "Telephone Visits"]
      union ["Encounter": "Preventive Care Services Other"] ) ValidEncounter
      with ( ["ConditionProblemsHealthConcerns": "HIV"]
        union ["ConditionEncounterDiagnosis": "HIV"] ) HIVDiagnosis
        such that ValidEncounter.period during day of "Measurement Period"
          and ValidEncounter.status = 'finished'
          and HIVDiagnosis.onset.toInterval ( ) starts on or before day of start of ValidEncounter.period
          and HIVDiagnosis.isVerified ( )
  )
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "Has One Encounter With HIV and One Viral Load Test At Least 90 Days Apart":
  exists ( "Encounter During Measurement Period With HIV" ) EncounterWithHIV
    with ["LaboratoryResultObservation": "HIV Viral Load Tests"] ViralLoadTest
      such that ViralLoadTest.status in { 'final', 'amended', 'corrected' }
        and ViralLoadTest.effective.toInterval ( ) during day of "Measurement Period"
        and ( ( ViralLoadTest.effective.toInterval ( ) starts 90 days or more after day of end of EncounterWithHIV.period )
            or ( EncounterWithHIV.period starts 90 days or more after day of end of ViralLoadTest.effective.toInterval ( ) )
        )
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "Has Two Encounters With HIV At Least 90 Days Apart":
  exists "Encounter During Measurement Period With HIV" EncounterWithHIV
    with "Encounter During Measurement Period With HIV" AnotherEncounterWithHIV
      such that EncounterWithHIV !~ AnotherEncounterWithHIV
        and AnotherEncounterWithHIV.period starts 90 days or more after day of end of EncounterWithHIV.period
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "Numerator":
  "Has One Encounter With HIV and One Viral Load Test At Least 90 Days Apart"
    or "Has Two Encounters With HIV At Least 90 Days Apart"
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "Has Active HIV Diagnosis Starts On or Before First 240 Days of Measurement Period":
  exists ( ( ["ConditionProblemsHealthConcerns": "HIV"]
      union ["ConditionEncounterDiagnosis": "HIV"] ) HIVDx
      where HIVDx.onset.toInterval ( ) starts on or before day of ( start of "Measurement Period" + 240 days )
        and HIVDx.isVerified ( )
  )
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "Has Qualifying Encounter During First 240 Days of Measurement Period":
  exists ( ["Encounter": "Office Visit"]
    union ["Encounter": "Outpatient Consultation"]
    union ["Encounter": "Annual Wellness Visit"]
    union ["Encounter": "Face-to-Face Interaction"]
    union ["Encounter": "Home Healthcare Services"]
    union ["Encounter": "Preventive Care Services Established Office Visit, 18 and Up"]
    union ["Encounter": "Preventive Care Services Initial Office Visit, 18 and Up"]
    union ["Encounter": "Preventive Care Services, Initial Office Visit, 0 to 17"]
    union ["Encounter": "Preventive Care, Established Office Visit, 0 to 17"]
    union ["Encounter": "Telephone Visits"]
    union ["Encounter": "Preventive Care Services Other"] ) QualifyingEncounter
    where QualifyingEncounter.period during day of Interval[start of "Measurement Period", start of "Measurement Period" + 240 days]
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "Initial Population":
  "Has Active HIV Diagnosis Starts On or Before First 240 Days of Measurement Period"
    and "Has Qualifying Encounter During First 240 Days of Measurement Period"
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "Denominator":
  "Initial Population"
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "SDE Payer":
  SDE."SDE Payer"
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
Logic Definition Library Name: CMS1157FHIRHIVRetention
define "SDE Race":
  SDE."SDE Race"
Logic Definition Library Name: CMS1157FHIRHIVRetention
define fluent function isVerified(condition Choice<ConditionProblemsHealthConcerns, ConditionEncounterDiagnosis>):
  condition.verificationStatus is not null implies ( condition.verificationStatus ~ Status."confirmed"
      or condition.verificationStatus ~ Status."unconfirmed"
      or condition.verificationStatus ~ Status."provisional"
      or condition.verificationStatus ~ Status."differential"
  )
Logic Definition Library Name: FHIRHelpers
define function ToString(value string): value.value
Logic Definition Library Name: FHIRHelpers
define function ToString(value uri): value.value
Logic Definition Library Name: FHIRHelpers
/*
@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]
Logic Definition Library Name: FHIRHelpers
define function ToString(value EncounterStatus): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value dateTime): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDateTime(value instant): value.value
Logic Definition Library Name: FHIRHelpers
define function ToDate(value date): value.value
Logic Definition Library Name: FHIRHelpers
/*
@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
Logic Definition Library Name: FHIRHelpers
/*
@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
Logic Definition Library Name: FHIRHelpers
/*
@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
        }
Logic Definition Library Name: FHIRHelpers
/*
@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
        }
Logic Definition Library Name: FHIRHelpers
define function ToString(value ObservationStatus): value.value
Logic Definition Library Name: FHIRCommon
/*
@description: Returns the single extension (if present) on the given resource with the specified url.
@comment: This function uses singleton from to ensure that a run-time exception is thrown if there
is more than one extension on the given resource with the specified url.
*/
define fluent function ext(domainResource DomainResource, url String):
  singleton from domainResource.exts(url)
Logic Definition Library Name: FHIRCommon
/*
@description: Returns any extensions defined on the given resource with the specified url
*/
define fluent function exts(domainResource DomainResource, url String):
  domainResource.extension E
    where E.url = url
    return E
Logic Definition Library Name: FHIRCommon
/*
@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
Logic Definition Library Name: FHIRCommon
/*
@description: Returns the single extension (if present) on the given element with the specified url.
@comment: This function uses singleton from to ensure that a run-time exception is thrown if there
is more than one extension on the given element with the specified url.
*/
define fluent function ext(element Element, url String):
  singleton from element.exts(url)
Logic Definition Library Name: FHIRCommon
/*
@description: Returns any extensions defined on the given element with the specified url.
*/
define fluent function exts(element Element, url String):
  element.extension E
    where E.url = url
    return E
Logic Definition Library Name: USCoreCommon
/*
@description: Returns the sex element as defined for the USCore patient profile
*/
define fluent function sex(patient Patient):
  patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-sex').value as FHIR.code
Logic Definition Library Name: USCoreCommon
define fluent function ethnicity(patient Patient):
  (patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity')) E
    return {
      ombCategory: E.ext('ombCategory').value as FHIR.Coding,
      detailed: (E.exts('detailed')) d return d.value as FHIR.Coding,
      text: E.ext('text').value as FHIR.string
    }
Logic Definition Library Name: USCoreCommon
define fluent function race(patient Patient):
  (patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-race')) E
    return {
      ombCategory: (E.exts('ombCategory')) o return o.value as FHIR.Coding,
      detailed: (E.exts('detailed')) d return d.value as FHIR.Coding,
      text: E.ext('text').value as FHIR.string
    }
Terminology
Code System Description: Code system SNOMEDCT
Resource: SNOMED CT (all versions)
Canonical URL: http://snomed.info/sct
Code System Description: Code system ConditionVerificationStatusCodes
Resource: ConditionVerificationStatus
Canonical URL: http://terminology.hl7.org/CodeSystem/condition-ver-status
Value Set Description: Value set Office Visit
Resource: Office Visit
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001
Value Set Description: Value set Outpatient Consultation
Resource: Outpatient Consultation
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008
Value Set Description: Value set Annual Wellness Visit
Resource: Annual Wellness Visit
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1240
Value Set Description: Value set Face-to-Face Interaction
Resource: Face to Face Interaction
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.375
Value Set Description: Value set Home Healthcare Services
Resource: Home Healthcare Services
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1016
Value Set Description: Value set Preventive Care Services Established Office Visit, 18 and Up
Resource: Preventive Care Services Established Office Visit, 18 and Up
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1025
Value Set Description: Value set Preventive Care Services Initial Office Visit, 18 and Up
Resource: Preventive Care Services Initial Office Visit, 18 and Up
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1023
Value Set Description: Value set Preventive Care Services, Initial Office Visit, 0 to 17
Resource: Preventive Care Services, Initial Office Visit, 0 to 17
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1022
Value Set Description: Value set Preventive Care, Established Office Visit, 0 to 17
Resource: Preventive Care, Established Office Visit, 0 to 17
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1024
Value Set Description: Value set Telephone Visits
Resource: Telephone Visits
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1080
Value Set Description: Value set Preventive Care Services Other
Resource: Preventive Care Services Other
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.11.1150
Value Set Description: Value set HIV
Resource: HIV
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.120.12.1003
Value Set Description: Value set HIV Viral Load Tests
Resource: HIV Viral Load Tests
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.377
Value Set Description: Value set Payer Type
Resource: Payer Type
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Direct Reference Code Display: Male (finding)
Code: 248153007
System: http://snomed.info/sct
Direct Reference Code Display: Female (finding)
Code: 248152002
System: http://snomed.info/sct
Direct Reference Code Display: confirmed
Code: confirmed
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
Direct Reference Code Display: unconfirmed
Code: unconfirmed
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
Direct Reference Code Display: provisional
Code: provisional
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
Direct Reference Code Display: differential
Code: differential
System: http://terminology.hl7.org/CodeSystem/condition-ver-status
Dependencies
Dependency Description: USQualityCore model information
Resource: https://madie.cms.gov/Library/USQualityCore-ModelInfo|0.1.0-cibuild
Canonical URL: https://madie.cms.gov/Library/USQualityCore-ModelInfo|0.1.0-cibuild
Dependency Description: USCore model information
Resource: http://hl7.org/fhir/us/cql/Library/USCore-ModelInfo|6.1.0-derived
Canonical URL: http://hl7.org/fhir/us/cql/Library/USCore-ModelInfo|6.1.0-derived
Dependency Description: FHIR model information
Resource: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1
Dependency Description: Library SDE
Resource: SupplementalDataElements version: 6.1.000
Canonical URL: https://madie.cms.gov/Library/SupplementalDataElements|6.1.000
Dependency Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Dependency Description: Library USCommon
Resource: http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot
Canonical URL: http://hl7.org/fhir/us/cql/Library/USCoreCommon|2.0.0-ballot
Dependency Description: Library FHIRCommon
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Dependency Description: Library Status
Resource: Status version: 2.1.000
Canonical URL: https://madie.cms.gov/Library/Status|2.1.000
Data Requirements
Data Requirement Type: Patient
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-patient
Must Support Elements: ombCategory, detailed, text
Data Requirement Type: Patient
Profile(s): Patient
Must Support Elements: birthDate
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Office Visit
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Outpatient Consultation
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Annual Wellness Visit
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Face to Face Interaction
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Home Healthcare Services
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Preventive Care Services Established Office Visit, 18 and Up
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Preventive Care Services Initial Office Visit, 18 and Up
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Preventive Care Services, Initial Office Visit, 0 to 17
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Preventive Care, Established Office Visit, 0 to 17
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Telephone Visits
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period, status
Code Filter(s):
Path: type
ValueSet: Preventive Care Services Other
Data Requirement Type: Condition
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-condition-problems-health-concerns
Must Support Elements: code
Code Filter(s):
Path: code
ValueSet: HIV
Data Requirement Type: Condition
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-condition-encounter-diagnosis
Must Support Elements: code
Code Filter(s):
Path: code
ValueSet: HIV
Data Requirement Type: Observation
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-lab
Must Support Elements: code, status, effective
Code Filter(s):
Path: code
ValueSet: HIV Viral Load Tests
Data Requirement Type: Coverage
Profile(s): http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-coverage
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: Payer Type
Parameters
Name Use Card. Type Documentation
Measurement Period In 0..1 Period
SDE Sex Out 0..1 Coding
Numerator Out 0..1 boolean
Denominator Out 0..1 boolean
SDE Payer Out 0..* Resource
Initial Population Out 0..1 boolean
SDE Ethnicity Out 0..1 Resource
SDE Race Out 0..1 Resource
Generated using version 0.5.4 of the sample-content-ig Liquid templates