dQM QICore Content Implementation Guide
2025.0.0 - CI Build

dQM QICore Content Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2025.0.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-qicore-2025/ and changes regularly. See the Directory of published versions

Measure: Hospital Harm - Falls with InjuryFHIR

Official URL: https://madie.cms.gov/Measure/CMS1017FHIRHHFI Version: 1.0.000
Active as of 2025-08-25 Responsible: Centers for Medicare & Medicaid Services (CMS) Computable Name: CMS1017FHIRHHFI
Other Identifiers: Short Name: CMS1017FHIR (use: usual, ), UUID:6425d5e9-a54b-40e0-a07d-e6e17137871c (use: official, ), UUID:fd45e28d-9c60-47b3-93df-1a9e96c17795 (use: official, ), Endorser: 4120e (use: official, ), Publisher: 1017FHIR (use: official, )

Copyright/Legal: 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. Mathematica disclaims all liability for use or accuracy of any third-party codes contained in the specifications.

LOINC(R) 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 copyright 2024 World Health Organization. All Rights Reserved.

This ratio measure assesses the number of inpatient hospitalizations where at least one fall with a major or moderate injury occurs among the total qualifying inpatient hospital days for patients aged 18 years and older

Metadata
Title Hospital Harm - Falls with InjuryFHIR
Version 1.0.000
Short Name CMS1017FHIR
GUID (Version Independent) urn:uuid:6425d5e9-a54b-40e0-a07d-e6e17137871c
GUID (Version Specific) urn:uuid:fd45e28d-9c60-47b3-93df-1a9e96c17795
CMS Identifier 1017FHIR
CMS Consensus Based Entity Identifier 4120e
Effective Period 2026-01-01 through 2026-12-31
Steward (Publisher) Centers for Medicare & Medicaid Services (CMS)
Developer Mathematica
Description

This ratio measure assesses the number of inpatient hospitalizations where at least one fall with a major or moderate injury occurs among the total qualifying inpatient hospital days for patients aged 18 years and older

Copyright

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. Mathematica disclaims all liability for use or accuracy of any third-party codes contained in the specifications.

LOINC(R) 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 copyright 2024 World Health Organization. All Rights Reserved.

Disclaimer

This performance measure is not a clinical guideline, does not establish a standard of medical care, and has 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

Inpatient falls are among the most common incidents reported in hospitals and can increase length of stay and patient costs. Due to the potential for serious harm associated with patient falls, "patient death or serious injury associated with a fall while being cared for in a health care setting" is considered a Serious Reportable Event by the National Quality Forum (NQF, 2019).

Falls (including unplanned or unintended descents to the floor) can result in patient injury ranging from minor abrasion or bruising to death as a result of injuries sustained from a fall. While major injuries (e.g., fractures, closed head injuries, internal bleeding) (Mintz et al., 2022) have the biggest impact on patient outcomes, 2008-2021 data findings from the 2022 Network of Patient Safety Databases (NPSD) demonstrated that 41.8 % of falls resulted in moderate injuries such as skin tear, avulsion, hematoma, significant bruising, dislocations and lacerations requiring suturing (AHRQ, 2022). Moderate injury is, as defined by the National Database of Nursing Quality Indicators (NDNQI), that resulted in suturing, application of steri-strips or skin glue, splinting, or muscle/joint strain (NDNQI, 2020). NPSD findings also demonstrated that mild to moderate level of harm represent 24.2.%, 0.4% - severe harm, and 0.1% - death (AHRQ, 2022; WHO, 2009).

By focusing on falls with major and moderate injuries, the goal of this hospital harm dQM is to raise awareness of fall rates and, ultimately, to improve patient safety by preventing falls with injury in all hospital patients. The purpose of measuring the rate of falls with major and moderate injury events is to improve hospitals' practices for monitoring patients at high risk for falls with injury and, in so doing, to reduce the frequency of patient falls with injury.

Clinical Recommendation Statement

Certain protocols and prevention measures to reduce patient falls with injury include using fall risk assessment tools to gauge individual patient risk, implementing fall prevention protocols directed at individual patient risk factors, and implementing environmental rounds to assess and correct environmental fall hazards. Recommended clinical guidelines and practices to reduce falls and injuries from falls in hospitals support many prevention activities including implementing multifactorial interventions and tailoring interventions to individual patient's conditions and needs. The intent and desired outcome for this dQM is to work with existing and recommended falls prevention processes to track falls with injury, and aim to reduce rates of inpatient falls resulting in major injury.

Recommended falls prevention guidelines are:

  • Optimal Perioperative Management of the Geriatric Patient: Best Practices Guideline (ACS NSQIP/AGS, 2016)

  • Falls in older people: assessing risk and prevention (NICE, 2013)

  • Preventing falls and reducing injury from falls (4th edition) (RNAO, 2017)

  • Fall prevention in hospitals and nursing homes: Clinical practice guideline (Schoberer et al., 2022)

  • World guidelines for falls prevention and management for older adults: a global initiative, (Montero-Odasso et al., 2022)

Citation

Mintz, J., Duprey, M. S., Zullo, A. R., Lee, Y., Kiel, D. P., Daiello, L. A., Rodriguez, K. E., Venkatesh, A. K., & Berry, S. D. (2022). Identification of Fall-Related Injuries in Nursing Home Residents Using Administrative Claims Data. The journals of gerontology. Series A, Biological sciences and medical sciences, 77(7), 1421-1429. https://doi.org/10.1093/gerona/glab274

Citation

