eCQM Content CMS Implementation Guide
2025.7.1 - CI Build

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

Measure: NHSN Glycemic Control Hypoglycemia Initial Population

Official URL: https://madie.cms.gov/Measure/NHSNGlycemicControlHypoglycemiaInitialPopulation Version: 0.0.001
Active as of 2025-07-09 Responsible: Centers for Disease Control and Prevention (CDC) Computable Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
Other Identifiers: Short Name: NHSNHypoglycemia (use: usual, ), UUID:0d555fb6-f654-418c-a2b3-2dd0c3f0e7b4 (use: official, ), UUID:50ceef3e-0a14-4f4f-8797-ffae8cce7237 (use: official, )

Copyright/Legal: Limited proprietary coding is contained in the Measure specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets.

All inpatient encounters (including ED/Observation visits that end within 1 hour of the start of the inpatient encounter) for patients of all ages where at least one diabetes medication was ordered or administered during the encounter that is during the measurement period.

Metadata
Title NHSN Glycemic Control Hypoglycemia Initial Population
Version 0.0.001
Short Name NHSNHypoglycemia
GUID (Version Independent) urn:uuid:0d555fb6-f654-418c-a2b3-2dd0c3f0e7b4
GUID (Version Specific) urn:uuid:50ceef3e-0a14-4f4f-8797-ffae8cce7237
Effective Period 2026-01-01 through 2026-12-31
Steward (Publisher) Centers for Disease Control and Prevention (CDC)
Developer Lantana Consulting Group
Description

All inpatient encounters (including ED/Observation visits that end within 1 hour of the start of the inpatient encounter) for patients of all ages where at least one diabetes medication was ordered or administered during the encounter that is during the measurement period.

Copyright

Limited proprietary coding is contained in the Measure specifications for user convenience. Users of proprietary code sets should obtain all necessary licenses from the owners of the code sets.

Disclaimer

Disclaimer This performance measure is not a clinical guideline, does not establish a standard of medical care and has not been tested for all potential applications.

THE MEASURES AND SPECIFICATIONS ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND.

This measure and specifications are subject to further revisions.

Rationale

The NHSN Glycemic Control module supports an electronic health record (EHR)- and vendor-neutral standard for reporting patient-level, linked medication and blood glucose data for inpatients. These data support calculation of inpatient medication-related hypoglycemia events by the NHSN application, which are then returned as reports to the facility. Inpatient hyperglycemia measurement is being incorporated into a future version of the NHSN Glycemic Control module. The primary objective of the NHSN Glycemic Control Module is to support U.S. hospitals in glycemic control measurement to improve glycemic management and patient safety. As additional data are collected by NHSN, an additional objective will be to facilitate inter-facility benchmarking of glycemic control metrics across U.S. hospitals and evaluate national-level trends of glycemic control metrics over time.

The IP dQM provides the initial population, FHIR line-level and supplement data necessary for calculating the module metrics.

Measure Group (Rate) (ID: Group_1)
Basis Encounter
Scoring Cohort
Type Process
Initial Population ID: InitialPopulation_1
Description:

All inpatient encounters, as well as ED and OBS encounters that end within 1 hour of the start of the inpatient encounter, for patients of all ages where at least one diabetes medication was ordered or administered during the encounter that is during the measurement period.

