Quality Measure Implementation Guide

This page is part of the Quality Measure STU2 for FHIR R4 Implementation Guide (v0.1.0: STU 1 Ballot 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-library-vte-icu-FHIR

Formats: XML, JSON, Turtle

Id: Library/library-vte-icu-FHIR
Type: system: http://hl7.org/fhir/library-type
code: logic-library
Identifier: system: http://example.org/fhir/cqi/ecqm/Library/Identifier
value: VTEICU_FHIR
Version: 2.4.000
Title: VTE ICU FHIR
Status: active
Description: This library is used as an example in the FHIR Quality Measure Implementation Guide
Related:

type: depends-on

Resource:
reference: Library/library-fhir-helpers

type: depends-on

Resource:
reference: Library/library-mat-global-common-functions-FHIR

Content: type: text/cql
library VTEICU_FHIR version '2.4.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 FHIRHelpers version '3.0.0' called FHIRHelpers
include MATGlobalCommonFunctions_FHIR version '2.0.000' called Common

// TODO: Determine how to reference a particular version of LOINC

codesystem "LOINC:2.46": 'http://loinc.org' version 'urn:hl7:version:2.46'
codesystem "SNOMEDCT:2016-03": 'http://snomed.info/sct/731000124108' version 'http://snomed.info/sct/731000124108/version/201603'

valueset "Intensive Care Unit": 'https://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.23'

code "Birthdate": '21112-8' from "LOINC:2.46" display 'Birth date'
code "Dead": '419099009' from "SNOMEDCT:2016-03" display 'Dead'

parameter "Measurement Period" Interval<DateTime>

context Patient

define function "ToDate"(Value DateTime):
  DateTime(year from Value, month from Value, day from Value, 0, 0, 0, 0, timezone from Value)

define function "CalendarDayOfOrDayAfter"(StartValue DateTime):
  Interval[StartValue, ToDate(StartValue + 2 days))

define function "Start of First ICU"(Encounter "Encounter"):
  start of "First Intensive Care Unit"(Encounter).period

define function "First Intensive Care Unit"(Encounter "Encounter"):
  First(Encounter.location L
      where Common.GetLocation(L.location).type in "Intensive Care Unit"
        and L.period during Encounter.period
      sort by start of period
  )