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

## Library: AdvancedIllnessandFrailty

Official URL: https://madie.cms.gov/Library/AdvancedIllnessandFrailty | Version: 2.1.000
Active as of 2025-07-25 | Responsible: National Committee for Quality Assurance | Computable Name: AdvancedIllnessandFrailty

This library contains definitions used to exclude patients 66 and older with an indication of frailty who also meet advanced illness criteria, and patients 66 and older who are living long term in a nursing home.

Metadata
Title | AdvancedIllnessandFrailty
Version | 2.1.000
Topic | FHIR
Topic | CQL
Steward (Publisher) | National Committee for Quality Assurance
Description | This library contains definitions used to exclude patients 66 and older with an indication of frailty who also meet advanced illness criteria, and patients 66 and older who are living long term in a nursing home.
Type | logic-library from http://terminology.hl7.org/CodeSystem/library-type
Dependency | Description: Model USQualityCore 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: 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 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 CMD Resource: http://hl7.org/fhir/us/cql/Library/CumulativeMedicationDuration|2.0.0-ballot Canonical URL: `http://hl7.org/fhir/us/cql/Library/CumulativeMedicationDuration|2.0.0-ballot`
Dependency | Description: Library Status Resource: Statusversion: null2.1.000) Canonical URL: `https://madie.cms.gov/Library/Status|2.1.000`
Dependency | Description: Code System LOINC Resource: Logical Observation Identifiers, Names and Codes (LOINC) Canonical URL: `http://loinc.org`
Dependency | Description: Code System SNOMEDCT Resource: SNOMED CT (all versions) Canonical URL: `http://snomed.info/sct`
Dependency | Description: Value Set Advanced Illness Resource: Advanced Illness Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.110.12.1082`
Dependency | Description: Value Set Dementia Medications Resource: Dementia Medications Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.196.12.1510`
Dependency | Description: Value Set Frailty Device Resource: Frailty Device Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.118.12.1300`
Dependency | Description: Value Set Frailty Diagnosis Resource: Frailty Diagnosis Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1074`
Dependency | Description: Value Set Frailty Encounter Resource: Frailty Encounter Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1088`
Dependency | Description: Value Set Frailty Symptom Resource: Frailty Symptom Canonical URL: `http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1075`
Data Requirement | Type: DeviceRequest Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-devicerequest` Code Filter(s): Path: code ValueSet: Frailty Device
Data Requirement | Type: Observation Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-screening-assessment` Code Filter(s): Path: code Code(s): LOINC: 98181-1 (Medical equipment used)
Data Requirement | Type: Condition Profile(s): Condition Code Filter(s): Path: code ValueSet: Frailty Diagnosis
Data Requirement | Type: Encounter Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-encounter` Code Filter(s): Path: type ValueSet: Frailty Encounter
Data Requirement | Type: Observation Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-simple-observation` Code Filter(s): Path: code ValueSet: Frailty Symptom
Data Requirement | Type: Condition Profile(s): Condition Code Filter(s): Path: code ValueSet: Advanced Illness
Data Requirement | Type: MedicationRequest Profile(s): MedicationRequest
Data Requirement | Type: Medication Profile(s): Medication
Data Requirement | Type: Observation Profile(s): `http://fhir.org/guides/astp/us-quality-core/StructureDefinition/us-quality-core-observation-screening-assessment` Code Filter(s): Path: code Code(s): LOINC: 71802-3 (Housing status)
Parameters
Name | Use | Card. | Type | Documentation
Measurement Period | In | 0..1 | Period |
Patient | Out | 0..1 | Resource |
Has Criteria Indicating Frailty | Out | 0..1 | boolean |
Has Advanced Illness in Year Before or During Measurement Period | Out | 0..1 | boolean |
Has Dementia Medications in Year Before or During Measurement Period | Out | 0..1 | boolean |
Is Age 66 or Older with Advanced Illness and Frailty | Out | 0..1 | boolean |
Is Age 66 to 80 with Advanced Illness and Frailty or Is Age 81 or Older with Frailty | Out | 0..1 | boolean |
Is Age 66 or Older Living Long Term in a Nursing Home | Out | 0..1 | boolean |
Library Content
CQL Content |
    /*
    NOTE: For use by March 2026 US Realm Connectathon participants for internal use only. Not for use or distribution in commercial products.
    */
    library AdvancedIllnessandFrailty version '2.1.000'

    using USQualityCore version '0.1.0-cibuild'
    using USCore version '6.1.0-derived'
    using FHIR version '4.0.1'

    include hl7.fhir.uv.cql.FHIRHelpers version '4.0.1' called FHIRHelpers
    include hl7.fhir.uv.cql.FHIRCommon version '2.0.0' called FHIRCommon
    include hl7.fhir.us.cql.CumulativeMedicationDuration version '2.0.0-ballot' called CMD

    include Status version '2.1.000' called Status

    codesystem "LOINC": 'http://loinc.org'
    codesystem "SNOMEDCT": 'http://snomed.info/sct'

    valueset "Advanced Illness": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.110.12.1082'
    valueset "Dementia Medications": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.196.12.1510'
    valueset "Frailty Device": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.118.12.1300'
    valueset "Frailty Diagnosis": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1074'
    valueset "Frailty Encounter": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1088'
    valueset "Frailty Symptom": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1075'

    code "Housing status": '71802-3' from "LOINC" display 'Housing status'
    code "Lives in nursing home (finding)": '160734000' from "SNOMEDCT" display 'Lives in nursing home (finding)'
    code "Medical equipment used": '98181-1' from "LOINC" display 'Medical equipment used'

    parameter "Measurement Period" Interval<DateTime>

    context Patient

    define "Is Age 66 or Older with Advanced Illness and Frailty":
       AgeInYearsAt(date from end of "Measurement Period") >= 66
        and "Has Criteria Indicating Frailty"
        and ( "Has Advanced Illness in Year Before or During Measurement Period"
            or "Has Dementia Medications in Year Before or During Measurement Period"
        )

    define "Is Age 66 to 80 with Advanced Illness and Frailty or Is Age 81 or Older with Frailty":
      ( AgeInYearsAt(date from end of "Measurement Period") in Interval[66, 80]
          and "Has Criteria Indicating Frailty"
          and ( "Has Advanced Illness in Year Before or During Measurement Period"
              or "Has Dementia Medications in Year Before or During Measurement Period"
          )
      )
        or ( AgeInYearsAt(date from end of "Measurement Period")>= 81
            and "Has Criteria Indicating Frailty"
        )

    define "Has Criteria Indicating Frailty":
      exists ( (([USQualityCore.DeviceRequest: "Frailty Device"]).isDeviceOrderPersonalUseDevices()) FrailtyDeviceOrder
          where FrailtyDeviceOrder.authoredOn.toInterval() during day of "Measurement Period"
      )
        or exists ( (([ObservationScreeningAssessment: "Medical equipment used"]).isAssessmentPerformed()) EquipmentUsed
            where EquipmentUsed.value as CodeableConcept in "Frailty Device"
            and EquipmentUsed.effective.toInterval() ends during day of "Measurement Period"
        )
        // TODO: Consider whether to keep this as the union of problems and encounter diagnoses
        or exists ( (([FHIR.Condition: "Frailty Diagnosis"]).verified()) FrailtyDiagnosis
            where FrailtyDiagnosis.prevalenceInterval() overlaps day of "Measurement Period"
        )
        or exists ( (([USQualityCore.Encounter: "Frailty Encounter"]).isEncounterPerformed()) FrailtyEncounter
            where FrailtyEncounter.period overlaps day of "Measurement Period"
        )
        or exists ( (([USQualityCore.SimpleObservation: "Frailty Symptom"]).isSymptom()) FrailtySymptom
            where FrailtySymptom.effective.toInterval() overlaps day of "Measurement Period"
        )

    define "Has Advanced Illness in Year Before or During Measurement Period":
    // TODO: Consider whether to keep this as the union of problems and encounter diagnoses
    exists ((([Condition: "Advanced Illness"]).verified()) AdvancedIllnessDiagnosis
    where AdvancedIllnessDiagnosis.prevalenceInterval() starts during day of Interval[start of "Measurement Period" - 1 year, end of "Measurement Period"])

    define "Has Dementia Medications in Year Before or During Measurement Period":
      exists (( ([FHIR.MedicationRequest: "Dementia Medications"]).isMedicationActive()) DementiaMedication
          where DementiaMedication.medicationRequestPeriod() overlaps day of Interval[start of "Measurement Period" - 1 year,
            end of "Measurement Period"]
      )

    define "Is Age 66 or Older Living Long Term in a Nursing Home":
      AgeInYearsAt(date from end of "Measurement Period") >= 66
        and ( ( Last( (([ObservationScreeningAssessment: "Housing status"]).isAssessmentPerformed()) HousingStatus
              where HousingStatus.effective.toInterval() ends on or before
              day of end of "Measurement Period"
              sort by
              end of effective.toInterval() asc
          )) LastHousingStatus
            where LastHousingStatus.value ~ "Lives in nursing home (finding)"
        ) is not null
ELM XML Content |
    Encoded data
ELM JSON Content |
    Encoded data
Generated using version 0.5.4 of the sample-content-ig Liquid templates