Logic Definition: Initial Population
Supplemental Data Elements
Supplemental Data Element ID: sde-encounter-locations
Usage Code: Supplemental Data
Description: SDE Encounter Locations
Logic Definition: SDE Encounter Locations
Supplemental Data Element ID: sde-location
Usage Code: Supplemental Data
Description: SDE Location
Logic Definition: SDE Location
Supplemental Data Element ID: sde-medication
Usage Code: Supplemental Data
Description: SDE Medication
Logic Definition: SDE Medication
Supplemental Data Element ID: sde-blood-glucose-observation
Usage Code: Supplemental Data
Description: SDE Blood Glucose Observation
Logic Definition: SDE Blood Glucose Observation
Supplemental Data Element ID: sde-chief-complaint
Usage Code: Supplemental Data
Description: SDE Chief Complaint
Logic Definition: SDE Chief Complaint
Supplemental Data Element ID: sde-condition
Usage Code: Supplemental Data
Description: SDE Condition
Logic Definition: SDE Condition
Supplemental Data Element ID: sde-coverage
Usage Code: Supplemental Data
Description: SDE Coverage
Logic Definition: SDE Coverage
Supplemental Data Element ID: sde-initial-population-encounters
Usage Code: Supplemental Data
Description: SDE Initial Population Encounters
Logic Definition: SDE Initial Population Encounters
Supplemental Data Element ID: sde-medication-administration
Usage Code: Supplemental Data
Description: SDE Medication Administration
Logic Definition: SDE Medication Administration
Supplemental Data Element ID: sde-medication-request
Usage Code: Supplemental Data
Description: SDE Medication Request
Logic Definition: SDE Medication Request
Supplemental Data Element ID: sde-minimal-patient
Usage Code: Supplemental Data
Description: SDE Minimal Patient
Logic Definition: SDE Minimal Patient
Supplemental Data Element ID: sde-service-request
Usage Code: Supplemental Data
Description: SDE Service Request
Logic Definition: SDE Service Request
Supplemental Data Element ID: sde-ethnicity
Usage Code: Supplemental Data
Description: SDE Ethnicity
Logic Definition: SDE Ethnicity
Supplemental Data Element ID: sde-payer
Usage Code: Supplemental Data
Description: SDE Payer
Logic Definition: SDE Payer
Supplemental Data Element ID: sde-race
Usage Code: Supplemental Data
Description: SDE Race
Logic Definition: SDE Race
Supplemental Data Element ID: sde-sex
Usage Code: Supplemental Data
Description: SDE Sex
Logic Definition: SDE Sex
Measure Logic
Primary Library NHSNGlycemicControlHypoglycemiaInitialPopulation
Contents Population Criteria
Logic Definitions
Terminology
Dependencies
Data Requirements
Population Criteria
Measure Group (Rate) (ID: Group_1)
Initial Population
// Initial Population


define "Initial Population":
  ( "Inpatient Encounters During Measurement Period"
    union "Encounters with Patient Hospital Locations" ) InpatientEncounters
    with "Antidiabetic Drugs Administered or Ordered" ADD
      such that Coalesce(start of ADD.effective.toInterval(), ADD.authoredOn) during InpatientEncounters."hospitalizationWithObservation" ( )
    where ( InpatientEncounters.status = 'finished'
        or InpatientEncounters.status = 'in-progress'
        or InpatientEncounters.status = 'triaged'
        or InpatientEncounters.status = 'onleave'
        or InpatientEncounters.status = 'entered-in-error'
    )
Initial Population
// Initial Population


define "Initial Population":
  ( "Inpatient Encounters During Measurement Period"
    union "Encounters with Patient Hospital Locations" ) InpatientEncounters
    with "Antidiabetic Drugs Administered or Ordered" ADD
      such that Coalesce(start of ADD.effective.toInterval(), ADD.authoredOn) during InpatientEncounters."hospitalizationWithObservation" ( )
    where ( InpatientEncounters.status = 'finished'
        or InpatientEncounters.status = 'in-progress'
        or InpatientEncounters.status = 'triaged'
        or InpatientEncounters.status = 'onleave'
        or InpatientEncounters.status = 'entered-in-error'
    )
Logic Definitions
Logic Definition Library Name: SupplementalDataElements
define "SDE Race":
  Patient.race R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }
Logic Definition Library Name: SupplementalDataElements
define "SDE Sex":
  case
    when Patient.sex = '248153007' then "Male (finding)"
    when Patient.sex = '248152002' then "Female (finding)"
    else null
  end
