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: DepressionScreeningandFollowUp

Official URL: http://fhir.org/guides/cqf/aphl/chronic-ds/Library/DepressionScreeningandFollowUp Version: 0.1.0
Draft as of 2025-12-18 Computable Name: DepressionScreeningandFollowUp
Id: DepressionScreeningandFollowUp
Version: 0.1.0
Url: DepressionScreeningandFollowUp
Status: draft
Type:

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

code: logic-library

Date: 2025-12-18 18:12:52+0000
Publisher: Clinical Quality Framework
Jurisdiction: 001
Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
Measurement PeriodPeriod01In
PatientPatient01Out
SDE EthnicityCoding0*Out
SDE PayerResource0*Out
SDE RaceCoding0*Out
SDE SexCoding01Out
SDE Ageinteger01Out
Stratifier Age GroupCoding01Out
SDE State of Residencestring01Out
SDE Postal Code of Residencestring01Out
SDE Food Insecurity Risk StatusCodeableConcept01Out
Qualifying Encounters During Measurement PeriodEncounter0*Out
Initial Populationboolean01Out
Denominatorboolean01Out
History of Bipolar Diagnosis Before Qualifying EncounterCondition0*Out
Denominator Exclusionsboolean01Out
Medical or Patient Reason for Not Screening Adolescent for DepressionObservation0*Out
Has Adolescent Depression ScreeningObservation0*Out
Medical or Patient Reason for Not Screening Adult for DepressionObservation0*Out
Has Adult Depression ScreeningObservation0*Out
Denominator Exceptionsboolean01Out
Patient Age 12 to 16 Years at Start of Measurement Periodboolean01Out
Most Recent Adolescent Depression ScreeningObservation01Out
Most Recent Adolescent Screening Negativeboolean01Out
Most Recent Adolescent Positive Depression ScreeningObservation01Out
Follow Up Interventions For Positive Adolescent Depression ScreeningResource0*Out
Most Recent Adolescent Depression Screening Positive and Follow Up Providedboolean01Out
Patient Age 17 Years at Start of Measurement Periodboolean01Out
Most Recent Adult Depression ScreeningObservation01Out
Most Recent Adult Screening Negativeboolean01Out
Most Recent Adult Positive Depression ScreeningObservation01Out
Follow Up Interventions For Positive Adult Depression ScreeningResource0*Out
Most Recent Adult Depression Screening Positive and Follow Up Providedboolean01Out
Patient Age 18 Years or Older at Start of Measurement Periodboolean01Out
Numeratorboolean01Out
Data Requirements:
TypeProfileMSCode Filter
Patient http://hl7.org/fhir/StructureDefinition/Patient
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.600.1916
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.526.3.1022
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.1080
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.67.1.101.1.128
Observation http://hl7.org/fhir/StructureDefinition/Observation ;;;; code filter:
path: code
value set: http://fhir.org/guides/cqf/aphl/chronic-ds/ValueSet/adolescent-depression-screening-assessment
Observation http://hl7.org/fhir/StructureDefinition/Observation ;;;; code filter:
path: code
value set: http://fhir.org/guides/cqf/aphl/chronic-ds/ValueSet/adult-depression-screening-assessment
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.526.3.1567
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.526.3.1566
MedicationRequest http://hl7.org/fhir/StructureDefinition/MedicationRequest ;
Medication http://hl7.org/fhir/StructureDefinition/Medication ;;
ServiceRequest http://hl7.org/fhir/StructureDefinition/ServiceRequest ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1570
ServiceRequest http://hl7.org/fhir/StructureDefinition/ServiceRequest ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1571
Procedure http://hl7.org/fhir/StructureDefinition/Procedure ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1569
Procedure http://hl7.org/fhir/StructureDefinition/Procedure ; code filter:
path: code
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1568
Content: text/cql
library DepressionScreeningandFollowUp 

// CMS2v13: Preventive Care and Screening: Screening for Depression and Follow-Up Plan

using FHIR version '4.0.1'

include FHIRHelpers version '4.1.000' called FHIRHelpers
include SupplementalDataElementsFHIR4 version '2.0.000' called SDE
include MATGlobalCommonFunctionsFHIR4 version '6.0.000' called Global
include AdultOutpatientEncountersFHIR4 version '2.0.000' called AdultOutpatientEncounters
include HospiceFHIR4 version '2.0.000' called Hospice
include AdvancedIllnessandFrailtyExclusionECQMFHIR4 version '5.12.000' called Frailty
include SurveillanceDataElementsFHIR4 version '1.0.000' called SurveillanceDataElements
include AlphoraCommon called AC
include PalliativeCareFHIR called PalliativeCare
include FHIRCommon version '1.1.000' called FC 

codesystem "LOINC": 'http://loinc.org'
codesystem "SNOMEDCT": 'http://snomed.info/sct' 
codesystem "DataAbsentReason": 'http://terminology.hl7.org/CodeSystem/data-absent-reason'

