Chronic Disease Surveillance
0.1.0 - CI Build International flag

Chronic Disease Surveillance, published by Clinical Quality Framework. This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/aphl-chronic-ig/ and changes regularly. See the Directory of published versions

Library: AdvancedIllnessandFrailtyExclusionECQMFHIR4

Official URL: http://fhir.org/guides/cqf/aphl/chronic-ds/Library/AdvancedIllnessandFrailtyExclusionECQMFHIR4 Version: 0.1.0
Active as of 2021-01-08 Computable Name: AdvancedIllnessandFrailtyExclusionECQMFHIR4

Frailty Exclusion

Id: AdvancedIllnessandFrailtyExclusionECQMFHIR4
Version: 0.1.0
Url: AdvancedIllnessandFrailtyExclusionECQMFHIR4
Type:

system: http://terminology.hl7.org/CodeSystem/library-type

code: logic-library

Date: 2021-01-08 13:45:35+0000
Publisher: Clinical Quality Framework
Description:

Frailty Exclusion

Jurisdiction: 001
Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
Measurement PeriodPeriod01In
PatientPatient01Out
Up To One Year Prior Including Measurement PeriodPeriod01Out
Has Criteria Indicating Frailtyboolean01Out
Outpatient Encounters With Advanced IllnessEncounter0*Out
Has Two Outpatient Encounters With Advanced Illness on Different Dates of ServiceEncounter0*Out
Has Inpatient Encounter With Advanced IllnessEncounter0*Out
Has Dementia Medications In Year Before or During Measurement PeriodMedicationRequest0*Out
Is Age 66 or Older with Advanced Illness and Frailtyboolean01Out
Is Age 66 to 80 with Advanced Illness and Frailty or Is Age 81 or Older with Frailtyboolean01Out
Lives In A Nursing Homeboolean01Out
Is Age 66 or Older Living Long Term in a Nursing Homeboolean01Out
Data Requirements:
TypeProfileMSCode Filter
Patient http://hl7.org/fhir/StructureDefinition/Patient
DeviceRequest http://hl7.org/fhir/StructureDefinition/DeviceRequest ;; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.118.12.1300
Observation http://hl7.org/fhir/StructureDefinition/Observation ;;; code filter:
path: code

system: http://loinc.org

code: 98181-1

display: Medical equipment used

Observation http://hl7.org/fhir/StructureDefinition/Observation ;; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1075
Observation http://hl7.org/fhir/StructureDefinition/Observation ;;; code filter:
path: code

system: http://loinc.org

code: 71802-3

display: Housing status

Condition http://hl7.org/fhir/StructureDefinition/Condition ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1074
Condition http://hl7.org/fhir/StructureDefinition/Condition ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.110.12.1082
Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1088
Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1087
Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1086
Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1010
Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1084
Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;; code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1083
MedicationRequest http://hl7.org/fhir/StructureDefinition/MedicationRequest ;; code filter:
path: medication
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.196.12.1510
MedicationRequest http://hl7.org/fhir/StructureDefinition/MedicationRequest ;;
Medication http://hl7.org/fhir/StructureDefinition/Medication ;;
Content: text/cql
library AdvancedIllnessandFrailtyExclusionECQMFHIR4 version '5.12.000'

using FHIR version '4.0.1'

include FHIRHelpers version '4.1.000' called FHIRHelpers
include MATGlobalCommonFunctionsFHIR4 version '6.0.000' called Global
include FHIRCommon version '1.1.000' called FC 
include AlphoraCommon called AC

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

valueset "Acute Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1083' 
valueset "Advanced Illness": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.110.12.1082' 
valueset "Care Services in Long-Term Residential Facility": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1014' 
valueset "Dementia Medications": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.196.12.1510' 
valueset "Emergency Department Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1010' 
valueset "Emergency Department Evaluation and Management Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1010'
valueset "Frailty Device": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.118.12.1300' 
valueset "Frailty Diagnosis": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1074' 
valueset "Frailty Encounter": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1088' 
valueset "Frailty Symptom": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.113.12.1075' 
valueset "Nonacute Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1084' 
valueset "Nursing Facility Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012' 
valueset "Observation": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1086' 
valueset "Outpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1087' 

code "Housing Status": '71802-3' from "LOINC" display 'Housing status'
code "Lives In A Nursing Home (finding)": '160734000' from "SNOMEDCT" display 'Lives in a nursing home (finding)'
code "Medical Equipment Used": '98181-1' from "LOINC" display 'Medical equipment used'

parameter "Measurement Period" default Interval[@2025-01-01T00:00:00.0, @2026-01-01T00:00:00.0)

context Patient

define "Up To One Year Prior Including Measurement Period":
  Interval[start of "Measurement Period" - 1 year, end of "Measurement Period"]