Logic Definition Library Name: SupplementalDataElements
define "SDE Payer":
  [Coverage: type in "Payer Type"] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }
Logic Definition Library Name: SupplementalDataElements
define "SDE Ethnicity":
  Patient.ethnicity E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }
Logic Definition Library Name: CQMCommon
/*
@description: Returns the Location resource specified by the given reference.
*/
define fluent function getLocation(reference Reference):
  singleton from (
    [Location] L where reference.references(L)
  )
Logic Definition Library Name: CQMCommon
/*
@description: Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter
*/
define fluent function hospitalizationWithObservation(TheEncounter Encounter ):
  TheEncounter Visit
  		let ObsVisit: Last([Encounter: "Observation Services"] LastObs
  				where LastObs.status = 'finished'
            and LastObs.period ends 1 hour or less on or before start of Visit.period
  				sort by end of period
  			),
  			VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),
  			EDVisit: Last([Encounter: "Emergency Department Visit"] LastED
  				where LastED.status = 'finished'
            and LastED.period ends 1 hour or less on or before VisitStart
  				sort by end of period
  			)
  		return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]
Logic Definition Library Name: FHIRHelpers
/*
@description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)
value to a CQL DateTime Interval
@comment: If the start value of the given period is unspecified, the starting
boundary of the resulting interval will be open (meaning the start of the interval
is unknown, as opposed to interpreted as the beginning of time).
*/
define function ToInterval(period FHIR.Period):
    if period is null then
        null
    else
        if period."start" is null then
            Interval(period."start".value, period."end".value]
        else
            Interval[period."start".value, period."end".value]
Logic Definition Library Name: FHIRHelpers
/*
@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
*/
define function ToConcept(concept FHIR.CodeableConcept):
    if concept is null then
        null
    else
        System.Concept {
            codes: concept.coding C return ToCode(C),
            display: concept.text.value
        }
Logic Definition Library Name: FHIRHelpers
/*
@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
*/
define function ToCode(coding FHIR.Coding):
    if coding is null then
        null
    else
        System.Code {
          code: coding.code.value,
          system: coding.system.value,
          version: coding.version.value,
          display: coding.display.value
        }
Logic Definition Library Name: FHIRHelpers
define function ToString(value uri): value.value
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "Inpatient Encounters During Measurement Period":
  [Encounter: "Encounter Inpatient"] InpatientEncounters
    where InpatientEncounters.period ends during day of "Measurement Period"
      and ( InpatientEncounters.class ~ QICoreCommon."inpatient non-acute"
          or InpatientEncounters.class ~ QICoreCommon."inpatient non-acute"
          or InpatientEncounters.class ~ QICoreCommon."short stay"
          or InpatientEncounters.class ~ QICoreCommon."inpatient acute"
          or InpatientEncounters.class ~ QICoreCommon."inpatient encounter"
      )
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "Encounters with Patient Hospital Locations":
  "Inpatient Encounters During Measurement Period" InpatientEncounter
    where exists ( InpatientEncounter.location HospitalLocation
        where HospitalLocation.location.getLocation ( ).type in "Inpatient, Emergency, and Observation Locations"
          and HospitalLocation.period during day of InpatientEncounter.period
    )
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "Antidiabetic Drugs Administered or Ordered":
  ( ( [MedicationAdministration: medication in "Diabetes Medications"] ADDMedAdmin
        where ADDMedAdmin.status ~ 'completed'
    )
      union ( [MedicationRequest: medication in "Diabetes Medications"] ADDOrder
          where ADDOrder.status ~ 'completed'
      )
  )
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
// Initial Population