Mohanty, S., Rosenthal, R.A., Russell, M.M., Neuman, M.D., Ko, C.Y., & Esnaola, N.F. (2016). Optimal Perioperative Management of the Geriatric Patient: Best Practices Guideline from ACS NSQIP/AGS. Journal of the American College of Surgeons 222(5), 930-947. doi: 10.1016/j.jamcollsurg.2015.12.026

Citation

Montero-Odasso, M., van der Velde, N., Martin, F. C., Petrovic, M., Tan, M. P., Ryg, J., Aguilar-Navarro, S., Alexander, N. B., Becker, C., Blain, H., Bourke, R., Cameron, I. D., Camicioli, R., Clemson, L., Close, J., Delbaere, K., Duan, L., Duque, G., Dyer, S. M., ... Rixt Zijlstra, G. A. (2022). World guidelines for falls prevention and management for older adults: a global initiative. Age and Ageing, 51(9), 1-36. https://doi.org/10.1093/ageing/afac205

Citation

National Quality Forum. Serious Reportable Events. http://www.qualityforum.org/topics/sres/serious_reportable_events.aspx. Accessed July 24, 2019

Citation

Network of Patient Safety Databases Chartbook, 2022. Rockville, MD: Agency for Healthcare Research and Quality; September 2022. AHRQ Pub. No. 22-0051

Citation

NICE. (2013). Falls in older people: assessing risk and prevention. London, UK

Citation

Press Ganey Guidelines for Data Collection and Submission Patient Falls Indicator, January 2020

Citation

RNAO. (2017). Preventing falls and reducing injury from falls (4th edition). Toronto, ON

Citation

Schoberer, D., Breimaier, H. E., Zuschnegg, J., Findling, T., Schaffer, S., & Archan, T. (2022). Fall prevention in hospitals and nursing homes: Clinical practice guideline. Worldviews on Evidence-Based Nursing, Vol. 19. https://doi.org/10.1111/wvn.12571

Citation

WHO. (2009). Conceptual Framework for the International Classification for Patient Safety, Version 1.1. https://apps.who.int/iris/bitstream/handle/10665/70882/WHO_IER_PSP_2010.2_eng.pdf

Guidance (Usage)

Hospital days are measured in 24-hour periods starting from the time of arrival at the hospital (including time in the Emergency Department and or Observation). The number of days will be counted as whole numbers; any fractional periods are dropped. For example, an eligible encounter with a length of stay of 75 hours will be measured as 3 days (72 hours).

This measure includes two measure observations used to calculate the ratio of the number of encounters with a fall over the total number of eligible hospital days. The ratio is reported as the rate of inpatient hospitalizations with falls with moderate or major injury per 1000 patient days.

To express the rate of inpatient hospitalizations with falls with moderate or major injury per 1,000 patient days, the following calculation is applied post-production during implementation: (Total number of encounters with falls with moderate or major injury / Total number of eligible hospital days) x 1000 = rate. Example: 1 eligible encounter with a patient fall with moderate or major injury over 120 eligible days (1/120) x 1000 = 8.33.

In ratio measures, both the Denominator and Numerator populations flow separately from the same Initial Population. Therefore, the same exclusion criteria must be applied to both the Denominator and Numerator to prevent excluded cases from being considered.

This dQM is an episode-based measure. An episode is defined as each inpatient hospitalization or encounter that ends during the measurement period.