valueset "Encounter to Screen for Depression": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.600.1916'
valueset "Physical Therapy Evaluation": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1022'
valueset "Telephone Visits": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1080'
valueset "Bipolar Disorder": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.67.1.101.1.128'
valueset "Medical Reason": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1007'
valueset "Adult Depression Screening Assessment": 'http://fhir.org/guides/cqf/aphl/chronic-ds/ValueSet/adult-depression-screening-assessment'
valueset "Adolescent Depression Screening Assessment": 'http://fhir.org/guides/cqf/aphl/chronic-ds/ValueSet/adolescent-depression-screening-assessment'

//adolescent
valueset "Adolescent Depression Medications": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1567'
valueset "Referral for Adolescent Depression": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1570'
valueset "Follow Up for Adolescent Depression": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1569'

//adult
valueset "Adult Depression Medications": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1566'
valueset "Referral for Adult Depression": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1571'
valueset "Follow Up for Adult Depression": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1568'

code "Depression Screening Declined": '720834000' from "SNOMEDCT" display 'Depression Screening Declined (situation)'
// code "Adolescent Depression Screening Assessment": '73831-0' from "LOINC" display 'Adolescent Depression Screening Assessment'
// code "Adult Depression Screening Assessment": '73832-8' from "LOINC" display 'Adult Depression Screening Assessment'
code "Depression Screening Negative": '428171000124102' from "SNOMEDCT" display 'Depression Screening Negative (finding)'
code "Depression Screening Positive": '428181000124104' from "SNOMEDCT" display 'Depression Screening Positive (finding)'
code "not-performed": 'not-performed' from "DataAbsentReason"


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

context Patient

define "SDE Ethnicity":
  SDE."SDE Ethnicity"

define "SDE Payer":
  SDE."SDE Payer"

define "SDE Race":
  SDE."SDE Race"

define "SDE Sex":
  SDE."SDE Sex"

define "SDE Age":
  SurveillanceDataElements."Age"

define "Stratifier Age Group":
  SurveillanceDataElements."Age Group"

define "SDE State of Residence":
  SurveillanceDataElements."State of Residence"

define "SDE Postal Code of Residence":
  SurveillanceDataElements."Postal Code of Residence"

define "SDE Food Insecurity Risk Status":
  SurveillanceDataElements."Food Insecurity Risk Status"



define "Initial Population":
  AgeInYearsAt(start of "Measurement Period") >= 12
    and exists(
      "Qualifying Encounters During Measurement Period" E 
        where FC.ToInterval(E.period) during "Measurement Period"
    )

define "Denominator":
  "Initial Population"

define "Denominator Exclusions":
  exists("History of Bipolar Diagnosis Before Qualifying Encounter")

define "Denominator Exceptions":
  (exists("Medical or Patient Reason for Not Screening Adolescent for Depression")
    and not exists("Has Adolescent Depression Screening"))
  or (exists("Medical or Patient Reason for Not Screening Adult for Depression")
    and not exists("Has Adult Depression Screening"))

define "Numerator":
  ( "Patient Age 12 to 16 Years at Start of Measurement Period"
      and ( "Most Recent Adolescent Screening Negative"
        or "Most Recent Adolescent Depression Screening Positive and Follow Up Provided" )
)
  or ( "Patient Age 17 Years at Start of Measurement Period"
    and ( "Most Recent Adolescent Screening Negative"
      or "Most Recent Adolescent Depression Screening Positive and Follow Up Provided"
      or "Most Recent Adult Screening Negative"
      or  "Most Recent Adult Depression Screening Positive and Follow Up Provided") 
  )
  or ( "Patient Age 18 Years or Older at Start of Measurement Period"
    and ( "Most Recent Adult Screening Negative"
      or "Most Recent Adult Depression Screening Positive and Follow Up Provided" ) )


define "Qualifying Encounters During Measurement Period":
  (AC.QualifiedEncounters([Encounter: "Encounter to Screen for Depression"])
    union AC.QualifiedEncounters([Encounter: "Physical Therapy Evaluation"])
    union AC.QualifiedEncounters([Encounter: "Telephone Visits"])) QualifyingEnc 
    where FC.ToInterval(QualifyingEnc.period) during "Measurement Period"


define function "Screening Within 14 Days of Encounter"(observation FHIR.Observation, encounter FHIR.Encounter)
returns System.Boolean:
  Coalesce(end of FC.ToInterval(observation.effective), observation.issued) 14 days or less before day of start of encounter.period
    and observation.value is not null

//Denominator Exclusion 
define "History of Bipolar Diagnosis Before Qualifying Encounter": 
  (AC.QualifiedConditions([Condition: "Bipolar Disorder"])) BipolarDiagnosis 
  with "Qualifying Encounters During Measurement Period" QualifyingEnc
    such that FC.ToPrevalenceInterval(BipolarDiagnosis) starts before QualifyingEnc.period


//Denominator Exception
define "Medical or Patient Reason for Not Screening Adolescent for Depression":
  AC.AbsentData([Observation: "Adolescent Depression Screening Assessment"], "Qualifying Encounters During Measurement Period", "Depression Screening Declined", "Medical Reason")

