eCQM QICore Content Implementation Guide
2024.0.0 - CI Build

eCQM QICore Content Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2024.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/ecqm-content-qicore-2024/ and changes regularly. See the Directory of published versions

Measure: Functional Status Assessment for Total Hip ReplacementFHIR

Official URL: https://madie.cms.gov/Measure/FunctionalStatusAssessmentforTotalHipReplacementFHIR Version: 0.0.008
Draft as of 2024-07-09 Responsible: Centers for Medicare & Medicaid Services (CMS) Computable Name: FunctionalStatusAssessmentforTotalHipReplacementFHIR
Other Identifiers: Short Name (use: usual, ), UUID:959c21c9-35c7-4967-aaec-3dab54850811 (use: official, ), UUID:ebd41a01-4e61-4198-9ff0-becc43de1ba7 (use: official, ), Publisher (use: official, )

Copyright/Legal: This Physician Performance Measure (Measure) and related data specifications are owned and stewarded by the Centers for Medicare & Medicaid Services (CMS). CMS contracted (Contract HHSP23320095627WC; HHSP23337008T) with the National Committee for Quality Assurance (NCQA) to develop this electronic measure. NCQA is not responsible for any use of the Measure. NCQA makes no representations, warranties, or endorsement about the quality of any organization or physician that uses or reports performance measures and NCQA has no liability to anyone who relies on such measures or specifications. 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. NCQA disclaims all liability for use or accuracy of any third-party codes contained in the specifications. CPT(R) codes, descriptions and other data are copyright 2024. American Medical Association. All rights reserved. CPT is a trademark of the American Medical Association. Fee schedules, relative value units, conversion factors and/or related components are not assigned by the AMA, are not part of CPT, and the AMA is not recommending their use. The AMA does not directly or indirectly practice medicine or dispense medical services. The AMA assumes no liability for data contained or not contained herein. Applicable FARS/DFARS restrictions apply to government use. The American Dental Association (“ADA”) holds a copyright to the Current Dental Terminology (“CDT”) codes contained in certain measure specifications. The CDT codes in the measure specifications are included with the permission of the ADA. All uses of the CDT codes require a license from the ADA. No alteration, amendments, or modifications of the CDT or any portion thereof is allowed. Resale, transmission, or distribution of copies of the CDT or other portions of the CDT is also not allowed. To inquire about licensing, contact CDT-SNODENT@ada.org. The measure specifications contain coding from LOINC(R) (http://loinc.org). The LOINC table, LOINC codes, LOINC panels and form file, LOINC linguistic variants file, LOINC/RSNA Radiology Playbook, and LOINC/IEEE Medical Device Code Mapping Table are copyright 2004-2024 Regenstrief Institute, Inc. and the Logical Observation Identifiers Names and Codes (LOINC) Committee, and are available at no cost under the license at http://loinc.org/terms-of-use. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2023 International Health Terminology Standards Development Organisation. ICD-10 copyright 2024 World Health Organization. All Rights Reserved. “HL7” is the registered trademark of Health Level Seven International.

Percentage of patients 19 years of age and older who received an elective primary total hip arthroplasty (THA) and completed a functional status assessment within 90 days prior to the surgery and in the 300 - 425 days after the surgery

UNKNOWN

Title: Functional Status Assessment for Total Hip ReplacementFHIR
Id: FunctionalStatusAssessmentforTotalHipReplacementFHIR
Version: 0.0.008
Url: Functional Status Assessment for Total Hip ReplacementFHIR
short-name identifier:

CMS56FHIR

version-independent identifier:

urn:uuid:959c21c9-35c7-4967-aaec-3dab54850811

version-specific identifier:

urn:uuid:ebd41a01-4e61-4198-9ff0-becc43de1ba7

publisher (CMS) identifier:

56FHIR

Effective Period: 2025-01-01..2025-12-31
Status: draft
Publisher: Centers for Medicare & Medicaid Services (CMS)
Author: National Committee for Quality Assurance
Description:

Percentage of patients 19 years of age and older who received an elective primary total hip arthroplasty (THA) and completed a functional status assessment within 90 days prior to the surgery and in the 300 - 425 days after the surgery

Purpose:

UNKNOWN

Copyright:

This Physician Performance Measure (Measure) and related data specifications are owned and stewarded by the Centers for Medicare & Medicaid Services (CMS). CMS contracted (Contract HHSP23320095627WC; HHSP23337008T) with the National Committee for Quality Assurance (NCQA) to develop this electronic measure. NCQA is not responsible for any use of the Measure. NCQA makes no representations, warranties, or endorsement about the quality of any organization or physician that uses or reports performance measures and NCQA has no liability to anyone who relies on such measures or specifications. 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. NCQA disclaims all liability for use or accuracy of any third-party codes contained in the specifications. CPT(R) codes, descriptions and other data are copyright 2024. American Medical Association. All rights reserved. CPT is a trademark of the American Medical Association. Fee schedules, relative value units, conversion factors and/or related components are not assigned by the AMA, are not part of CPT, and the AMA is not recommending their use. The AMA does not directly or indirectly practice medicine or dispense medical services. The AMA assumes no liability for data contained or not contained herein. Applicable FARS/DFARS restrictions apply to government use. The American Dental Association (“ADA”) holds a copyright to the Current Dental Terminology (“CDT”) codes contained in certain measure specifications. The CDT codes in the measure specifications are included with the permission of the ADA. All uses of the CDT codes require a license from the ADA. No alteration, amendments, or modifications of the CDT or any portion thereof is allowed. Resale, transmission, or distribution of copies of the CDT or other portions of the CDT is also not allowed. To inquire about licensing, contact CDT-SNODENT@ada.org. The measure specifications contain coding from LOINC(R) (http://loinc.org). The LOINC table, LOINC codes, LOINC panels and form file, LOINC linguistic variants file, LOINC/RSNA Radiology Playbook, and LOINC/IEEE Medical Device Code Mapping Table are copyright 2004-2024 Regenstrief Institute, Inc. and the Logical Observation Identifiers Names and Codes (LOINC) Committee, and are available at no cost under the license at http://loinc.org/terms-of-use. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2023 International Health Terminology Standards Development Organisation. ICD-10 copyright 2024 World Health Organization. All Rights Reserved. “HL7” is the registered trademark of Health Level Seven International.

Disclaimer:

The performance Measure is not a clinical guideline and does not establish a standard of medical care, and has not been tested for all potential applications. THE MEASURE 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:

THAs are common surgical procedures that address hip pain and functional impairment, primarily caused by osteoarthritis. Although THA is an effective procedure for addressing osteoarthritis for many patients, some people, particularly those with more severe preoperative pain and impairment, do not experience the improvements in pain, function, and quality of life expected from the procedure (Beswick et al., 2012; Fortin et al., 1999; Tilbury et al., 2016). In 2010, providers performed 326,100 THAs, with 95 percent of them in patients age 45 and older (Wolford, Palso, & Bercovitz, 2015). Although THAs were introduced as a procedure for older adults, the percentage of patients age 55 to 64 (29 percent) who had a THA in 2010 exceeded the percentage of patients age 75 and older (26 percent) who had a THA (Wolford, Palso, & Bercovitz, 2015). Kurtz et al. (2009) projected that patients younger than 65 would account for 52 percent of THAs by 2030. This growth in hip surgeries for patients younger than 65 is significant because these patients often require more expensive joint arthroplasties that will better withstand the wear caused by physical activity (Bozic et al., 2006). This measure evaluates whether patients complete a patient-reported functional status assessment (FSA) before and after a THA. Measuring functional status for patients undergoing THA permits longitudinal assessment - from the patient's perspective - of the impact of surgical intervention on pain, physical function, as well as health-related quality of life (Rothrock et al., 2010).

Clinical recommendation statement:

While there is no clinical guideline recommending that clinicians assess patients who are undergoing total hip replacements using patient-reported outcomes of function and pain, several clinical specialty societies support the use of a general health questionnaire and a disease-specific questionnaire for these patients. In particular, they recommend the Veterans RAND 12-item health survey (VR-12) or the Patient-Reported Outcomes Measurement Information System [PROMIS]-10-Global as the general health questionnaire and the Hip Disability and Osteoarthritis Outcome Score [HOOS], Jr. as the disease-specific questionnaire (American Association of Orthopaedic Surgeons, the American Joint Replacement Registry, The Hip Society, The Knee Society, & the American Association of Hip and Knee Surgeons, 2015). Peer-reviewed and grey literature support additional exclusions for patients undergoing total hip replacements. Staged procedures, concurrent procedures, partial procedures, resurfacing procedures, revision procedures, and removal of implant devices or prosthesis were linked to significant morbidity; complications (such as dislocation, infection, and reinfection); and high failure rates (Ludwick et al., 2021). In addition, mechanical complications, such as instability and dislocation, are also linked to complications and are associated with primary and revision THA/Total Knee Arthroplasty (TKA) (Gkiatas et al., 2021). Malignant neoplasms (such as osteonecrosis of the femoral head) are associated with substantial pain and functional disabilities before THA/TKA (Bernhard et al., 2021). Additionally, peer-reviewed and grey literature support various postoperative time frames, including follow-up within 10 to 14 months (Franklin et al., 2021) (Holte et al., 2021).

Guidance (Usage): The same FSA instrument must be used for the initial and follow-up assessment. This eCQM is a patient-based measure. This FHIR-based measure has been derived from the QDM-based measure: CMS56v13. Please refer to the HL7 QI-Core Implementation Guide (http://hl7.org/fhir/us/qicore/STU4.1.1/) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (http://hl7.org/fhir/us/qicore/STU4.1.1/qdm-to-qicore.html).
Population Criteria:
64e6505f2ad653247b573ae2
Initial Population: Patients 19 years of age and older who had a primary THA between November two years prior to the measurement period and October of the year prior to measurement period; and who had an outpatient encounter between August of the year prior to the measurement period and the end of the measurement period
Denominator: Equals Initial Population
Denominator Exclusion: Exclude patients who are in hospice care for any part of the measurement period. Exclude patients with severe cognitive impairment that starts before or in any part of the measurement period. Exclude patients with one or more specific lower body fractures indicating trauma in the 24 hours before or at the start of the total hip arthroplasty. Exclude patients with a partial hip arthroplasty procedure on the day of the total hip arthroplasty. Exclude patients with a revision hip arthroplasty procedure, an implanted device/prosthesis removal procedure or a resurfacing/supplement procedure on the day of the total hip arthroplasty. Exclude patients with a malignant neoplasm of the pelvis, sacrum, coccyx, lower limbs, or bone/bone marrow or a disseminated malignant neoplasm on the day of the total hip arthroplasty. Exclude patients with a mechanical complication on the day of the total hip arthroplasty. Exclude patients with a second total hip arthroplasty procedure 1 year before or after the original total hip arthroplasty procedure. Exclude patients who die on the day of the total hip arthroplasty procedure or in the 300 days after.
Numerator: Patients with patient-reported functional status assessment results (i.e., Veterans RAND 12-item health survey [VR-12], Patient-Reported Outcomes Measurement Information System [PROMIS]-10-Global Health, Hip Disability and Osteoarthritis Outcome Score [HOOS], HOOS Jr.) in the 90 days prior to or on the day of the primary THA procedure, and in the 300 - 425 days after the THA procedure
Libraries:
FunctionalStatusAssessmentforTotalHipReplacementFHIR
Terminology and Other Dependencies:
  • Library/Status|1.8.000
  • Library/QICoreCommon|2.1.000
  • Library/FHIRHelpers|4.4.000
  • Library/Hospice|6.12.000
  • Observation Category Codes
  • Logical Observation Identifiers, Names and Codes (LOINC)
  • Current Procedural Terminology (CPT®)
  • SNOMED CT (all versions)
  • Primary THA Procedure
  • Outpatient Consultation
  • Office Visit
  • Telephone Visits
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1089
  • Encounter Inpatient
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1003
  • Hospice Care Ambulatory
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1165
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1178
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1184
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1189
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1180
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1182
  • Parameters:
    name use min max type
    Measurement Period In 0 1 Period
    Numerator Out 0 1 boolean
    Denominator Out 0 1 boolean
    Initial Population Out 0 1 boolean
    Denominator Exclusions Out 0 1 boolean
    DataRequirements:
    Resource Type Resource Elements Valueset Name Valueset
    Procedure(QICoreProcedure) code performed status status.value Hospice Care Ambulatory Hospice Care Ambulatory
    Procedure(QICoreProcedure) code performed status status.value Partial Arthroplasty of Hip http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1184
    Procedure(QICoreProcedure) code performed status status.value Removal, Revision and Supplement Procedures of the Lower Body and Spine http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1189
    Procedure(QICoreProcedure) code id id.value performed status status.value Primary THA Procedure Primary THA Procedure
    Procedure(QICoreProcedure) code performed id id.value status status.value Primary THA Procedure Primary THA Procedure
    Procedure(QICoreProcedure) code performed status status.value Primary THA Procedure Primary THA Procedure
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code value status status.value category effective
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code effective value status status.value category
    Observation(QICoreObservation) code value effective status status.value category
    Patient(QICorePatient)
    Encounter(QICoreEncounter) type status status.value period
    Encounter(QICoreEncounter) type status status.value period Outpatient Consultation Outpatient Consultation
    Encounter(QICoreEncounter) type status status.value period Office Visit Office Visit
    Encounter(QICoreEncounter) type status status.value period Telephone Visits Telephone Visits
    Encounter(QICoreEncounter) type status status.value period Virtual Encounter http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1089
    Encounter(QICoreEncounter) type hospitalization hospitalization.dischargeDisposition period status status.value Encounter Inpatient Encounter Inpatient
    Encounter(QICoreEncounter) type period status status.value Hospice Encounter http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1003
    ServiceRequest(QICoreServiceRequest) code authoredOn authoredOn.value status status.value intent intent.value Hospice Care Ambulatory Hospice Care Ambulatory
    Condition(QICoreCondition) code Hospice Diagnosis http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1165
    Condition(QICoreCondition) code
    Condition(QICoreCondition) code Lower Body Fractures Excluding Ankle and Foot http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1178
    Condition(QICoreCondition) code Malignant Neoplasms of Lower and Unspecified Limbs http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1180
    Condition(QICoreCondition) code Mechanical Complications Excluding Upper Body http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.1182
    Direct Reference Codes:
    display code system
    survey survey http://terminology.hl7.org/CodeSystem/observation-category
    Quality of life score [HOOS] 72093-8 http://loinc.org
    Sport-recreation score [HOOS] 72094-6 http://loinc.org
    Activities of daily living score [HOOS] 72095-3 http://loinc.org
    Symptoms score [HOOS] 72096-1 http://loinc.org
    Pain score [HOOS] 72097-9 http://loinc.org
    Total interval score [HOOSJR] 82323-7 http://loinc.org
    PROMIS-10 Global Mental Health (GMH) score T-score 71969-0 http://loinc.org
    PROMIS-10 Global Physical Health (GPH) score T-score 71971-6 http://loinc.org
    VR-12 Mental component summary (MCS) score - oblique method T-score 72026-8 http://loinc.org
    VR-12 Physical component summary (PCS) score - oblique method T-score 72025-0 http://loinc.org
    VR-12 Mental component summary (MCS) score - orthogonal method T-score 72028-4 http://loinc.org
    VR-12 Physical component summary (PCS) score - orthogonal method T-score 72027-6 http://loinc.org
    Postoperative follow-up visit, normally included in the surgical package, to indicate that an evaluation and management service was performed during a postoperative period for a reason(s) related to the original procedure 99024 http://www.ama-assn.org/go/cpt
    Discharge to home for hospice care (procedure) 428361000124107 http://snomed.info/sct
    Discharge to healthcare facility for hospice care (procedure) 428371000124100 http://snomed.info/sct
    Yes (qualifier value) 373066001 http://snomed.info/sct
    Hospice care [Minimum Data Set] 45755-6 http://loinc.org
    Severe cognitive impairment (finding) 702956004 http://snomed.info/sct
    Logic Definitions:
    Group Scoring Population Criteria Expression
    64e6505f2ad653247b573ae2 Group scoring: proportion
    Type:

    Process

    Rate Aggregation: None
    Improvement Notation:

    increase

    Initial Population
    define "Initial Population":
      "Has Qualifying Encounter"
        and exists ( "Total Hip Arthroplasty Procedure" )
        and AgeInYearsAt(date from start of "Measurement Period") >= 19
    Denominator
    define "Denominator":
      "Initial Population"
    Denominator Exclusion
    define "Denominator Exclusions":
      Hospice."Has Hospice Services"
        or "Has Severe Cognitive Impairment"
        or "Has Total Hip Arthroplasty with 1 or More Lower Body Fractures"
        or "Has Partial Hip Arthroplasty Procedure"
        or "Has Revision Hip Arthroplasty Procedure or Implanted Device or Prosthesis Removal Procedure"
        or "Has Malignant Neoplasm of Lower and Unspecified Limbs"
        or "Has Mechanical Complication"
        or "Has More Than One Elective Primary Total Hip Arthroplasty Performed"
        or "Death Within 300 Days of the THA Procedure"
    Numerator
    define "Numerator":
      ( "Has THA with Initial and Follow Up HOOS Assessments" )
        or ( "Has THA with Initial and Follow Up HOOSJr Assessments" )
        or ( "Has THA with Initial and Follow Up PROMIS10 Assessments" )
        or ( "Has THA with Initial and Follow Up VR12 Oblique Assessments" )
        or ( "Has THA with Initial and Follow Up VR12 Orthogonal Assessments" )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR November 1 Two Years Prior to the Measurement Period
    define "November 1 Two Years Prior to the Measurement Period":
      DateTime((year from start of "Measurement Period" - 2), 11, 1, 0, 0, 0, 0, 0)
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR October 31 Year Prior to the Measurement Period
    define "October 31 Year Prior to the Measurement Period":
      DateTime((year from start of "Measurement Period" - 1), 10, 31, 23, 59, 59, 0, 0)
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Total Hip Arthroplasty Procedure
    define "Total Hip Arthroplasty Procedure":
      ( ( [Procedure: "Primary THA Procedure"] ).isProcedurePerformed ( ) ) THAProcedure
        where THAProcedure.performed.toInterval ( ) starts during day of Interval["November 1 Two Years Prior to the Measurement Period", "October 31 Year Prior to the Measurement Period"]
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Date HOOS Total Assessment Completed
    define "Date HOOS Total Assessment Completed":
      from
        ( ( [Observation: "Quality of life score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSLifeQuality,
        ( ( [Observation: "Sport-recreation score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSSport,
        ( ( [Observation: "Activities of daily living score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSActivityScore,
        ( ( [Observation: "Symptoms score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSSymptoms,
        ( ( [Observation: "Pain score [HOOS]"] ).isAssessmentPerformed ( ) ) HOOSPain
        let HOOSLifeQualityDate: date from start of HOOSLifeQuality.effective.toInterval ( ),
        HOOSSportDate: date from start of HOOSSport.effective.toInterval ( ),
        HOOSActivityScoreDate: date from start of HOOSActivityScore.effective.toInterval ( ),
        HOOSSymptomsDate: date from start of HOOSSymptoms.effective.toInterval ( ),
        HOOSPainDate: date from start of HOOSPain.effective.toInterval ( )
        where HOOSLifeQualityDate same day as HOOSSportDate
          and HOOSSport.value is not null
          and HOOSLifeQualityDate same day as HOOSActivityScoreDate
          and HOOSActivityScore.value is not null
          and HOOSLifeQualityDate same day as HOOSSymptomsDate
          and HOOSSymptoms.value is not null
          and HOOSLifeQualityDate same day as HOOSPainDate
          and HOOSPain.value is not null
          and HOOSLifeQuality.value is not null
        return Max({ HOOSLifeQualityDate, HOOSSportDate, HOOSActivityScoreDate, HOOSSymptomsDate, HOOSPainDate })
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has THA with Initial and Follow Up HOOS Assessments
    define "Has THA with Initial and Follow Up HOOS Assessments":
      exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
          return THAProcedure.performed.toInterval ( ) ) TotalHip
          with "Date HOOS Total Assessment Completed" InitialHipAssessmentHOOS
            such that TotalHip starts 90 days or less on or after day of InitialHipAssessmentHOOS
          with "Date HOOS Total Assessment Completed" FollowUpHipAssessmentHOOS
            such that date from FollowUpHipAssessmentHOOS during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Date HOOSJr Total Assessment Completed
    define "Date HOOSJr Total Assessment Completed":
      ( ( ( [Observation: "Total interval score [HOOSJR]"] ).isAssessmentPerformed ( ) ) HOOSJr
        where HOOSJr.value is not null ) DocumentedHOOSJr
        return date from start of DocumentedHOOSJr.effective.toInterval ( )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has THA with Initial and Follow Up HOOSJr Assessments
    define "Has THA with Initial and Follow Up HOOSJr Assessments":
      exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
          return THAProcedure.performed.toInterval ( ) ) TotalHip
          with "Date HOOSJr Total Assessment Completed" InitialHipAssessment
            such that TotalHip starts 90 days or less on or after day of InitialHipAssessment
          with "Date HOOSJr Total Assessment Completed" FollowUpHipAssessment
            such that date from FollowUpHipAssessment during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Date PROMIS10 Total Assessment Completed
    define "Date PROMIS10 Total Assessment Completed":
      from
        ( ( [Observation: "PROMIS-10 Global Mental Health (GMH) score T-score"] ).isAssessmentPerformed ( ) ) PROMIS10MentalScore,
        ( ( [Observation: "PROMIS-10 Global Physical Health (GPH) score T-score"] ).isAssessmentPerformed ( ) ) PROMIS10PhysicalScore
        let PROMIS10MentalScoreDate: date from start of PROMIS10MentalScore.effective.toInterval ( ),
        PROMIS10PhysicalScoreDate: date from start of PROMIS10PhysicalScore.effective.toInterval ( )
        where PROMIS10MentalScoreDate same day as PROMIS10PhysicalScoreDate
          and PROMIS10PhysicalScore.value is not null
          and PROMIS10MentalScore.value is not null
        return Max({ PROMIS10MentalScoreDate, PROMIS10PhysicalScoreDate })
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has THA with Initial and Follow Up PROMIS10 Assessments
    define "Has THA with Initial and Follow Up PROMIS10 Assessments":
      exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
          return THAProcedure.performed.toInterval ( ) ) TotalHip
          with "Date PROMIS10 Total Assessment Completed" InitialHipAssessmentPROMIS10
            such that TotalHip starts 90 days or less on or after day of InitialHipAssessmentPROMIS10
          with "Date PROMIS10 Total Assessment Completed" FollowUpHipAssessmentPROMIS10
            such that date from FollowUpHipAssessmentPROMIS10 during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Date VR12 Oblique Total Assessment Completed
    define "Date VR12 Oblique Total Assessment Completed":
      from
        ( ( [Observation: "VR-12 Mental component summary (MCS) score - oblique method T-score"] ).isAssessmentPerformed ( ) ) VR12MentalAssessment,
        ( ( [Observation: "VR-12 Physical component summary (PCS) score - oblique method T-score"] ).isAssessmentPerformed ( ) ) VR12PhysicalAssessment
        let VR12MentalAssessmentDate: date from start of VR12MentalAssessment.effective.toInterval ( ),
        VR12PhysicalAssessmentDate: date from start of VR12PhysicalAssessment.effective.toInterval ( )
        where VR12MentalAssessmentDate same day as VR12PhysicalAssessmentDate
          and VR12MentalAssessment.value is not null
          and VR12PhysicalAssessment.value is not null
        return Max({ VR12MentalAssessmentDate, VR12PhysicalAssessmentDate })
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has THA with Initial and Follow Up VR12 Oblique Assessments
    define "Has THA with Initial and Follow Up VR12 Oblique Assessments":
      exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
          return THAProcedure.performed.toInterval ( ) ) TotalHip
          with "Date VR12 Oblique Total Assessment Completed" InitialHipAssessmentOblique
            such that TotalHip starts 90 days or less on or after day of InitialHipAssessmentOblique
          with "Date VR12 Oblique Total Assessment Completed" FollowUpHipAssessmentOblique
            such that date from FollowUpHipAssessmentOblique during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Date VR12 Orthogonal Total Assessment Completed
    define "Date VR12 Orthogonal Total Assessment Completed":
      from
        ( ( [Observation: "VR-12 Mental component summary (MCS) score - orthogonal method T-score"] ).isAssessmentPerformed ( ) ) VR12MentalAssessment,
        ( ( [Observation: "VR-12 Physical component summary (PCS) score - orthogonal method T-score"] ).isAssessmentPerformed ( ) ) VR12PhysicalAssessment
        let VR12MentalAssessmentDate: date from start of VR12MentalAssessment.effective.toInterval ( ),
        VR12PhysicalAssessmentDate: date from start of VR12PhysicalAssessment.effective.toInterval ( )
        where VR12MentalAssessmentDate same day as VR12PhysicalAssessmentDate
          and VR12MentalAssessment.value is not null
          and VR12PhysicalAssessment.value is not null
        return Max({ VR12MentalAssessmentDate, VR12PhysicalAssessmentDate })
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has THA with Initial and Follow Up VR12 Orthogonal Assessments
    define "Has THA with Initial and Follow Up VR12 Orthogonal Assessments":
      exists ( ( "Total Hip Arthroplasty Procedure" THAProcedure
          return THAProcedure.performed.toInterval ( ) ) TotalHip
          with "Date VR12 Orthogonal Total Assessment Completed" InitialHipAssessmentOrthogonal
            such that TotalHip starts 90 days or less on or after day of InitialHipAssessmentOrthogonal
          with "Date VR12 Orthogonal Total Assessment Completed" FollowUpHipAssessmentOrthogonal
            such that date from FollowUpHipAssessmentOrthogonal during day of Interval[date from end of TotalHip + 300 days, date from end of TotalHip + 425 days]
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Numerator
    define "Numerator":
      ( "Has THA with Initial and Follow Up HOOS Assessments" )
        or ( "Has THA with Initial and Follow Up HOOSJr Assessments" )
        or ( "Has THA with Initial and Follow Up PROMIS10 Assessments" )
        or ( "Has THA with Initial and Follow Up VR12 Oblique Assessments" )
        or ( "Has THA with Initial and Follow Up VR12 Orthogonal Assessments" )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR August 1 Year Prior to the Measurement Period
    define "August 1 Year Prior to the Measurement Period":
      DateTime((year from start of "Measurement Period" - 1), 8, 1, 0, 0, 0, 0, 0)
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has Qualifying Encounter
    define "Has Qualifying Encounter":
      exists ( ( ( [Encounter: "Outpatient Consultation"]
            union [Encounter: "Office Visit"]
            union ( [Encounter] E
                where exists ( ( E.type ) T
                    where T ~ "Postoperative follow-up visit, normally included in the surgical package, to indicate that an evaluation and management service was performed during a postoperative period for a reason(s) related to the original procedure"
                )
            )
            union [Encounter: "Telephone Visits"]
            union [Encounter: "Virtual Encounter"]
        ).isEncounterPerformed ( ) ) ValidEncounters
          where ValidEncounters.period.toInterval ( ) during day of Interval["August 1 Year Prior to the Measurement Period", end of "Measurement Period"]
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Initial Population
    define "Initial Population":
      "Has Qualifying Encounter"
        and exists ( "Total Hip Arthroplasty Procedure" )
        and AgeInYearsAt(date from start of "Measurement Period") >= 19
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Denominator
    define "Denominator":
      "Initial Population"
    Library Name Name
    Hospice Has Hospice Services
    define "Has Hospice Services":
      exists ((([Encounter: "Encounter Inpatient"]).isEncounterPerformed()) InpatientEncounter
          where (InpatientEncounter.hospitalization.dischargeDisposition ~ "Discharge to home for hospice care (procedure)"
              or InpatientEncounter.hospitalization.dischargeDisposition ~ "Discharge to healthcare facility for hospice care (procedure)"
          )
            and InpatientEncounter.period.toInterval() ends during day of "Measurement Period"
      )
        or exists ((([Encounter: "Hospice Encounter"]).isEncounterPerformed()) HospiceEncounter
            where HospiceEncounter.period.toInterval() overlaps day of "Measurement Period"
        )
        or exists ((([Observation: "Hospice care [Minimum Data Set]"]).isAssessmentPerformed()) HospiceAssessment
            where HospiceAssessment.value ~ "Yes (qualifier value)"
              and HospiceAssessment.effective.toInterval() overlaps day of "Measurement Period"
        )
        or exists ((([ServiceRequest: "Hospice Care Ambulatory"]).isInterventionOrder()) HospiceOrder
            where HospiceOrder.authoredOn.toInterval() during day of "Measurement Period"
            // and HospiceOrder.doNotPerform is not true
            // https://oncprojectracking.healthit.gov/support/browse/CQLIT-447
        )
        or exists ((([Procedure: "Hospice Care Ambulatory"]).isInterventionPerformed()) HospicePerformed
            where HospicePerformed.performed.toInterval() overlaps day of "Measurement Period"
        )
        or exists (([Condition: "Hospice Diagnosis"]) HospiceCareDiagnosis
            where HospiceCareDiagnosis.prevalenceInterval() overlaps day of "Measurement Period"
        )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has Severe Cognitive Impairment
    define "Has Severe Cognitive Impairment":
      exists [Condition: "Severe cognitive impairment (finding)"] Dementia
        where Dementia.prevalenceInterval ( ) overlaps day of "Measurement Period"
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has Total Hip Arthroplasty with 1 or More Lower Body Fractures
    define "Has Total Hip Arthroplasty with 1 or More Lower Body Fractures":
      exists ( "Total Hip Arthroplasty Procedure" THAProcedure
          with [Condition: "Lower Body Fractures Excluding Ankle and Foot"] LowerBodyFracture
            such that LowerBodyFracture.prevalenceInterval ( ) starts 24 hours or less on or before start of THAProcedure.performed."toInterval" ( )
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has Partial Hip Arthroplasty Procedure
    define "Has Partial Hip Arthroplasty Procedure":
      exists ( ( ( [Procedure: "Partial Arthroplasty of Hip"] ).isProcedurePerformed ( ) ) PartialTHAProcedure
          with "Total Hip Arthroplasty Procedure" THAProcedure
            such that PartialTHAProcedure.performed.toInterval ( ) during day of THAProcedure.performed.toInterval ( )
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has Revision Hip Arthroplasty Procedure or Implanted Device or Prosthesis Removal Procedure
    define "Has Revision Hip Arthroplasty Procedure or Implanted Device or Prosthesis Removal Procedure":
      exists ( "Total Hip Arthroplasty Procedure" THAProcedure
          with ( ( [Procedure: "Removal, Revision and Supplement Procedures of the Lower Body and Spine"] ).isProcedurePerformed ( ) ) RevisionTHAProcedure
            such that RevisionTHAProcedure.performed.toInterval ( ) during day of THAProcedure.performed.toInterval ( )
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has Malignant Neoplasm of Lower and Unspecified Limbs
    define "Has Malignant Neoplasm of Lower and Unspecified Limbs":
      exists ( [Condition: "Malignant Neoplasms of Lower and Unspecified Limbs"] MalignantNeoplasm
          with "Total Hip Arthroplasty Procedure" THAProcedure
            such that MalignantNeoplasm.prevalenceInterval ( ) overlaps day of THAProcedure.performed.toInterval ( )
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has Mechanical Complication
    define "Has Mechanical Complication":
      exists ( [Condition: "Mechanical Complications Excluding Upper Body"] MechanicalComplications
          with "Total Hip Arthroplasty Procedure" THAProcedure
            such that MechanicalComplications.prevalenceInterval ( ) overlaps day of THAProcedure.performed.toInterval ( )
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Has More Than One Elective Primary Total Hip Arthroplasty Performed
    define "Has More Than One Elective Primary Total Hip Arthroplasty Performed":
      exists ( "Total Hip Arthroplasty Procedure" THAProcedure
          with ( ( [Procedure: "Primary THA Procedure"] ).isProcedurePerformed ( ) ) ElectiveTHAProcedure
            such that THAProcedure.id !~ ElectiveTHAProcedure.id
              and start of ElectiveTHAProcedure.performed.toInterval ( ) during day of Interval[( start of THAProcedure.performed.toInterval ( ) ) - 1 year, ( start of THAProcedure.performed.toInterval ( ) ) + 1 year]
      )
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Death Within 300 Days of the THA Procedure
    define "Death Within 300 Days of the THA Procedure":
      exists "Total Hip Arthroplasty Procedure" THAProcedure
        where date from Patient.deceased during day of Interval[date from start of THAProcedure.performed.toInterval ( ), date from start of THAProcedure.performed.toInterval ( ) + 300 days]
    Library Name Name
    FunctionalStatusAssessmentforTotalHipReplacementFHIR Denominator Exclusions
    define "Denominator Exclusions":
      Hospice."Has Hospice Services"
        or "Has Severe Cognitive Impairment"
        or "Has Total Hip Arthroplasty with 1 or More Lower Body Fractures"
        or "Has Partial Hip Arthroplasty Procedure"
        or "Has Revision Hip Arthroplasty Procedure or Implanted Device or Prosthesis Removal Procedure"
        or "Has Malignant Neoplasm of Lower and Unspecified Limbs"
        or "Has Mechanical Complication"
        or "Has More Than One Elective Primary Total Hip Arthroplasty Performed"
        or "Death Within 300 Days of the THA Procedure"
    Library Name Name
    Status isProcedurePerformed
    //Procedure, Performed
    define fluent function isProcedurePerformed(Proc List<Procedure>):
      Proc P
        where P.status ~ 'completed'
    Library Name Name
    Status isAssessmentPerformed
    //This library contains functions that are based on QDM 5.6 to QICore 4.1.1 March 2023 (https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns---QICore-v4.1.1). The functions may appear similar to some QICoreCommon functions but different in that they have constraints that are relevant for measures authored by NCQA.
    
    //Assessment, Performed
    define fluent function isAssessmentPerformed(Obs List<Observation>):
      Obs O
        where O.status in { 'final', 'amended', 'corrected' }
              and exists ( O.category ObservationCategory
              where ( ObservationCategory ) ~ "survey"
          )
    Library Name Name
    FHIRHelpers ToConcept
    /*
    @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
            }
    Library Name Name
    Status isEncounterPerformed
    //Encounter, Performed
    //General usage unless required otherwise by measure intent (e.g., follow-up encounters)
    define fluent function isEncounterPerformed(Enc List<Encounter>):
      Enc E
        where E.status in {'finished', 'arrived', 'triaged', 'in-progress', 'onleave'}
    Library Name Name
    QICoreCommon toInterval
    /*
    @description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
    @comment: Normalizes a choice type of DateTime, Quanitty, Interval<DateTime>, or Interval<Quantity> 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 QICore, allowing this function to be used across any resource.
    The input can be provided as a DateTime, Quantity, Interval<DateTime> or Interval<Quantity>.
    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 Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
    and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
    If the input is a DateTime Interval, the result is the input.
    If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
    is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
    immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
    If the input is a Timing, an error will be thrown indicating that Timing calculations are not implemented. Any other input will reslt in a null DateTime Interval
    */
    define fluent function toInterval(choice Choice<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>, Timing>):
      case
    	  when choice is DateTime then
        	Interval[choice as DateTime, choice as DateTime]
    		when choice is Interval<DateTime> then
      		choice as Interval<DateTime>
    		when choice is Quantity then
    		  Interval[Patient.birthDate + (choice as Quantity),
    			  Patient.birthDate + (choice as Quantity) + 1 year)
    		when choice is Interval<Quantity> then
    		  Interval[Patient.birthDate + (choice.low as Quantity),
    			  Patient.birthDate + (choice.high as Quantity) + 1 year)
    		when choice is Timing then
          Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval<DateTime>
    		else
    			null as Interval<DateTime>
    	end
    Library Name Name
    Status isInterventionOrder
    //Intervention, Order: active and completed only    
    define fluent function isInterventionOrder(ServiceRequest List<ServiceRequest>):
      ServiceRequest S
        where S.status in { 'active', 'completed' }
          and S.intent = 'order'
    Library Name Name
    Status isInterventionPerformed
    //Intervention, Performed
    define fluent function isInterventionPerformed(Proc List<Procedure>):
      Proc P
        where P.status ~ 'completed'
    Library Name Name
    QICoreCommon prevalenceInterval
    /*
    @description: Returns an interval representing the normalized prevalence period of a given Condition.
    @comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
    onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting 
    interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
    */
    define fluent function prevalenceInterval(condition Condition):
    if condition.clinicalStatus ~ "active"
      or condition.clinicalStatus ~ "recurrence"
      or condition.clinicalStatus ~ "relapse" then
      Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
    else
        (end of condition.abatementInterval()) abatementDate
        return if abatementDate is null then
          Interval[start of condition.onset.toInterval(), abatementDate)
        else
          Interval[start of condition.onset.toInterval(), abatementDate]