This FHIR-based measure has been derived from the QDM-based measure: CMS1017v2. 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 Encounter
Scoring [http://terminology.hl7.org/CodeSystem/measure-scoring#ratio: 'Ratio']
Type [http://terminology.hl7.org/CodeSystem/measure-type#outcome: 'Outcome']
Rate Aggregation

None

Improvement Notation [http://terminology.hl7.org/CodeSystem/measure-improvement-notation#decrease: 'Decreased score indicates improvement']
Initial Population ID: InitialPopulation_1
Description:

Inpatient hospitalizations for patients aged 18 years and older with a length of stay less than or equal to 120 days that ends during the measurement period

Logic Definition: Initial Population
Denominator ID: Denominator_1
Description:

Equals Initial Population

Logic Definition: Denominator
Denominator Exclusion ID: DenominatorExclusion_1
Description:

Inpatient hospitalizations where the patient has a fall diagnosis present on admission.

Logic Definition: Denominator Exclusions
Numerator ID: Numerator_1
Description:

Inpatient hospitalizations where the patient has a fall that results in a major or moderate injury during the encounter.

The diagnosis of a major or moderate injury must not be present on admission.

Logic Definition: Numerator
Numerator Exclusion ID: NumeratorExclusion_1
Description:

Inpatient hospitalizations where the patient has a fall diagnosis present on admission

Logic Definition: Numerator Exclusions
Measure Observation ID: MeasureObservation_1_1
Description:

Denominator Observation, associated with the Denominator: The total number of eligible days across all encounters which match the initial population/denominator criteria.

Logic Definition: Denominator Observation
Measure Observation ID: MeasureObservation_1_2
Description:

Numerator Observation, associated with the Numerator: The total number of inpatient hospitalizations where a fall with major or moderate injury occurred, across all eligible encounters.

Logic Definition: Numerator Observation
Supplemental Data Guidance

For every patient evaluated by this measure also identify payer, race, ethnicity and sex

Supplemental Data Guidance

Variables being collected for the development of baseline risk adjustment model include encounters with:

Medications active on admission such as:

  • anticoagulants
  • antidepressants
  • antihypertensives
  • central nervous system depressant medications
  • diuretics
  • opioids

Medications administered during the hospitalization, such as anticoagulants

Diagnoses present on admission which may increase the risk for a fall with injury, such as:

  • abnormal weight loss or malnutrition
  • coagulation disorders
  • delirium, dementia, or other psychosis
  • depression
  • epilepsy
  • leukemia or lymphoma
  • liver disease (moderate to severe)
  • malignant bone disease
  • neurologic movement and related disorders
  • obesity
  • osteoporosis
  • peripheral neuropathy
  • stroke
  • suicide attempt

Physical traits, such as body mass index (BMI)

All encounter diagnoses along with their rank (e.g., 1 = principal, 2 = secondary) and present on admission (POA) indicators are being collected for the development of baseline risk adjustment model.

Supplemental Data Elements
Supplemental Data Element ID: sde-ethnicity
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Ethnicity
Logic Definition: SDE Ethnicity
Supplemental Data Element ID: sde-payer
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Payer
Logic Definition: SDE Payer
Supplemental Data Element ID: sde-race
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Race
Logic Definition: SDE Race
Supplemental Data Element ID: sde-sex
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#supplemental-data]
Description: SDE Sex
Logic Definition: SDE Sex
Supplemental Data Element ID: risk-variable-body-mass-index-(bmi)
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Body Mass Index (BMI)
Logic Definition: Risk Variable Body Mass Index (BMI)
Supplemental Data Element ID: risk-variable-all-encounter-diagnoses-with-rank-and-poa-indication
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable All Encounter Diagnoses with Rank and POA Indication
Logic Definition: Risk Variable All Encounter Diagnoses with Rank and POA Indication
Supplemental Data Element ID: risk-variable-encounter-with-abnormal-weight-loss-or-malnutrition-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Abnormal Weight Loss or Malnutrition Present on Admission
Logic Definition: Risk Variable Encounter with Abnormal Weight Loss or Malnutrition Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-anticoagulant-active-at-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Anticoagulant Active at Admission
Logic Definition: Risk Variable Encounter with Anticoagulant Active at Admission
Supplemental Data Element ID: risk-variable-encounter-with-anticoagulant-administration-during-encounter
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Anticoagulant Administration During Encounter
Logic Definition: Risk Variable Encounter with Anticoagulant Administration During Encounter
Supplemental Data Element ID: risk-variable-encounter-with-antidepressant-active-at-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Antidepressant Active at Admission
Logic Definition: Risk Variable Encounter with Antidepressant Active at Admission
Supplemental Data Element ID: risk-variable-encounter-with-antihypertensive-active-at-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Antihypertensive Active at Admission
Logic Definition: Risk Variable Encounter with Antihypertensive Active at Admission
Supplemental Data Element ID: risk-variable-encounter-with-cns-depressant-active-at-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with CNS Depressant Active at Admission
Logic Definition: Risk Variable Encounter with CNS Depressant Active at Admission
Supplemental Data Element ID: risk-variable-encounter-with-diuretic-active-at-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Diuretic Active at Admission
Logic Definition: Risk Variable Encounter with Diuretic Active at Admission
Supplemental Data Element ID: risk-variable-encounter-with-opioid-medication-active-at-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Opioid Medication Active at Admission
Logic Definition: Risk Variable Encounter with Opioid Medication Active at Admission
Supplemental Data Element ID: risk-variable-encounter-with-coagulation-disorder-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Coagulation Disorder Present on Admission
Logic Definition: Risk Variable Encounter with Coagulation Disorder Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-depression-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Depression Present on Admission
Logic Definition: Risk Variable Encounter with Depression Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-delirium-or-dementia-or-other-psychosis-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Delirium or Dementia or Other Psychosis Present on Admission
Logic Definition: Risk Variable Encounter with Delirium or Dementia or Other Psychosis Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-epilepsy-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Epilepsy Present on Admission
Logic Definition: Risk Variable Encounter with Epilepsy Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-leukemia-or-lymphoma-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Leukemia or Lymphoma Present on Admission
Logic Definition: Risk Variable Encounter with Leukemia or Lymphoma Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-liver-disease-moderate-to-severe-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Liver Disease Moderate to Severe Present on Admission
Logic Definition: Risk Variable Encounter with Liver Disease Moderate to Severe Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-malignant-bone-disease-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Malignant Bone Disease Present on Admission
Logic Definition: Risk Variable Encounter with Malignant Bone Disease Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-neurologic-disorder-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Neurologic Disorder Present on Admission
Logic Definition: Risk Variable Encounter with Neurologic Disorder Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-obesity-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Obesity Present on Admission
Logic Definition: Risk Variable Encounter with Obesity Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-osteoporosis-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Osteoporosis Present on Admission
Logic Definition: Risk Variable Encounter with Osteoporosis Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-peripheral-neuropathy-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Peripheral Neuropathy Present on Admission
Logic Definition: Risk Variable Encounter with Peripheral Neuropathy Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-stroke-present-on-admission
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Stroke Present on Admission
Logic Definition: Risk Variable Encounter with Stroke Present on Admission
Supplemental Data Element ID: risk-variable-encounter-with-suicide-attempt
Usage Code: [http://terminology.hl7.org/CodeSystem/measure-data-usage#risk-adjustment-factor]
Description: Risk Variable Encounter with Suicide Attempt
Logic Definition: Risk Variable Encounter with Suicide Attempt
Measure Logic
Primary Library https://madie.cms.gov/Library/CMS1017FHIRHHFI
Contents Population Criteria
Logic Definitions
Terminology
Dependencies
Data Requirements
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
define "Initial Population":
  "Qualifying Encounter"
Denominator
define "Denominator":
  "Initial Population"
Denominator Exclusion
define "Denominator Exclusions":
  "Encounter With A Fall Present On Admission"
Numerator
define "Numerator":
  "Encounter Where A Fall And Major Injury Occurred Not POA"
    union "Encounter Where A Fall And Moderate Injury Occurred Not POA"
Numerator Exclusion
define "Numerator Exclusions":
  "Encounter With A Fall Present On Admission"
Measure Observation
define function "Denominator Observation"(QualifyingEncounter Encounter):
  duration in days of QualifyingEncounter.hospitalizationWithObservation ( )
Measure Observation
define function "Numerator Observation"(QualifyingEncounter Encounter):
  Count("Numerator" FallsEncounter
      where FallsEncounter.period ends during QualifyingEncounter.hospitalizationWithObservation()
  )
Logic Definitions
Logic Definition Library Name: SupplementalDataElements
define "SDE Payer":
  [Coverage: type in "Payer Type"] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }
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: 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 Ethnicity":
  Patient.ethnicity E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }
Logic Definition Library Name: CQMCommon
define "Inpatient Encounter":
  [Encounter: "Encounter Inpatient"] EncounterInpatient
    where EncounterInpatient.status = 'finished'
      and EncounterInpatient.period ends during day of "Measurement Period"
Logic Definition Library Name: CQMCommon
/*
@description: Calculates the difference in calendar days between the start and end of the given interval.
*/
define fluent function lengthInDays(Value Interval<DateTime> ):
  difference in days between start of Value and end of Value
Logic Definition Library Name: CQMCommon
/*
@description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
*/
define fluent function hospitalizationWithObservation(TheEncounter Encounter ):
  TheEncounter Visit
  		let ObsVisit: Last([Encounter: "Observation Services"] LastObs
  				where LastObs.status = 'finished'
            and LastObs.period ends 1 hour or less on or before start of Visit.period
  				sort by end of period
  			),
  			VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),
  			EDVisit: Last([Encounter: "Emergency Department Visit"] LastED
  				where LastED.status = 'finished'
            and LastED.period ends 1 hour or less on or before VisitStart
  				sort by end of period
  			)
  		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]
