Quality Measure Implementation Guide
5.0.0 - STU5 United States of America flag

This page is part of the Quality Measure STU2 for FHIR R4 Implementation Guide (v5.0.0: STU5 (v5.0.0)) based on FHIR (HL7® FHIR® Standard) R4. This is the current published version. For a full list of available versions, see the Directory of published versions

Library: Example Publishable Library (Experimental)

Official URL: http://hl7.org/fhir/us/cqfmeasures/Library/EXMPublishableLibrary Version: 2.0.0
Active as of 2019-09-03 Computable Name: EXMPublishableLibrary
Other Identifiers: http://example.org/fhir/cqi/ecqm/Library/Identifier#EXMPublishableLibrary (use: official, )

This library is used as an example in the FHIR Quality Measure Implementation Guide

Title: Example Publishable Library
Id: EXMPublishableLibrary
Version: 2.0.0
Url: http://hl7.org/fhir/us/cqfmeasures/Library/EXMPublishableLibrary
Official

EXMPublishableLibrary

Experimental: true
Type:

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

code: logic-library

Date: 2019-09-03
Publisher: HL7 International / Clinical Quality Information
Description:

This library is used as an example in the FHIR Quality Measure Implementation Guide

Jurisdiction: US
Approval Date: 2019-08-03
Related Artifacts:

Dependencies

  • http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1
  • http://fhir.org/guides/common/Library/FHIRHelpers|4.0.1
  • Diagnosis Role
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.299
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.126
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.836
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.837
  • http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Parameters:
NameTypeMinMaxIn/Out
Measurement PeriodPeriod01In
PatientPatient01Out
Inpatient EncounterEncounter0*Out
Initial PopulationEncounter0*Out
Measure PopulationEncounter0*Out
Stratifier 1Encounter0*Out
Stratifier 2Encounter0*Out
Stratifier 3Encounter0*Out
Stratifier 4Encounter0*Out
SDE EthnicityCoding0*Out
SDE PayerResource0*Out
SDE RaceCoding0*Out
SDE SexCoding01Out
Data Requirements:
TypeProfileMSCode Filter
Encounter http://hl7.org/fhir/StructureDefinition/Encounter
Encounter http://hl7.org/fhir/StructureDefinition/Encounter code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Condition http://hl7.org/fhir/StructureDefinition/Condition code filter:
path: id
Coverage http://hl7.org/fhir/StructureDefinition/Coverage code filter:
path: type
value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Content: text/cql
library EXMPublishableLibrary version '2.0.0'

/*
This example is purely for illustration purposes to show how all the elements of a
FHIR-based quality measure are represented. It is intentionally simplified to show
specific aspects of a measure, and is not intended as an example of a clinically
meaningful measure.
*/

/*
NOTE: This is the same library as EXMLogic, being used to illustrate the different flavors of profiles:
* Computable: Focusing on computable/design-time aspects
* Executable: Focusing on run-time aspects
* Publishable: Focusing on knowledge management aspects
*/

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1' called FHIRHelpers

codesystem "Diagnosis Role": 'http://terminology.hl7.org/CodeSystem/diagnosis-role'

valueset "Emergency Department Visit" : 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292'
valueset "Psychiatric/Mental Health Patient" : 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.299'
valueset "Hospital Settings" : 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.126'

valueset "ONC Administrative Sex": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1'
valueset "Race": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.836'
valueset "Ethnicity": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.837'
valueset "Payer": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591'

code "Billing": 'billing' from "Diagnosis Role" display 'Billing'

parameter "Measurement Period" Interval<DateTime>

context Patient

define "Initial Population" :
  "Inpatient Encounter" Encounter

define "Measure Population" :
  "Initial Population"

define function "Measure Observation" (Encounter "Encounter" ) :
  duration in minutes of "Related ED Visit"(Encounter).period

define "Stratifier 1" :
  "Inpatient Encounter" Encounter
    where not (PrincipalDiagnosis(Encounter).code in "Psychiatric/Mental Health Patient")

define "Stratifier 2" :
  "Inpatient Encounter" Encounter
    where PrincipalDiagnosis(Encounter).code in "Psychiatric/Mental Health Patient"

define "Stratifier 3" :
  "Inpatient Encounter" Encounter
    where PrincipalDiagnosis(Encounter) is null

define "Stratifier 4" :
  "Inpatient Encounter" Encounter
    where PrincipalDiagnosis(Encounter) is null

define "Inpatient Encounter" :
  ["Encounter"] Encounter
    where LengthInDays(Encounter.period) <= 120
      and Encounter.period ends during "Measurement Period"

define function "PrincipalDiagnosis"(Encounter Encounter):
	(singleton from (Encounter.diagnosis D where D.use ~ ToConcept("Billing") and D.rank.value = 1)) PD
		return singleton from ([Condition: id in "GetId"(PD.condition.reference)])

define function "LengthInDays"(Value Interval<DateTime>):
	difference in days between start of Value and end of Value

define function "GetId"(uri String):
	Last(Split(uri, '/'))

//Measure Observation
define function "Related ED Visit" (Encounter "Encounter" ) :
  Last(["Encounter" : "Emergency Department Visit"] ED
    where ED.status = 'finished'
      and ED.period ends 1 hour or less before start of Encounter.period
    sort by start of period )

define "SDE Ethnicity":
  (flatten (
    Patient.extension Extension
      where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity'
        return Extension.extension
  )) E
    where E.url = 'ombCategory'
      or E.url = 'detailed'
    return E.value as Coding

define "SDE Payer":
    [Coverage: type in "Payer"] Payer
      return {
        code: Payer.type,
        period: Payer.period
      }

define "SDE Race":
  (flatten (
    Patient.extension Extension
      where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race'
        return Extension.extension
  )) E
    where E.url = 'ombCategory'
      or E.url = 'detailed'
    return E.value as Coding

define "SDE Sex":
  case
    when Patient.gender = 'male' then Code { code: 'M', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Male' }
    when Patient.gender = 'female' then Code { code: 'F', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Female' }
    else null
  end
Content: application/elm+xml
Encoded data (39012 characters)
Content: application/elm+json
Encoded data (70964 characters)