eCQM QICore Content Implementation Guide
2023.0.0 - CI Build

eCQM QICore Content Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2023.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/ecqm-content-qicore-2023/ and changes regularly. See the Directory of published versions

## Library: PCMaternal

Official URL: http://ecqi.healthit.gov/ecqms/Library/PCMaternal | Version: 5.10.000
Active as of 2023-08-21 | Responsible: The Joint Commission | Computable Name: PCMaternal
Other Identifiers: https://madie.cms.gov/login#64b84d66774bb523d9a14578 (use: official, )

This library specifies common data elements used by PC01, PC02, PC07.

Id: | 64b84d66774bb523d9a14578
Url: | http://ecqi.healthit.gov/ecqms/Library/PCMaternal
Version: | 5.10.000
Identifier: | value: 64b84d66774bb523d9a14578
Name: | PCMaternal
Title: | PCMaternal
Status: | active
Experimental: | false
Type: | system: http://terminology.hl7.org/CodeSystem/library-type code: logic-library
Date: | 2023-08-21T20:21:27+00:00
Publisher: | The Joint Commission
Description: | This library specifies common data elements used by PC01, PC02, PC07.
Related Artifacts: | Dependencies
Data Requirements: |
Type | Profile | MS | Code Filter
--- | --- | --- | ---
Procedure |  |  | code filter: path: code value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.59
Encounter |  |  | code filter: path: code value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Encounter |  |  | code filter: path: code value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Encounter |  |  | code filter: path: code value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1029.369
Observation |  |  | code filter: path: code system: http://loinc.org code: 11778-8 display: Delivery date Estimated
Observation |  |  | code filter: path: code value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.26
Observation |  |  | code filter: path: code system: http://loinc.org code: 93857-1 display: Date and time of obstetric delivery
Content: text/cql
    library PCMaternal version '5.10.000'

    /*@update: @@Created from QDM v2.1 to FHIR, then updated 041922 after annual update to QDM v2.21.000 @@*/

    using QICore version '4.1.1'

    include FHIRHelpers version '4.3.000' called FHIRHelpers
    include CQMCommon version '1.4.000' called Global
    include QICoreCommon version '1.5.000' called QICoreCommon

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

    valueset "Delivery Procedures": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.59'
    valueset "ED Visit and OB Triage": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1029.369'
    valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
    valueset "Estimated Gestational Age at Delivery": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1045.26'
    valueset "Observation Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143'

    code "Date and time of obstetric delivery": '93857-1' from "LOINC" display 'Date and time of obstetric delivery'
    code "Delivery date Estimated": '11778-8' from "LOINC" display 'Delivery date Estimated'

    parameter "Measurement Period" Interval<DateTime>

    context Patient

    define "Delivery Encounter with Age Range":
      "Encounter with Age Range" EncounterWithAge
                    with ["Procedure": "Delivery Procedures"] DeliveryProcedure
                    such that DeliveryProcedure.status = 'completed'
                    and DeliveryProcedure.performed.toInterval  ( ) starts during day of EncounterWithAge.hospitalizationWithEDOBTriageObservation ()

    define "Encounter with Age Range":
      ["Encounter": "Encounter Inpatient"] EncounterInpatient
                          where EncounterInpatient.status = 'finished'
                            and AgeInYearsAt(date from start of EncounterInpatient.period) in Interval[ 8, 65 )
                            and EncounterInpatient.period ends during day of "Measurement Period"

    define "Variable Calculated Gestational Age":
      //This definition establishes a variable of CGA (Calculated Gestational Age) for all patients for the sole purpose of displaying the Calculated Gestational Age. This definition is not used in the measure logic.
      "Delivery Encounter with Age Range" QualifyingEncounter
        let CGA: QualifyingEncounter.calculatedGestationalAge()
      //  return { QualifyingEncounter, CGA }
        return {
          EncounterID: QualifyingEncounter.id,
          CalculatedCGA: CGA
        }

    define fluent function calculatedGestationalAge (TheEncounter Encounter ):
      //Gestational Age = (280-(Estimated Delivery Date minus Reference Date/Delivery Date))/7
      ( 280 - ( difference in days between TheEncounter.lastTimeOfDelivery () and TheEncounter.lastEstimatedDeliveryDate( )) ) div 7

    /*define function "HospitalizationWithEDOBTriageObservation"(Encounter Encounter ):
      HospitalizationWithEDOBTriageObservation returns the total interval from the start of any immediately prior emergency department visit or OB Triage visit through the observation visit to the discharge of the given encounter
      Encounter Visit
        let ObsVisit: Last(["Encounter": "Observation Services"] LastObs
            where LastObs.period ends 1 hour or less on or before start of Visit.period
              and LastObs.status = 'finished'
            sort by
            end of period
        ),
        VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),
        EDOBTriageVisit: Last(["Encounter": "ED Visit and OB Triage"] LastEDOBTriage
            where LastEDOBTriage.period ends 1 hour or less on or before VisitStart
              and LastEDOBTriage.status = 'finished'
            sort by
            end of period
        )
        return Interval[Coalesce(start of EDOBTriageVisit.period, VisitStart),
        end of Visit.period]*/

    define fluent function hospitalizationWithEDOBTriageObservation (TheEncounter Encounter ):
      /*hospitalizationWithEDOBTriageObservation returns the total interval from the start of any immediately prior emergency department visit or OB Triage visit through the observation visit to the discharge of the given encounter*/
      TheEncounter Visit
        let ObsVisit: Last(["Encounter": "Observation Services"] LastObs
            where LastObs.period ends 1 hour or less on or before start of Visit.period
              and LastObs.status = 'finished'
            sort by
            end of period
        ),
        VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),
        EDOBTriageVisit: Last(["Encounter": "ED Visit and OB Triage"] LastEDOBTriage
            where LastEDOBTriage.period ends 1 hour or less on or before VisitStart
              and LastEDOBTriage.status = 'finished'
            sort by
            end of period
        )
        return Interval[Coalesce(start of EDOBTriageVisit.period, VisitStart),
        end of Visit.period]

      /*===============================================================*/
      /*  03/14/2022 from MATGlobalCommonFunctionsv7.000 - latest QDM  */
      /*     even though this PCMaternalFHIR was derived from          */
      /*     PCMaternal=2.1.000 cql, to make next update easier.       */
      /*     Will need to re-insert "Global". in front of these        */
      /*     function names later (whereever they are directly used.*/

    define fluent function lastEstimatedDeliveryDate (TheEncounter Encounter ):
      /*This function identifies the last time the EDD was assessed 42 weeks or less prior to or on delivery and stores the result of that assessment.*/
      Last(["Observation": "Delivery date Estimated"] EstimatedDateOfDelivery
          where EstimatedDateOfDelivery.value as DateTime is not null
            and EstimatedDateOfDelivery.status in { 'final', 'amended', 'corrected' }
            and EstimatedDateOfDelivery.effective.earliest ( ) 42 weeks or less before or on TheEncounter.lastTimeOfDelivery ()
          sort by effective.earliest ( )
      ).value as DateTime

    define fluent function lastEstimatedGestationalAge (TheEncounter Encounter ):
      Last(["Observation": "Estimated Gestational Age at Delivery"] EstimatedGestationalAge
          where EstimatedGestationalAge.value is not null
            and EstimatedGestationalAge.status in { 'final', 'amended', 'corrected' }
            and EstimatedGestationalAge.effective.earliest() 24 hours or less before or on TheEncounter.lastTimeOfDelivery ()
          sort by effective.earliest ()
      ).value as Quantity

    define fluent function lastTimeOfDelivery (TheEncounter Encounter ):
      Last(["Observation": "Date and time of obstetric delivery"] TimeOfDelivery
          where TimeOfDelivery.value as DateTime is not null
            and TimeOfDelivery.status in { 'final', 'amended', 'corrected' }
            and TimeOfDelivery.effective.earliest () during TheEncounter.hospitalizationWithEDOBTriageObservation ()
            and TimeOfDelivery.value as DateTime during TheEncounter.hospitalizationWithEDOBTriageObservation()
          sort by effective.earliest()
      ).value as DateTime
Content: application/elm+xml
    Encoded data (266572 characters)
Content: application/elm+json
    Encoded data (393808 characters)