Logic Definition Library Name: CQMCommon
/*
 @description: Returns true if the given diagnosis is present on admission, based on the given poaValueSet
 @comment: See the QICore 6 Authoring Patterns discussion on [Principal Diagnosis and Present on Admission](https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns-QICore-v6.0.0#conditions-present-on-admission-and-principal-diagnoses) for more information
 */
 define fluent function isDiagnosisPresentOnAdmission(encounter Encounter, diagnosisValueSet ValueSet, poaValueSet ValueSet):
   exists (
     (encounter.claimDiagnosis()) CD
       where CD.onAdmission in poaValueSet
         and (
           CD.diagnosis in diagnosisValueSet
             or CD.diagnosis.getCondition().code in diagnosisValueSet
         )
   )
Logic Definition Library Name: CQMCommon
/*
@description: Returns the claim diagnosis elements for the given encounter
@comment: See the QICore 6 Authoring Patterns discussion on [Principal Diagnosis and Present on Admission](https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns-QICore-v6.0.0#conditions-present-on-admission-and-principal-diagnoses) for more information
*/
define fluent function claimDiagnosis(encounter Encounter):
  encounter E
    let 
      claim: ([Claim] C where C.status = 'active' and C.use = 'claim' and exists (C.item I where I.encounter.references(E))),
      claimItem: (claim.item I where I.encounter.references(E))
    return claim.diagnosis D where D.sequence in claimItem.diagnosisSequence
Logic Definition Library Name: CQMCommon
/*
@description: Returns the Condition resource for the given reference
*/
define fluent function getCondition(reference Reference):
  singleton from (([ConditionEncounterDiagnosis] union [ConditionProblemsHealthConcerns]) C where reference.references(C.id))
Logic Definition Library Name: QICoreCommon
/*
@description: Returns true if any of the given references are to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of any of the given references.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(references List<Reference>, resource Resource):
  exists (references R where R.references(resource))
Logic Definition Library Name: QICoreCommon
/*
@description: Returns true if the given reference is to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference Reference, resource Resource):
  resource.id = Last(Split(reference.reference, '/'))
Logic Definition Library Name: QICoreCommon
/*
@description: Returns true if the given reference is to the given resourceId
@comment: Returns true if the `resourceId` parameter exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference Reference, resourceId String):
  resourceId = Last(Split(reference.reference, '/'))
Logic Definition Library Name: QICoreCommon
/*
@description: Returns the tail of the given uri (i.e. everything after the last slash in the URI).
@comment: This function can be used to determine the logical id of a given resource. It can be used in
a single-server environment to trace references. However, this function does not attempt to resolve
or distinguish the base of the given url, and so cannot be used safely in multi-server environments.
*/
define fluent function getId(uri String):
  Last(Split(uri, '/'))
Logic Definition Library Name: QICoreCommon
/*
@description: Returns true if the given MedicationRequest has a category of Community
*/
define fluent function isCommunity(medicationRequest Choice<MedicationRequest, MedicationNotRequested>):
  exists (medicationRequest.category C
    where C ~ Community
  )