define "Is Age 66 or Older with Advanced Illness and Frailty":
  AgeInYearsAt(date from end of "Measurement Period") >= 66
    and "Has Criteria Indicating Frailty"
    and (
      exists("Has Two Outpatient Encounters With Advanced Illness on Different Dates of Service")
      or exists("Has Inpatient Encounter With Advanced Illness")
        or exists("Has Dementia Medications In Year Before or During Measurement Period")
    )

define "Is Age 66 to 80 with Advanced Illness and Frailty or Is Age 81 or Older with Frailty":
  (
    AgeInYearsAt(date from end of "Measurement Period") in Interval[66, 80]
      and "Has Criteria Indicating Frailty"
      and (
        exists("Has Two Outpatient Encounters With Advanced Illness on Different Dates of Service")
        or exists("Has Inpatient Encounter With Advanced Illness")
        or exists("Has Dementia Medications In Year Before or During Measurement Period")
      )
  ) 
  or (
    AgeInYearsAt(date from end of "Measurement Period") >= 81
      and "Has Criteria Indicating Frailty"
  )

define "Is Age 66 or Older Living Long Term in a Nursing Home":
  AgeInYearsAt(date from end of "Measurement Period") >= 66
    and "Lives In A Nursing Home"

define "Has Criteria Indicating Frailty":
  exists(
    (AC.QualifiedDeviceRequests([DeviceRequest: "Frailty Device"])) FrailtyDeviceOrder
      where FrailtyDeviceOrder.authoredOn during day of "Measurement Period"
    ) 
    or exists(
        (AC.QualifiedObservations([Observation: "Medical Equipment Used"])) EquipmentUsed
          where EquipmentUsed.value in "Frailty Device"
            and FC.ToInterval(EquipmentUsed.effective) ends during day of "Measurement Period"
    )
    or exists(
      (AC.QualifiedConditions([Condition: "Frailty Diagnosis"])) FrailtyDiagnosis
        where FC.ToPrevalenceInterval(FrailtyDiagnosis) overlaps "Measurement Period"
    )
    or exists(
      (AC.QualifiedEncounters([Encounter: "Frailty Encounter"])) FrailtyEnc
        where FC.ToInterval(FrailtyEnc.period) overlaps "Measurement Period"
    )
    or exists(
      (AC.QualifiedObservations([Observation: "Frailty Symptom"])) FrailtySymptom
        where FC.ToInterval(FrailtySymptom.effective) overlaps "Measurement Period"
    )

define "Has Inpatient Encounter With Advanced Illness":  
  (AC.QualifiedEncounters([Encounter: "Acute Inpatient"])) InpatientEnc
    with (AC.QualifiedConditions([Condition: "Advanced Illness"])) AdvanIll
      such that FC.ToPrevalenceInterval(AdvanIll) overlaps InpatientEnc.period
        and FC.ToInterval(InpatientEnc.period) overlaps "Up To One Year Prior Including Measurement Period"

define "Outpatient Encounters With Advanced Illness":
  ((AC.QualifiedEncounters([Encounter: "Outpatient"]))
    union (AC.QualifiedEncounters([Encounter: "Observation"]))
    union (AC.QualifiedEncounters([Encounter: "Emergency Department Visit"]))
    union (AC.QualifiedEncounters([Encounter: "Nonacute Inpatient"]))) OutpatientEnc
      with (AC.QualifiedConditions([Condition: "Advanced Illness"])) AdvanIll
        such that FC.ToPrevalenceInterval(AdvanIll) overlaps "Measurement Period"
      and FC.ToInterval(OutpatientEnc.period) overlaps "Up To One Year Prior Including Measurement Period" 

define "Has Two Outpatient Encounters With Advanced Illness on Different Dates of Service":
  from
    "Outpatient Encounters With Advanced Illness" OutpatientEncounter1,
    "Outpatient Encounters With Advanced Illness" OutpatientEncounter2
  where OutpatientEncounter2.period ends 1 day or more after day of end of OutpatientEncounter1.period
  return OutpatientEncounter1    

define "Has Dementia Medications In Year Before or During Measurement Period":
  (AC.QualifiedMedicationRequests([MedicationRequest: "Dementia Medications"])) DementiaMed
    where exists(
      DementiaMed.dosageInstruction dosage
      where exists(
        FC.ToTimingInterval(dosage.timing)) timing
        where timing overlaps "Up To One Year Prior Including Measurement Period")

define "Lives In A Nursing Home":
  Last(
    (AC.QualifiedObservations([Observation: "Housing Status"])) HousingStatus
      where FC.ToInterval(HousingStatus.effective) ends on or before end of "Measurement Period"
        and HousingStatus.value ~ ToConcept("Lives In A Nursing Home (finding)")
    sort by issued ascending
  ) is not null


Content: application/elm+xml
Encoded data (154028 characters)
Content: application/elm+json
Encoded data (291220 characters)