SMART DAK Cervical Cancer Screening
0.0.1 - ci-build

SMART DAK Cervical Cancer Screening, published by Dan Heslinga (independent contributor). This guide is not an authorized publication; it is the continuous build for version 0.0.1 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/dhes/smart-dak-cxca/ and changes regularly. See the Directory of published versions

Library: CXCAElements

Official URL: http://smart.who.int/cxca/Library/CXCAElements Version: 0.0.1
Draft as of 2026-05-14 Computable Name: CXCAElements

Shared CQL elements library for the cervical cancer screening DAK. Provides per-patient predicates and counts derived from FHIR resources (Patient, Procedure, Observation, ServiceRequest); consumed by both CDS-side Logic libraries and eCQM-side Indicator libraries to materialize the harmonization pattern from the eCQM/CDS paper. Source CQL is at input/cql/CXCAElements.cql.

Title: CXCAElements
Id: CXCAElements
Version: 0.0.1
Url: CXCAElements
Status: draft
Type:

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

code: logic-library

Date: 2026-05-14 00:50:23+0000
Publisher: Dan Heslinga (independent contributor)
Description:

Shared CQL elements library for the cervical cancer screening DAK. Provides per-patient predicates and counts derived from FHIR resources (Patient, Procedure, Observation, ServiceRequest); consumed by both CDS-side Logic libraries and eCQM-side Indicator libraries to materialize the harmonization pattern from the eCQM/CDS paper. Source CQL is at input/cql/CXCAElements.cql.

Parameters:
NameTypeMinMaxIn/Out
PatientPatient01Out
Current Patient Age In Yearsinteger01Out
Hysterectomy ProceduresProcedure0*Out
Has Had Hysterectomyboolean01Out
Data Requirements:
TypeProfileMSCode Filter
Procedure http://hl7.org/fhir/StructureDefinition/Procedure
Content: text/cql
/*
 * Library: CXCAElements
 *
 * THE HARMONIZATION LAYER.
 *
 * A shared CQL library that provides per-patient predicates and counts derived
 * from FHIR resources, consumed by both the CDS-side Logic libraries (e.g.,
 * CXCAD2DTScreeningEligibilityLogic) and the eCQM-side Indicator libraries
 * (e.g., CXCAIND01Logic). The defines below are the single source of truth
 * for what counts as "an HPV+ result," "a documented hysterectomy," etc.
 *
 * METHODOLOGY POINT (the harmonization paper distilled):
 *
 *   When CDS asks "is this patient due for screening today?" and an eCQM asks
 *   "what % of the cohort got screened in the period?", they ask different
 *   *aggregations* of the same underlying clinical fact: "did this patient
 *   get screened?" If both consumers compute that fact independently, they
 *   can drift — and the report stops aligning with the rule that drove the
 *   care. The fix is to define the underlying fact ONCE in a shared layer
 *   and have both consumers reference it.
 *
 *   IMMZ realizes this with `IMMZElements` and disease-specific
 *   `IMMZD2DTMeasles*Elements` libraries. We mirror that pattern here.
 *
 * Phase 5 chunk 8 — initial demonstration set. Currently only "Has Had
 * Hysterectomy" is materialized as a real FHIR query (Procedure with
 * CXCA.D#DE45). Subsequent iterations will add:
 *   - Per-period HPV result existence (with positive/negative value check)
 *   - Per-period cytology result existence (with Bethesda value check)
 *   - Per-period HPV-not-done existence (the Phase 4 NotDone pattern)
 *   - Time-window helpers (hasResultWithin, isExpectedButMissingFor)
 *
 * Each new define replaces a placeholder Boolean parameter in a downstream
 * library — this is the per-iteration migration path from placeholder-CQL
 * to real-FHIR-query-CQL.
 */

library CXCAElements version '0.0.1'

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1'

context Patient

// =============================================================================
// Patient demographics
// =============================================================================

/*
 * Current patient age in years.
 */
define "Current Patient Age In Years":
  AgeInYears()

// =============================================================================
// Hysterectomy history
// =============================================================================

/*
 * @internal: All recorded hysterectomy procedures for this patient,
 *   filtered to status = completed.
 */
define "Hysterectomy Procedures":
  [Procedure] P
    where P.status = 'completed'
      and exists (P.code.coding C where C.code = 'DE45'
                                     and C.system = 'http://smart.who.int/cxca/CodeSystem/CXCA.D')

/*
 * The patient has a documented completed hysterectomy.
 *
 * NOTE: A/641 section 2.2 only excludes hysterectomy for non-cervical-cancer indication
 * with a documented negative post-op vaginal-smear cytology. This define
 * captures only the hysterectomy fact; the indication and post-op cytology
 * checks live in higher-layer logic that combines this define with others.
 */
define "Has Had Hysterectomy":
  exists "Hysterectomy Procedures"
Content: application/elm+xml
Encoded data (20720 characters)