define "Initial Population":
  ( "Inpatient Encounters During Measurement Period"
    union "Encounters with Patient Hospital Locations" ) InpatientEncounters
    with "Antidiabetic Drugs Administered or Ordered" ADD
      such that Coalesce(start of ADD.effective.toInterval(), ADD.authoredOn) during InpatientEncounters."hospitalizationWithObservation" ( )
    where ( InpatientEncounters.status = 'finished'
        or InpatientEncounters.status = 'in-progress'
        or InpatientEncounters.status = 'triaged'
        or InpatientEncounters.status = 'onleave'
        or InpatientEncounters.status = 'entered-in-error'
    )
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Coverage":
  [Coverage] Coverages
    where exists ( "Initial Population" IP
        where Coverages.period starts before or on day of IP.period
          and end of Coverages.period on or after day of end of IP.period
    )
    return { Coverages.id, Coverages.meta, Coverages.status, Coverages.type, Coverages.policyHolder, Coverages.subscriber, Coverages.subscriberId, Coverages.beneficiary, Coverages.dependent, Coverages.relationship, Coverages.period, Coverages.payor, Coverages.class, Coverages.order, Coverages.network, Coverages.subrogation, Coverages.contract }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "MedicationRequests":
  [MedicationRequest]
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Medication Request":
  "MedicationRequests" MedRequests
    where exists ( "Initial Population" InitialPopulation
        where MedRequests.authoredOn during InitialPopulation."hospitalizationWithObservation" ( )
    )
    return { MedRequests.id, MedRequests.meta, MedRequests.status, MedRequests.statusReason, MedRequests.intent, MedRequests.category, MedRequests.priority, MedRequests.doNotPerform, MedRequests.reported, MedRequests.medication, MedRequests.subject, MedRequests.encounter, MedRequests.authoredOn, MedRequests.requester, MedRequests.recorder, MedRequests.reasonCode, MedRequests.reasonReference, MedRequests.instantiatesCanonical, MedRequests.instantiatesUri, MedRequests.courseOfTherapyType, MedRequests.dosageInstruction }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Encounter Locations":
  "Initial Population" IP
    where exists ( IP.location InitialPopulationLocation
        let types: ( InitialPopulationLocation.location ).getLocation ( ).type
        where exists ( types type
            where type in "Inpatient, Emergency, and Observation Locations"
        )
          and InitialPopulationLocation.period during IP.period
    )
    return { IP.id, IP.meta, IP.identifier, IP.status, IP.statusHistory, IP.class, IP.classHistory, IP.type, IP.serviceType, IP.priority, IP.subject, IP.period, IP.length, IP.reasonCode, IP.reasonReference, IP.diagnosis, IP.account, IP.hospitalization, IP.location, IP.partOf }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Race":
  SDE."SDE Race"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "MedicationAdministrations":
  [MedicationAdministration]
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Medication Administration":
  "MedicationAdministrations" MedAdministrations
    where exists ( "Initial Population" InitialPopulation
        where MedAdministrations.effective.toInterval ( ) overlaps InitialPopulation."hospitalizationWithObservation" ( )
    )
    return { MedAdministrations.id, MedAdministrations.meta, MedAdministrations.instantiates, MedAdministrations.partOf, MedAdministrations.status, MedAdministrations.statusReason, MedAdministrations.category, MedAdministrations.medication, MedAdministrations.subject, MedAdministrations.context, MedAdministrations.supportingInformation, MedAdministrations.effective, MedAdministrations.performer, MedAdministrations.reasonCode, MedAdministrations.reasonReference, MedAdministrations.request, MedAdministrations.device, MedAdministrations.note, MedAdministrations.dosage }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Sex":
  SDE."SDE Sex"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Initial Population Encounters":
  "Initial Population" IP
    return { IP.id, IP.meta, IP.identifier, IP.status, IP.statusHistory, IP.class, IP.classHistory, IP.type, IP.serviceType, IP.priority, IP.subject, IP.period, IP.length, IP.reasonCode, IP.reasonReference, IP.diagnosis, IP.account, IP.hospitalization, IP.location, IP.partOf }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
//Supplemental Data Elements