Logic Definition Library Name: CumulativeMedicationDuration
define fluent function medicationRequestPeriod(Request "MedicationRequest"):
  Request R
    let
      dosage: singleton from R.dosageInstruction,
      doseAndRate: singleton from dosage.doseAndRate,
      timing: dosage.timing,
      frequency: Coalesce(timing.repeat.frequencyMax, timing.repeat.frequency),
      period: Quantity(timing.repeat.period, timing.repeat.periodUnit),
      doseRange: doseAndRate.dose,
      doseQuantity: doseAndRate.dose,
      dose: Coalesce(end of doseRange, doseQuantity),
      dosesPerDay: Coalesce(ToDaily(frequency, period), Count(timing.repeat.timeOfDay), 1.0),
      boundsPeriod: timing.repeat.bounds as Interval<DateTime>,
      daysSupply: (convert R.dispenseRequest.expectedSupplyDuration to days).value,
      quantity: R.dispenseRequest.quantity,
      refills: Coalesce(R.dispenseRequest.numberOfRepeatsAllowed, 0),
      startDate:
        Coalesce(
          date from start of boundsPeriod,
          date from R.authoredOn,
          date from start of R.dispenseRequest.validityPeriod
        ),
      totalDaysSupplied: Coalesce(daysSupply, quantity.value / (dose.value * dosesPerDay)) * (1 + refills)
    return
      if startDate is not null and totalDaysSupplied is not null then
        Interval[startDate, startDate + Quantity(totalDaysSupplied - 1, 'day') ]
      else if startDate is not null and boundsPeriod."high" is not null then
        Interval[startDate, date from end of boundsPeriod]
      else
        null
Logic Definition Library Name: CumulativeMedicationDuration
/**********************************************************************/
/* Functions in this region are copied from opioid-mme-r4             */
/**********************************************************************/

define function Quantity(value Decimal, unit String):
  if value is not null then
    System.Quantity { value: value, unit: unit }
  else
    null
Logic Definition Library Name: CumulativeMedicationDuration
/*
 Goal is to get to number of days
 Two broad approaches to the calculation:
  1) Based on supply and frequency, calculate the number of expected days the medication will cover/has covered
  2) Based on relevant period, determine a covered interval and calculate the length of that interval in days
This topic covers several use cases and illustrates how to calculate Cumulative
Medication Duration for each type of medication resource using the supply and
frequency approach.
*/

/*
  For the first approach, we need to get from frequency to a frequency/day
  So we define ToDaily
*/