define "Has Adolescent Depression Screening":
  ((AC.QualifiedObservations([Observation: "Adolescent Depression Screening Assessment"])) AdolescentScreening
    with "Qualifying Encounters During Measurement Period" QualifyingEnc
      such that "Screening Within 14 Days of Encounter"(AdolescentScreening, QualifyingEnc))


define "Medical or Patient Reason for Not Screening Adult for Depression":
  AC.AbsentData([Observation: "Adult Depression Screening Assessment"], "Qualifying Encounters During Measurement Period", "Depression Screening Declined", "Medical Reason")

define "Has Adult Depression Screening":
  ((AC.QualifiedObservations([Observation: "Adult Depression Screening Assessment"])) AdolescentScreening
    with "Qualifying Encounters During Measurement Period" QualifyingEnc
      such that "Screening Within 14 Days of Encounter"(AdolescentScreening, QualifyingEnc))


//Numerator
define "Patient Age 12 to 16 Years at Start of Measurement Period":
  AgeInYearsAt(start of "Measurement Period") in Interval[12, 16]

define "Patient Age 17 Years at Start of Measurement Period":
  AgeInYearsAt(start of "Measurement Period") = 17

define "Patient Age 18 Years or Older at Start of Measurement Period":
  AgeInYearsAt(start of "Measurement Period") >= 18


//Adolescent Numerator
define "Most Recent Adolescent Depression Screening":
  AC.MostRecent(("Has Adolescent Depression Screening"))

define "Most Recent Adolescent Screening Negative":
  ("Most Recent Adolescent Depression Screening" AdolescentScreening
    where AdolescentScreening.value ~ ToConcept("Depression Screening Negative")) is not null

define "Most Recent Adolescent Positive Depression Screening":
  "Most Recent Adolescent Depression Screening" RecentScreening
    where RecentScreening.value ~ ToConcept("Depression Screening Positive")

define "Follow Up Interventions For Positive Adolescent Depression Screening":
  (AC.QualifiedMedicationRequests([MedicationRequest: "Adolescent Depression Medications"])
    union AC.QualifiedServiceRequests([ServiceRequest: "Referral for Adolescent Depression"])
    union AC.QualifiedProcedures([Procedure: "Follow Up for Adolescent Depression"])) FollowUpInterventions
    let "Intervention Day": Coalesce(FC.ToInterval(FollowUpInterventions.authoredOn), FC.ToInterval(FollowUpInterventions.performed))
    with "Qualifying Encounters During Measurement Period" QualifyingEnc
      such that "Intervention Day" same day as QualifyingEnc.period
      or "Intervention Day" 2 days or less after day of end of FC.ToInterval(QualifyingEnc.period) 
 
define "Most Recent Adolescent Depression Screening Positive and Follow Up Provided":
  ("Most Recent Adolescent Positive Depression Screening" RecentScreening
  let "Screening Day": Coalesce(FC.ToInterval(RecentScreening.effective), FC.ToInterval(RecentScreening.issued))
  with "Follow Up Interventions For Positive Adolescent Depression Screening" FollowUpInterventions
    such that "Screening Day" 14 days or less before start of Coalesce(FC.ToInterval(FollowUpInterventions.authoredOn), FC.ToInterval(FollowUpInterventions.performed))
  ) is not null 

//Adult Numerator
define "Most Recent Adult Depression Screening":
  AC.MostRecent(("Has Adult Depression Screening"))

define "Most Recent Adult Screening Negative":
  ("Most Recent Adult Depression Screening" AdultScreening
    where AdultScreening.value ~ ToConcept("Depression Screening Negative")) is not null

define "Most Recent Adult Positive Depression Screening":
  "Most Recent Adult Depression Screening" RecentScreening
    where RecentScreening.value ~ ToConcept("Depression Screening Positive")

define "Follow Up Interventions For Positive Adult Depression Screening":
  ((AC.QualifiedMedicationRequests([MedicationRequest: "Adult Depression Medications"])
    union AC.QualifiedServiceRequests([ServiceRequest: "Referral for Adult Depression"])
    union AC.QualifiedProcedures([Procedure: "Follow Up for Adult Depression"]))) FollowUpInterventions
    let "Intervention Day": Coalesce(FC.ToInterval(FollowUpInterventions.authoredOn), FC.ToInterval(FollowUpInterventions.performed))
    with "Qualifying Encounters During Measurement Period" QualifyingEnc
      such that "Intervention Day" same day as QualifyingEnc.period
      or "Intervention Day" 2 days or less after day of end of FC.ToInterval(QualifyingEnc.period) 

define "Most Recent Adult Depression Screening Positive and Follow Up Provided":
  ("Most Recent Adult Positive Depression Screening" RecentScreening
  let "Screening Day": Coalesce(FC.ToInterval(RecentScreening.effective), FC.ToInterval(RecentScreening.issued))
  with "Follow Up Interventions For Positive Adult Depression Screening" FollowUpInterventions
    such that "Screening Day" 14 days or less before start of Coalesce(FC.ToInterval(FollowUpInterventions.authoredOn), FC.ToInterval(FollowUpInterventions.performed))
  ) is not null 
Content: application/elm+xml
Encoded data (263028 characters)
Content: application/elm+json
Encoded data (504768 characters)