define "SDE Blood Glucose Observation":
  ( ["LaboratoryResultObservation": "Blood Glucose Laboratory and Point of Care Tests"] GlucoseTest
      where exists ( "Initial Population" InitialPopulation
          where start of GlucoseTest.effective.toInterval ( ) during day of InitialPopulation.period
            or GlucoseTest.issued during day of InitialPopulation.period
      )
      return { GlucoseTest.id, GlucoseTest.extension, GlucoseTest.text, GlucoseTest.referenceRange, GlucoseTest.component, GlucoseTest.basedOn, GlucoseTest.partOf, GlucoseTest.category, GlucoseTest.status, GlucoseTest.subject, GlucoseTest.focus, GlucoseTest.encounter, GlucoseTest.effective, GlucoseTest.issued, GlucoseTest.performer, GlucoseTest.value, GlucoseTest.dataAbsentReason, GlucoseTest.interpretation, GlucoseTest.note, GlucoseTest.bodySite, GlucoseTest.method, GlucoseTest.specimen, GlucoseTest.device, GlucoseTest.hasMember, GlucoseTest.derivedFrom }
  )
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Condition":
  ["ConditionProblemsHealthConcerns"] Diagnosis
    where exists ( "Initial Population" IP
        where Diagnosis.prevalenceInterval ( ) overlaps day of IP.period
    )
    return { Diagnosis.id, Diagnosis.meta, Diagnosis.clinicalStatus, Diagnosis.verificationStatus, Diagnosis.category, Diagnosis.severity, Diagnosis.code, Diagnosis.bodySite, Diagnosis.subject, Diagnosis.encounter.reference.getId ( ), Diagnosis.onset, Diagnosis.stage, Diagnosis.evidence, Diagnosis.note }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Payer":
  SDE."SDE Payer"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
// Initial Population


