Colorectal Cancer Screening and Management (CRCSM) Clinical Decision Support (CDS) Implementation Guide
0.1.0 - ci-build

Colorectal Cancer Screening and Management (CRCSM) Clinical Decision Support (CDS) Implementation Guide - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

Library: ScreeningEligible

Official URL: http://cancerscreeningcds.github.io/crcsm-cds/Library/ScreeningEligible Version: 0.1.0
Draft as of 2025-02-28 Computable Name: ScreeningEligible
Id: ScreeningEligible
Version: 0.1.0
Url: ScreeningEligible
Status: draft
Type:

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

code: logic-library

Date: 2025-02-28 21:24:30+0000
Publisher: MITRE
Related Artifacts:

Dependencies

  • http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1
  • http://cancerscreeningcds.github.io/crcsm-cds/Library/FHIRHelpers|4.0.1
  • http://cancerscreeningcds.github.io/crcsm-cds/Library/ScreeningEligibleEvents|1.0.0
  • http://cancerscreeningcds.github.io/crcsm-cds/Library/ScreeningEligibleActions|1.0.0
  • http://cancerscreeningcds.github.io/crcsm-cds/Library/DataElements|1.0.0
  • Logical Observation Identifiers, Names and Codes (LOINC)
  • http://example.org/CodeSystem/plan-definition-action-code-system
  • http://example.org/CodeSystem/plan-definition-action-reason-code-system
Parameters:
NameTypeMinMaxIn/Out
PatientPatient01Out
MostRecentAgeValuedecimal01Out
MissingAgeOrBirthdateboolean01Out
ErrorMissingAgeOrBirthdateboolean01Out
IsIncludedAndNotExcludedErrorsHaveOccurredboolean01Out
inc-AgeAtLeast18boolean01Out
IsIncludedboolean01Out
Excludedboolean01Out
IsIncludedAndNotExcludedboolean01Out
CheckIsIncludedAndNotExcludedboolean01Out
ActiveCRCResource01Out
HxTotalColectomyResource01Out
SymptomaticResource01Out
EligibleResource01Out
flow-ScreeningEligibleResource0*Out
IsScreeningEligibleboolean01Out
IsNotScreeningEligibleboolean01Out
ExistsActiveCRCboolean01Out
ExistsHxTotalColectomyboolean01Out
ExistsSymptomaticboolean01Out
ScreeningEligibleCodeCoding01Out
ScreeningEligibleReasonCoding01Out
Data Requirements:
TypeProfileMSCode Filter
Patient http://hl7.org/fhir/StructureDefinition/Patient
Observation http://hl7.org/fhir/StructureDefinition/Observation ;;; code filter:
path: code

system: http://loinc.org

code: 30525-0

display: Age

code filter:
path: value.unit

code: years

Content: text/cql
library ScreeningEligible version '1.0.0'

using FHIR version '4.0.1'
include FHIRHelpers  version '4.0.1' called FHIRHelpers

include ScreeningEligibleEvents version '1.0.0' called Events
include ScreeningEligibleActions version '1.0.0' called Actions
include DataElements version '1.0.0' called DataElements

//------------------------------------------------------------------------------
// CODE SYSTEMS, VALUE SETS, AND CODES
//------------------------------------------------------------------------------

codesystem "LOINC": 'http://loinc.org'

codesystem "ActCode": 'http://example.org/CodeSystem/plan-definition-action-code-system'
codesystem "ReasonCode": 'http://example.org/CodeSystem/plan-definition-action-reason-code-system'

// Act Codes
code "Error": 'error' from "ActCode"
// Reason Codes
code "Missing age or birth date": 'missingageorbirthdate' from "ReasonCode"

// Standard codes
code "Age": '30525-0' from "LOINC" display 'Age'

//------------------------------------------------------------------------------
// PARAMETERS
//------------------------------------------------------------------------------

context Patient

//------------------------------------------------------------------------------
// CDS Logic
//------------------------------------------------------------------------------

define CheckIsIncludedAndNotExcluded:
  IsIncludedAndNotExcludedErrorsHaveOccurred is not true 
    and Message(IsIncludedAndNotExcluded, IsIncludedAndNotExcluded is false,
    'http://example.org/CodeSystem/plan-definition-action-reason-code-system/excludedornotincluded',
    'Error', 
    'Excluded or not included')  

define IsIncludedAndNotExcluded:
  IsIncluded and not Excluded

// INCLUSIONS
define IsIncluded:
  "inc-AgeAtLeast18"

// Age 18 years and older, only use MostRecentAgeValue if no birthdate  
define "inc-AgeAtLeast18":
  (AgeInYears() is not null and AgeInYears() >= 18) or (AgeInYears() is null and MostRecentAgeValue >= 18)

define MostRecentAgeValue:
  First(
    [Observation: "Age"] O
      where O.value.unit = 'years'
      sort by effective desc
  ).value.value.value

// EXCLUSIONS
define Excluded:
  false

//------------------------------------------------------------------------------
// RECOMMENDATIONS
//------------------------------------------------------------------------------

define "flow-ScreeningEligible":
  {
    Coalesce(
      ActiveCRC,
      HxTotalColectomy,
      Symptomatic,
      Eligible
    )
  }
  except { null }


define ActiveCRC:
  if Events."eve-ActiveCRC" is true
  then Actions."end-noteligible-currentcolorectalcancer" else null

define HxTotalColectomy:
  if Events."eve-HxTotalColectomy" is true
  then Actions."end-noteligible-colectomy" else null

define Symptomatic:
  if Events."eve-Symptomatic" is true
  then Actions."act-Diagnostic" else null

define Eligible:
  if Coalesce(
    ActiveCRC,
    HxTotalColectomy,
    Symptomatic
  ) is null
  then Actions."act-ScreeningEligible" else null
  

//------------------------------------------------------------------------------
// DYNAMIC VALUES
//------------------------------------------------------------------------------

define IsScreeningEligible:
  Eligible is not null

define IsNotScreeningEligible:
  Eligible is null  


define ExistsActiveCRC:
  ActiveCRC is not null

define ExistsHxTotalColectomy:
  HxTotalColectomy is not null

define ExistsSymptomatic:
  Symptomatic is not null

define ScreeningEligibleCode:
  First("flow-ScreeningEligible").code

define ScreeningEligibleReason:
  First("flow-ScreeningEligible").reason 

//------------------------------------------------------------------------------
// ERRORS
//------------------------------------------------------------------------------

define IsIncludedAndNotExcludedErrorsHaveOccurred:
  ErrorMissingAgeOrBirthdate

define MissingAgeOrBirthdate:
  AgeInYears() is null and MostRecentAgeValue is null

define ErrorMissingAgeOrBirthdate:
  if MissingAgeOrBirthdate
  then Message(true, true,
    'http://example.org/CodeSystem/plan-definition-action-reason-code-system/missingageorbirthdate',
    'Warning', 
    'Missing age or birth date')
  else false

Content: application/elm+xml
Encoded data (64240 characters)
Content: application/elm+json
Encoded data (117552 characters)