/*
  Calculates daily frequency given frequency within a period
*/
define function ToDaily(frequency System.Integer, period System.Quantity):
  case period.unit
    when 'h' then frequency * (24.0 / period.value)
    when 'min' then frequency * (24.0 / period.value) * 60
    when 's' then frequency * (24.0 / period.value) * 60 * 60
    when 'd' then frequency * (24.0 / period.value) / 24
    when 'wk' then frequency * (24.0 / period.value) / (24 * 7)
    when 'mo' then frequency * (24.0 / period.value) / (24 * 30) /* assuming 30 days in month */
    when 'a' then frequency * (24.0 / period.value) / (24 * 365) /* assuming 365 days in year */
    when 'hour' then frequency * (24.0 / period.value)
    when 'minute' then frequency * (24.0 / period.value) * 60
    when 'second' then frequency * (24.0 / period.value) * 60 * 60
    when 'day' then frequency * (24.0 / period.value) / 24
    when 'week' then frequency * (24.0 / period.value) / (24 * 7)
    when 'month' then frequency * (24.0 / period.value) / (24 * 30) /* assuming 30 days in month */
    when 'year' then frequency * (24.0 / period.value) / (24 * 365) /* assuming 365 days in year */
    when 'hours' then frequency * (24.0 / period.value)
    when 'minutes' then frequency * (24.0 / period.value) * 60
    when 'seconds' then frequency * (24.0 / period.value) * 60 * 60
    when 'days' then frequency * (24.0 / period.value) / 24
    when 'weeks' then frequency * (24.0 / period.value) / (24 * 7)
    when 'months' then frequency * (24.0 / period.value) / (24 * 30) /* assuming 30 days in month */
    when 'years' then frequency * (24.0 / period.value) / (24 * 365) /* assuming 365 days in year */
    else Message(null, true, 'CMDLogic.ToDaily.UnknownUnit', ErrorLevel, 'Unknown unit ' & period.unit)
  end
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
/*
@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 uri): value.value
Logic Definition Library Name: CMS1017FHIRHHFI
define "Qualifying Encounter":
  CQMCommon."Inpatient Encounter" InpatientEncounter
    where InpatientEncounter.hospitalizationWithObservation ( ).lengthInDays ( ) <= 120
      and AgeInYearsAt(date from start of InpatientEncounter.period) >= 18
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Osteoporosis Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Osteoporosis", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Coagulation Disorder Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Coagulation Disorders", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Antidepressant Active at Admission":
  "Qualifying Encounter" InpatientEncounter
    with ["MedicationRequest": "Antidepressants"] AntidepressantMed
      such that AntidepressantMed.status in { 'active', 'completed' }
        and ( AntidepressantMed.intent = 'order'
            or ( AntidepressantMed.intent = 'plan'
                and AntidepressantMed.subject.reference.getId ( ) = Patient.id
            )
        )
        and AntidepressantMed.isCommunity ( )
        and AntidepressantMed.medicationRequestPeriod ( ) overlaps before day of InpatientEncounter.period
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable All Encounter Diagnoses with Rank and POA Indication":
  from
    "Qualifying Encounter" InpatientEncounter
    let claim: ( [Claim] C
        where C.status = 'active'
          and C.use = 'claim'
          and exists ( C.item ClaimItem
              where ClaimItem.encounter.references ( InpatientEncounter )
          )
    ),
    claimItem: ( claim.item ClaimItem
        where ClaimItem.encounter.references ( InpatientEncounter )
    )
    return Tuple {
      encounterId: InpatientEncounter.id,
      diagnosis: claim.diagnosis,
      rank: claim.diagnosis.sequence,
      POA: claim.diagnosis Diag
        where Diag.onAdmission in "Present on Admission or Clinically Undetermined"
          or Diag.onAdmission in "Not Present On Admission or Documentation Insufficient to Determine"
    }
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Leukemia or Lymphoma Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Leukemia or Lymphoma", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Obesity Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Obesity", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Peripheral Neuropathy Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Peripheral Neuropathy", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Delirium or Dementia or Other Psychosis Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Delirium, Dementia, and Other Psychoses", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Suicide Attempt":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.encountersDiagnosis ( ).code in "Suicide Attempt"
Logic Definition Library Name: CMS1017FHIRHHFI
define "SDE Payer":
  SDE."SDE Payer"
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Liver Disease Moderate to Severe Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Liver Disease Moderate to Severe", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Initial Population":
  "Qualifying Encounter"
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Anticoagulant Administration During Encounter":
  "Qualifying Encounter" InpatientEncounter
    with ["MedicationAdministration": "Anticoagulants for All Indications"] Anticoagulants
      such that Anticoagulants.effective.toInterval ( ) starts during InpatientEncounter.hospitalizationWithObservation ( )
        and Anticoagulants.status in { 'in-progress', 'completed' }
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Neurologic Disorder Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Neurologic Movement and Related Disorders", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Abnormal Weight Loss or Malnutrition Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Abnormal Weight Loss", "Present on Admission or Clinically Undetermined" )
      or InpatientEncounter.isDiagnosisPresentOnAdmission ( "Malnutrition", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Anticoagulant Active at Admission":
  "Qualifying Encounter" InpatientEncounter
    with ["MedicationRequest": "Anticoagulants for All Indications"] Anticoagulants
      such that Anticoagulants.status in { 'active', 'completed' }
        and ( Anticoagulants.intent = 'order'
            or ( Anticoagulants.intent = 'plan'
                and Anticoagulants.subject.reference.getId ( ) = Patient.id
            )
        )
        and Anticoagulants.isCommunity ( )
        and Anticoagulants.medicationRequestPeriod ( ) overlaps before day of InpatientEncounter.period
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Body Mass Index (BMI)":
  from
    ["USCoreBMIProfile"] BMI
    with "Qualifying Encounter" InpatientEncounter
      such that BMI.effective.toInterval ( ) starts during InpatientEncounter.hospitalizationWithObservation ( )
        and BMI.value is not null
        and BMI.status in { 'final', 'amended', 'corrected' }
    return BMI.value as Quantity
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Depression Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Depression", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Epilepsy Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Epilepsy", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Diuretic Active at Admission":
  "Qualifying Encounter" InpatientEncounter
    with ["MedicationRequest": "Diuretics"] DiureticMed
      such that DiureticMed.status in { 'active', 'completed' }
        and ( DiureticMed.intent = 'order'
            or ( DiureticMed.intent = 'plan'
                and DiureticMed.subject.reference.getId ( ) = Patient.id
            )
        )
        and DiureticMed.isCommunity ( )
        and DiureticMed.medicationRequestPeriod ( ) overlaps before day of InpatientEncounter.period
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with CNS Depressant Active at Admission":
  "Qualifying Encounter" InpatientEncounter
    with ["MedicationRequest": "Central Nervous System Depressants"] CNSMed
      such that CNSMed.status in { 'active', 'completed' }
        and ( CNSMed.intent = 'order'
            or ( CNSMed.intent = 'plan'
                and CNSMed.subject.reference.getId ( ) = Patient.id
            )
        )
        and CNSMed.isCommunity ( )
        and CNSMed.medicationRequestPeriod ( ) overlaps before day of InpatientEncounter.period
Logic Definition Library Name: CMS1017FHIRHHFI
define "SDE Race":
  SDE."SDE Race"
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Malignant Bone Disease Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Malignant Bone Disease", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "SDE Sex":
  SDE."SDE Sex"
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Antihypertensive Active at Admission":
  "Qualifying Encounter" InpatientEncounter
    with ["MedicationRequest": "Antihypertensives"] BPMed
      such that BPMed.status in { 'active', 'completed' }
        and ( BPMed.intent = 'order'
            or ( BPMed.intent = 'plan'
                and BPMed.subject.reference.getId ( ) = Patient.id
            )
        )
        and BPMed.isCommunity ( )
        and BPMed.medicationRequestPeriod ( ) overlaps before day of InpatientEncounter.period
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Opioid Medication Active at Admission":
  "Qualifying Encounter" InpatientEncounter
    with ["MedicationRequest": "Opioids"] OpioidMed
      such that OpioidMed.status in { 'active', 'completed' }
        and ( OpioidMed.intent = 'order'
            or ( OpioidMed.intent = 'plan'
                and OpioidMed.subject.reference.getId ( ) = Patient.id
            )
        )
        and OpioidMed.isCommunity ( )
        and OpioidMed.medicationRequestPeriod ( ) overlaps before day of InpatientEncounter.period
Logic Definition Library Name: CMS1017FHIRHHFI
define "Encounter With A Fall Diagnosis":
  "Qualifying Encounter" QualifyingFall
    where QualifyingFall.reasonCode in "Inpatient Falls"
      or QualifyingFall.encountersDiagnosis ( ).code in "Inpatient Falls"
Logic Definition Library Name: CMS1017FHIRHHFI
define "Encounter With A Fall Event":
  "Qualifying Encounter" InpatientEncounter
    with [AdverseEvent: "Inpatient Falls"] FallsDocumentation
      such that Coalesce(FallsDocumentation.date, FallsDocumentation.recordedDate) during InpatientEncounter.hospitalizationWithObservation ( )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Encounter Where A Fall Occurred":
  "Encounter With A Fall Diagnosis" EncounterFallDiagnosis
    union "Encounter With A Fall Event" EncounterFallEvent
Logic Definition Library Name: CMS1017FHIRHHFI
define "Encounter With A Fall Not Present On Admission":
  "Encounter Where A Fall Occurred" EncounterFallDiagnosis
    where EncounterFallDiagnosis.hasDiagnosisNotPresentOnAdmissionOrNull ( "Inpatient Falls" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Encounter Where A Fall And Major Injury Occurred Not POA":
  "Encounter With A Fall Not Present On Admission" FallOccurred
    where exists ( ( FallOccurred.claimDiagnosis ( ) ) MajorFallOccurred
        where ( MajorFallOccurred.onAdmission is null
            or MajorFallOccurred.onAdmission in "Not Present On Admission or Documentation Insufficient to Determine"
        )
          and ( MajorFallOccurred.diagnosis in "Major Injuries"
              or MajorFallOccurred.diagnosis.getCondition ( ).code in "Major Injuries"
          )
    )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Encounter Where A Fall And Moderate Injury Occurred Not POA":
  "Encounter With A Fall Not Present On Admission" FallOccurred
    where exists ( ( FallOccurred.claimDiagnosis ( ) ) ModerateFallOccurred
        where ( ModerateFallOccurred.onAdmission is null
            or ModerateFallOccurred.onAdmission in "Not Present On Admission or Documentation Insufficient to Determine"
        )
          and ( ModerateFallOccurred.diagnosis in "Moderate Injuries"
              or ModerateFallOccurred.diagnosis.getCondition ( ).code in "Moderate Injuries"
          )
    )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Numerator":
  "Encounter Where A Fall And Major Injury Occurred Not POA"
    union "Encounter Where A Fall And Moderate Injury Occurred Not POA"
Logic Definition Library Name: CMS1017FHIRHHFI
define "Denominator":
  "Initial Population"
Logic Definition Library Name: CMS1017FHIRHHFI
define "Encounter With A Fall Present On Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Inpatient Falls", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define "Numerator Exclusions":
  "Encounter With A Fall Present On Admission"
Logic Definition Library Name: CMS1017FHIRHHFI
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
Logic Definition Library Name: CMS1017FHIRHHFI
define "Denominator Exclusions":
  "Encounter With A Fall Present On Admission"
Logic Definition Library Name: CMS1017FHIRHHFI
define "Risk Variable Encounter with Stroke Present on Admission":
  "Qualifying Encounter" InpatientEncounter
    where InpatientEncounter.isDiagnosisPresentOnAdmission ( "Stroke", "Present on Admission or Clinically Undetermined" )
Logic Definition Library Name: CMS1017FHIRHHFI
define fluent function encountersDiagnosis(Encounter Encounter):
  Encounter.reasonReference EncDiag
    return singleton from ( ( [ConditionEncounterDiagnosis] ConditionED
        union [ConditionProblemsHealthConcerns] ConditionPHC ) Cond
        where EncDiag.references ( Cond.id )
    )
Logic Definition Library Name: CMS1017FHIRHHFI
define function "Denominator Observation"(QualifyingEncounter Encounter):
  duration in days of QualifyingEncounter.hospitalizationWithObservation ( )
Logic Definition Library Name: CMS1017FHIRHHFI
define fluent function hasDiagnosisNotPresentOnAdmissionOrNull(encounter Encounter, diagnosisValueSet ValueSet):
  exists ( [Claim] C
      where C.status = 'active'
        and C.use = 'claim'
        and exists ( C.item I
            where I.encounter.references ( encounter )
        )
      return C.diagnosis D
        where exists ( C.item I
            where I.encounter.references ( encounter )
              and D.sequence in I.diagnosisSequence
        )
          and ( D.onAdmission is null
              or D.onAdmission in "Not Present On Admission or Documentation Insufficient to Determine"
          )
          and D.diagnosis in diagnosisValueSet
  )
Logic Definition Library Name: CMS1017FHIRHHFI
define function "Numerator Observation"(QualifyingEncounter Encounter):
  Count("Numerator" FallsEncounter
      where FallsEncounter.period ends during QualifyingEncounter.hospitalizationWithObservation()
  )
Terminology
Code System Description: Code system MedicationRequestCategory
Resource: http://terminology.hl7.org/CodeSystem/medicationrequest-category
Canonical URL: http://terminology.hl7.org/CodeSystem/medicationrequest-category
Code System Description: Code system SNOMEDCT
Resource: http://snomed.info/sct
Canonical URL: http://snomed.info/sct
Value Set Description: Value set Encounter Inpatient
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Value Set Description: Value set Observation Services
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Value Set Description: Value set Emergency Department Visit
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Value Set Description: Value set Osteoporosis
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1200.147
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1200.147
Value Set Description: Value set Present on Admission or Clinically Undetermined
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.197
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.197
Value Set Description: Value set Coagulation Disorders
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.23
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.23
Value Set Description: Value set Antidepressants
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.163
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.163
Value Set Description: Value set Not Present On Admission or Documentation Insufficient to Determine
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.198
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.198
Value Set Description: Value set Leukemia or Lymphoma
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.136
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.136
Value Set Description: Value set Obesity
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.162
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.162
Value Set Description: Value set Peripheral Neuropathy
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.175
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.175
Value Set Description: Value set Delirium, Dementia, and Other Psychoses
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.168
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.168
Value Set Description: Value set Suicide Attempt
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.130
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.130
Value Set Description: Value set Payer Type
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Value Set Description: Value set Liver Disease Moderate to Severe
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.137
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.137
Value Set Description: Value set Anticoagulants for All Indications
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.22
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.22
Value Set Description: Value set Neurologic Movement and Related Disorders
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.174
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.174
Value Set Description: Value set Abnormal Weight Loss
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1258.2
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1258.2
Value Set Description: Value set Malnutrition
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1272.1
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1272.1
Value Set Description: Value set Depression
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.169
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.169
Value Set Description: Value set Epilepsy
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.171
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.171
Value Set Description: Value set Diuretics
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.170
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.170
Value Set Description: Value set Central Nervous System Depressants
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.134
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.134
Value Set Description: Value set Malignant Bone Disease
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.24
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.24
Value Set Description: Value set Antihypertensives
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.164
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.164
Value Set Description: Value set Opioids
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.120
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.120
Value Set Description: Value set Inpatient Falls
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.171
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.171
Value Set Description: Value set Major Injuries
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.120
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.120
Value Set Description: Value set Moderate Injuries
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.205
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.205
Value Set Description: Value set Stroke
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.176
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.176
Direct Reference Code Display: Community
Code: community
System: http://terminology.hl7.org/CodeSystem/medicationrequest-category
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
Dependencies
Dependency Description: QICore model information
Resource: http://hl7.org/fhir/Library/QICore-ModelInfo
Canonical URL: http://hl7.org/fhir/Library/QICore-ModelInfo
Dependency Description: Library CQMCommon
Resource: https://madie.cms.gov/Library/CQMCommon|4.1.000
Canonical URL: https://madie.cms.gov/Library/CQMCommon|4.1.000
Dependency Description: Library FHIRHelpers
Resource: https://madie.cms.gov/Library/FHIRHelpers|4.4.000
Canonical URL: https://madie.cms.gov/Library/FHIRHelpers|4.4.000
Dependency Description: Library QICoreCommon
Resource: https://madie.cms.gov/Library/QICoreCommon|4.0.000
Canonical URL: https://madie.cms.gov/Library/QICoreCommon|4.0.000
Dependency Description: Library CMD
Resource: https://madie.cms.gov/Library/CumulativeMedicationDuration|6.0.000
Canonical URL: https://madie.cms.gov/Library/CumulativeMedicationDuration|6.0.000
Dependency Description: Library SDE
Resource: https://madie.cms.gov/Library/SupplementalDataElements|5.1.000
Canonical URL: https://madie.cms.gov/Library/SupplementalDataElements|5.1.000
Data Requirements
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, status, status.value, period, onAdmission, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, status, status.value, period, onAdmission, diagnosis, diagnosis.code
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, status, status.value, period, onAdmission, diagnosis, diagnosis.code, id, id.value, reasonCode
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Must Support Elements: id, id.value, url, extension
Data Requirement Type: Resource
Profile(s): http://hl7.org/fhir/StructureDefinition/Resource
Must Support Elements: id, id.value
Data Requirement Type: Claim
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-claim
Must Support Elements: status, status.value, use, use.value, item, diagnosis
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-encounter-diagnosis
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, dispenseRequest.numberOfRepeatsAllowed.value, authoredOn, authoredOn.value, dispenseRequest.validityPeriod, status, status.value, intent, intent.value, subject, subject.reference, subject.reference.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.163
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, dispenseRequest.numberOfRepeatsAllowed.value, authoredOn, authoredOn.value, dispenseRequest.validityPeriod, status, status.value, intent, intent.value, subject, subject.reference, subject.reference.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.22
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, dispenseRequest.numberOfRepeatsAllowed.value, authoredOn, authoredOn.value, dispenseRequest.validityPeriod, status, status.value, intent, intent.value, subject, subject.reference, subject.reference.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.170
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, dispenseRequest.numberOfRepeatsAllowed.value, authoredOn, authoredOn.value, dispenseRequest.validityPeriod, status, status.value, intent, intent.value, subject, subject.reference, subject.reference.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.134
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, dispenseRequest.numberOfRepeatsAllowed.value, authoredOn, authoredOn.value, dispenseRequest.validityPeriod, status, status.value, intent, intent.value, subject, subject.reference, subject.reference.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.164
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, dispenseRequest.numberOfRepeatsAllowed.value, authoredOn, authoredOn.value, dispenseRequest.validityPeriod, status, status.value, intent, intent.value, subject, subject.reference, subject.reference.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.120
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Must Support Elements: medication.reference.value, dosageInstruction, dispenseRequest, dispenseRequest.expectedSupplyDuration, dispenseRequest.quantity, dispenseRequest.numberOfRepeatsAllowed, dispenseRequest.numberOfRepeatsAllowed.value, authoredOn, authoredOn.value, dispenseRequest.validityPeriod, status, status.value, intent, intent.value, subject, subject.reference, subject.reference.value
Data Requirement Type: Medication
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication
Must Support Elements: id.value, code
Data Requirement Type: Coverage
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Data Requirement Type: MedicationAdministration
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration
Must Support Elements: medication, effective, status, status.value
Code Filter(s):
Path: medication
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1248.22
Data Requirement Type: MedicationAdministration
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration
Must Support Elements: medication.reference.value, effective, status, status.value
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/core/StructureDefinition/us-core-bmi
Must Support Elements: effective, value, status, status.value
Data Requirement Type: AdverseEvent
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-adverseevent
Must Support Elements: event, date, date.value, recordedDate, recordedDate.value
Code Filter(s):
Path: event
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1147.171
Generated using version 0.4.8 of the sample-content-ig Liquid templates