define "Initial Population":
  ( "Inpatient Encounters During Measurement Period"
    union "Encounters with Patient Hospital Locations" ) InpatientEncounters
    with "Antidiabetic Drugs Administered or Ordered" ADD
      such that Coalesce(start of ADD.effective.toInterval(), ADD.authoredOn) during InpatientEncounters."hospitalizationWithObservation" ( )
    where ( InpatientEncounters.status = 'finished'
        or InpatientEncounters.status = 'in-progress'
        or InpatientEncounters.status = 'triaged'
        or InpatientEncounters.status = 'onleave'
        or InpatientEncounters.status = 'entered-in-error'
    )
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "Get Locations from Initial Population":
  flatten ( "Initial Population" IP
      let locationElements: IP.location
      return locationElements LE
        let locationReference: LE.location
        return ( locationReference.getLocation ( ) )
  )
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Location":
  "Get Locations from Initial Population" Locations
    where exists "Initial Population"
      and Locations is not null
    return { Locations.id, Locations.meta, Locations.extension, Locations.status, Locations.operationalStatus, Locations.name, Locations.alias, Locations.description, Locations.mode, Locations.type, Locations.telecom, Locations.address, Locations.physicalType, Locations.position, Locations.managingOrganization, Locations.partOf, Locations.hoursOfOperation, Locations.availabilityExceptions, Locations.endpoint }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Service Request":
  [ServiceRequest] ServiceRequests
    where exists ( "Initial Population" InitialPopulation
        where ServiceRequests.authoredOn during InitialPopulation.period
    )
    return { ServiceRequests.id, ServiceRequests.meta, ServiceRequests.instantiatesCanonical, ServiceRequests.instantiatesUri, ServiceRequests.basedOn, ServiceRequests.replaces, ServiceRequests.requisition, ServiceRequests.status, ServiceRequests.intent, ServiceRequests.category, ServiceRequests.priority, ServiceRequests.doNotPerform, ServiceRequests.code, ServiceRequests.orderDetail, ServiceRequests.quantity, ServiceRequests.subject, ServiceRequests.encounter, ServiceRequests.occurrence, ServiceRequests.asNeeded, ServiceRequests.authoredOn, ServiceRequests.requester, ServiceRequests.performerType, ServiceRequests.performer, ServiceRequests.locationCode, ServiceRequests.reasonCode, ServiceRequests.reasonReference, ServiceRequests.insurance, ServiceRequests.bodySite, ServiceRequests.note, ServiceRequests.patientInstruction }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Minimal Patient":
  [Patient] MinPt
    where exists "Initial Population"
    return { MinPt.id, MinPt.meta, MinPt.extension, MinPt.identifier, MinPt.active, MinPt.name, MinPt.telecom, MinPt.gender, MinPt.birthDate, MinPt.deceased, MinPt.address, MinPt.maritalStatus, MinPt.multipleBirth, MinPt.photo, MinPt.contact, MinPt.communication, MinPt.generalPractitioner, MinPt.managingOrganization, MinPt.link }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Medication":
  ( "MedicationRequests"
    union "MedicationAdministrations" ) MedReqOrAdmin
    let medication: GetMedication(MedReqOrAdmin.medication)
    where medication is not null
      and exists ( "Initial Population" IP
          where Coalesce(MedReqOrAdmin.effective.toInterval(), MedReqOrAdmin.authoredOn.toInterval()) overlaps IP."hospitalizationWithObservation" ( )
      )
    return { medication.id, medication.meta, medication.code, medication.status, medication.manufacturer, medication.form, medication.amount, medication.ingredient, medication.batch }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define "SDE Chief Complaint":
  "Initial Population" IP
    where exists ( IP.diagnosis InitialPopulationDiagnosis
        where InitialPopulationDiagnosis.use ~ QICoreCommon."CC"
    )
    return { IP.id, IP.meta, IP.identifier, IP.status, IP.statusHistory, IP.class, IP.classHistory, IP.type, IP.serviceType, IP.priority, IP.subject, IP.period, IP.length, IP.reasonCode, IP.reasonReference, IP.diagnosis, IP.account, IP.hospitalization, IP.location, IP.partOf }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemiaInitialPopulation
define function "GetMedication"(reference Reference):
  singleton from ( [Medication] Medication
      where reference.references ( Medication )
  )
Logic Definition Library Name: QICoreCommon
/*
@description: Returns true if the given reference is to the given resource
@comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference.
NOTE: This function assumes resources from the same source server.
*/
define fluent function references(reference Reference, resource Resource):
  resource.id = Last(Split(reference.reference, '/'))
Logic Definition Library Name: QICoreCommon
/*
@description: Returns an interval representing the normalized prevalence period of a given Condition.
@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting 
interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
*/
define fluent function prevalenceInterval(condition Choice<"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns">):
if condition.clinicalStatus ~ "active"
  or condition.clinicalStatus ~ "recurrence"
  or condition.clinicalStatus ~ "relapse" then
  Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
else
    (end of condition.abatementInterval()) abatementDate
    return if abatementDate is null then
      Interval[start of condition.onset.toInterval(), abatementDate)
    else
      Interval[start of condition.onset.toInterval(), abatementDate]
