Quality Measure STU1 for FHIR STU3 Implementation Guide

This page is part of the Quality Measure STU2 for FHIR R4 Implementation Guide (v1.0.0: STU 1) based on FHIR R3. The current version which supercedes this version is 3.0.0. For a full list of available versions, see the Directory of published versions

Library-hospice-fhir

Formats: XML, JSON, Turtle

Id: hospice-fhir
Type:
system: http://hl7.org/fhir/library-type
code: logic-library
Version: 1.0.000
Status: active
Related:

type: depends-on

Resource:
reference: Library/matglobalcommonfunctions-fhir

type: depends-on

Resource:
reference: Library/fhirhelpers

Data Requirements:

type: Encounter

code filter:
path: type
valueset: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307

type: Encounter

code filter:
path: type
valueset: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292

type: Condition

code filter:
path: id

type: Condition

code filter:
path: id

type: Location

code filter:
path: id

type: Encounter

code filter:
path: type
valueset: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307

type: ProcedureRequest

code filter:
path: code
valueset: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1108.15

type: Procedure

code filter:
path: code
valueset: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1108.15

Content: type: text/cql
library Hospice_FHIR version '1.0.000'

/*
This example is a work in progress and should not be considered a final specification
or recommendation for guidance. This example will help guide and direct the process
of finding conventions and usage patterns that meet the needs of the various stakeholders
in the measure development community.
*/

using FHIR version '3.0.0'

include MATGlobalCommonFunctions_FHIR version '2.0.000' called Global
include FHIRHelpers version '3.0.0' called FHIRHelpers

codesystem "SNOMED CT:2017-09": 'http://snomed.info/sct' version 'http://snomed.info/sct/731000124108/version/201709'

valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307'
valueset "Hospice care ambulatory": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1108.15'

code "Discharge to healthcare facility for hospice care (procedure)": '428371000124100' from "SNOMED CT:2017-09" display 'Discharge to healthcare facility for hospice care (procedure)'
code "Discharge to home for hospice care (procedure)": '428361000124107' from "SNOMED CT:2017-09" display 'Discharge to home for hospice care (procedure)'

context Patient

define function "Has Hospice"(MeasurementPeriod Interval<DateTime>):
	exists (
	    [Encounter: "Encounter Inpatient"] DischargeHospice
			where DischargeHospice.status = 'final'
			    and (
			        FHIRHelpers.ToConcept(DischargeHospice.hospitalization.dischargeDisposition).codes[0] ~ "Discharge to home for hospice care (procedure)"
					    or FHIRHelpers.ToConcept(DischargeHospice.hospitalization.dischargeDisposition).codes[0] ~ "Discharge to healthcare facility for hospice care (procedure)"
			    )
				and DischargeHospice.period ends during day of MeasurementPeriod
	)
    or exists (
        [ProcedureRequest: "Hospice care ambulatory"] HospiceOrder
            where HospiceOrder.intent = 'order'
                and HospiceOrder.authoredOn in day of MeasurementPeriod
    )
    or exists (
        [Procedure: "Hospice care ambulatory"] HospicePerformed
            where HospicePerformed.status = 'completed'
                and Global."Get Choice Interval - dateTime or Period"(HospicePerformed.performed) overlaps MeasurementPeriod
    )