Logic Definition Library Name: QICoreCommon
/*
@description: Returns an interval representing the normalized abatement of a given Condition.
@comment: If the abatement element of the Condition is represented as a DateTime, the result
is an interval beginning and ending on that DateTime.
If the abatement is represented as a Quantity, the quantity is expected to be a calendar-duration and is interpreted as the age of the patient. The
result is an interval from the date the patient turned that age to immediately before one year later.
If the abatement is represented as a Quantity Interval, the quantities are expected to be calendar-durations and are interpreted as an age range during
which the abatement occurred. The result is an interval from the date the patient turned the starting age of the quantity interval, and ending immediately
before one year later than the date the patient turned the ending age of the quantity interval.
*/
define fluent function abatementInterval(condition Choice<"ConditionEncounterDiagnosis", "ConditionProblemsHealthConcerns">):
	if condition.abatement is DateTime then
	  Interval[condition.abatement as DateTime, condition.abatement as DateTime]
	else if condition.abatement is Quantity then
		Interval[Patient.birthDate + (condition.abatement as Quantity),
			Patient.birthDate + (condition.abatement as Quantity) + 1 year)
	else if condition.abatement is Interval<Quantity> then
	  Interval[Patient.birthDate + (condition.abatement.low as Quantity),
		  Patient.birthDate + (condition.abatement.high as Quantity) + 1 year)
	else if condition.abatement is Interval<DateTime> then
	  Interval[condition.abatement.low, condition.abatement.high)
	else null as Interval<DateTime>
Logic Definition Library Name: QICoreCommon
/*
@description: Returns the tail of the given uri (i.e. everything after the last slash in the URI).
@comment: This function can be used to determine the logical id of a given resource. It can be used in
a single-server environment to trace references. However, this function does not attempt to resolve
or distinguish the base of the given url, and so cannot be used safely in multi-server environments.
*/
define fluent function getId(uri String):
  Last(Split(uri, '/'))
Logic Definition Library Name: QICoreCommon
/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of DateTime, Quanitty, Interval<DateTime>, or Interval<Quantity> types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in QICore, allowing this function to be used across any resource.
The input can be provided as a DateTime, Quantity, Interval<DateTime> or Interval<Quantity>.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.
If the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
If the input is a DateTime Interval, the result is the input.
If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
If the input is a Timing, an error will be thrown indicating that Timing calculations are not implemented. Any other input will reslt in a null DateTime Interval
*/
define fluent function toInterval(choice Choice<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>, Timing>):
  case
	  when choice is DateTime then
    	Interval[choice as DateTime, choice as DateTime]
		when choice is Interval<DateTime> then
  		choice as Interval<DateTime>
		when choice is Quantity then
		  Interval[Patient.birthDate + (choice as Quantity),
			  Patient.birthDate + (choice as Quantity) + 1 year)
		when choice is Interval<Quantity> then
		  Interval[Patient.birthDate + (choice.low as Quantity),
			  Patient.birthDate + (choice.high as Quantity) + 1 year)
		when choice is Timing then
      Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval<DateTime>
		else
			null as Interval<DateTime>
	end
Terminology
Code System Description: Code system ActCode
Resource: ActCode
Canonical URL: http://terminology.hl7.org/CodeSystem/v3-ActCode
Code System Description: Code system SNOMEDCT
Resource: SNOMED CT (all versions)
Canonical URL: http://snomed.info/sct
Code System Description: Code system ConditionClinicalStatusCodes
Resource: Condition Clinical Status Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/condition-clinical
Code System Description: Code system Diagnosis Role
Resource: Diagnosis Role
Canonical URL: http://terminology.hl7.org/CodeSystem/diagnosis-role
Value Set Description: Value set Encounter Inpatient
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Value Set Description: Value set Inpatient, Emergency, and Observation Locations
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.265
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.265
Value Set Description: Value set Diabetes Medications
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.58
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.58
Value Set Description: Value set Observation Services
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Value Set Description: Value set Emergency Department Visit
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Value Set Description: Value set Blood Glucose Laboratory and Point of Care Tests
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.38
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.38
Value Set Description: Value set Payer Type
Resource: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Direct Reference Code Display: inpatient non-acute
Code: NONAC
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: short stay
Code: SS
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: inpatient acute
Code: ACUTE
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: inpatient encounter
Code: IMP
System: http://terminology.hl7.org/CodeSystem/v3-ActCode
Direct Reference Code Display: Male (finding)
Code: 248153007
System: http://snomed.info/sct
Direct Reference Code Display: Female (finding)
Code: 248152002
System: http://snomed.info/sct
Direct Reference Code Display: Active
Code: active
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Display: Recurrence
Code: recurrence
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Display: Relapse
Code: relapse
System: http://terminology.hl7.org/CodeSystem/condition-clinical
Direct Reference Code Display: Chief complaint
Code: CC
System: http://terminology.hl7.org/CodeSystem/diagnosis-role
Dependencies
Dependency Description: Library FHIRHelpers
Resource: Library/FHIRHelpers|4.4.000
Canonical URL: Library/FHIRHelpers|4.4.000
Dependency Description: Library QICoreCommon
Resource: Library/QICoreCommon|4.0.000
Canonical URL: Library/QICoreCommon|4.0.000
Dependency Description: Library CQMCommon
Resource: Library/CQMCommon|4.1.000
Canonical URL: Library/CQMCommon|4.1.000
Dependency Description: Library QICoreCommon
Resource: Library/QICoreCommon|4.0.000
Canonical URL: Library/QICoreCommon|4.0.000
Dependency Description: Library FHIRHelpers
Resource: Library/FHIRHelpers|4.4.000
Canonical URL: Library/FHIRHelpers|4.4.000
Dependency Description: Library SDE
Resource: Library/SupplementalDataElements|5.1.000
Canonical URL: Library/SupplementalDataElements|5.1.000
Dependency Description: Library FHIRHelpers
Resource: Library/FHIRHelpers|4.4.000
Canonical URL: Library/FHIRHelpers|4.4.000
Dependency Description: Library FHIRHelpers
Resource: Library/FHIRHelpers|4.4.000
Canonical URL: Library/FHIRHelpers|4.4.000
Data Requirements
Data Requirement Type: Location
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-location
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, status, status.value, period
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, status, status.value, period
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Data Requirement Type: Coverage
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage
Must Support Elements: period, id, id.value, meta, status, status.value, type, policyHolder, subscriber, subscriberId, subscriberId.value, beneficiary, dependent, dependent.value, relationship, payor, class, order, order.value, network, network.value, subrogation, subrogation.value, contract
Data Requirement Type: Observation
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-observation-lab
Must Support Elements: code, effective, issued, issued.value, id, id.value, extension, text, referenceRange, component, basedOn, partOf, category, status, status.value, subject, focus, encounter, performer, value, dataAbsentReason, interpretation, note, bodySite, method, specimen, device, hasMember, derivedFrom
Code Filter(s):
Path: code
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.38
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition-problems-health-concerns
Must Support Elements: id, id.value, meta, clinicalStatus, verificationStatus, category, severity, code, bodySite, subject, encounter, encounter.reference, encounter.reference.value, onset, stage, evidence, note
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, period, class
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Data Requirement Type: Encounter
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter
Must Support Elements: type, period, class, location
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Must Support Elements: url
Data Requirement Type: ServiceRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-servicerequest
Must Support Elements: authoredOn, authoredOn.value, id, id.value, meta, instantiatesCanonical, instantiatesUri, basedOn, replaces, requisition, status, status.value, intent, intent.value, category, priority, priority.value, doNotPerform, doNotPerform.value, code, orderDetail, quantity, subject, encounter, occurrence, asNeeded, requester, performerType, performer, locationCode, reasonCode, reasonReference, insurance, bodySite, note, patientInstruction, patientInstruction.value
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Must Support Elements: id, id.value, meta, extension, identifier, active, active.value, name, telecom, gender, gender.value, birthDate, birthDate.value, deceased, address, maritalStatus, multipleBirth, photo, contact, communication, generalPractitioner, managingOrganization, link
Data Requirement Type: Medication
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medication
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationrequest
Data Requirement Type: MedicationAdministration
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-medicationadministration
Data Requirement Type: Coverage
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-coverage
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Data Requirement Type: Patient
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-patient
Must Support Elements: url, extension
Generated using version 0.4.8 of the sample-content-ig Liquid templates