Common CQL Artifacts for FHIR (US-Based)
1.0.0 - Informative 1 United States of America flag

This page is part of the Common CQL Assets for FHIR (US-Based) (v1.0.0: Informative 1 - Informative) 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: US Core Common

Official URL: http://hl7.org/fhir/us/cql/Library/USCoreCommon Version: 1.0.0
Standards status: Informative Maturity Level: 3 Computable Name: USCoreCommon

This library defines functions to expose extensions defined in USCore as fluent functions in CQL, as well as common terminology and functions used in writing CQL with FHIR and USCore profiles.

Metadata
Title US Core Common
Version 1.0.0
Jurisdiction United States of America
Topic FHIR
Topic CQL
Steward (Publisher) HL7 International / Clinical Decision Support
Description

This library defines functions to expose extensions defined in USCore as fluent functions in CQL, as well as common terminology and functions used in writing CQL with FHIR and USCore profiles.

Type logic-library from http://terminology.hl7.org/CodeSystem/library-type
Dependency Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Dependency Description: Library FHIRCommon
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Dependency Description: Code System CVX
Resource: Vaccine Administered Code Set (CVX)
Canonical URL: http://hl7.org/fhir/sid/cvx
Dependency Description: Code System ActCode
Resource: ActCode
Canonical URL: http://terminology.hl7.org/CodeSystem/v3-ActCode
Dependency Description: Code System USCoreConditionCategory
Resource: US Core Condition Category Extension Codes
Canonical URL: http://hl7.org/fhir/us/core/CodeSystem/condition-category
Dependency Description: Code System CDC Race and Ethnicity Codes
Resource: CDC Race and Ethnicity
Canonical URL: urn:oid:2.16.840.1.113883.6.238
Dependency Description: Code System CommunicationCategoryCodeSystem
Resource: CommunicationCategory
Canonical URL: http://terminology.hl7.org/CodeSystem/communication-category
Dependency Description: Code System IdentifierType
Resource: identifierType
Canonical URL: http://terminology.hl7.org/CodeSystem/v2-0203
Parameters
Name Use Card. Type Documentation
Patient Out 0..1 Patient
Library Content
CQL Content
/*
@author: Bryn Rhodes
@description: This library defines functions to expose extensions defined
in USCore as fluent functions in CQL, as well as common terminology and functions
used in writing CQL with FHIR and USCore profiles.
*/
library USCoreCommon

using FHIR version '4.0.1'
using USCore version '7.0.0'

include hl7.fhir.uv.cql.FHIRHelpers version '4.0.1'
include hl7.fhir.uv.cql.FHIRCommon version '2.0.0'

codesystem "CVX": 'http://hl7.org/fhir/sid/cvx'
codesystem "ActCode": 'http://terminology.hl7.org/CodeSystem/v3-ActCode'
codesystem "USCoreConditionCategory": 'http://hl7.org/fhir/us/core/CodeSystem/condition-category'
codesystem "CDC Race and Ethnicity Codes": 'urn:oid:2.16.840.1.113883.6.238'
codesystem "CommunicationCategoryCodeSystem": 'http://terminology.hl7.org/CodeSystem/communication-category'
codesystem "IdentifierType": 'http://terminology.hl7.org/CodeSystem/v2-0203'

code "MedicalRecordNumber": 'MR' from "IdentifierType" display 'Medical record number'

// Encounter Class Codes
code "ambulatory": 'AMB' from ActCode display 'ambulatory'
code "emergency": 'EMER' from ActCode display 'emergency'
code "field": 'FLD' from ActCode display 'field'
code "home health": 'HH' from ActCode display 'home health'
code "inpatient encounter": 'IMP' from ActCode display 'inpatient encounter'
code "inpatient acute": 'ACUTE' from ActCode display 'inpatient acute'
code "inpatient non-acute": 'NONAC' from ActCode display 'inpatient non-acute'
code "observation encounter": 'OBSENC' from ActCode display 'observation encounter'
code "pre-admission": 'PRENC' from ActCode display 'pre-admission'
code "short stay": 'SS' from ActCode display 'short stay'
code "virtual": 'VR' from ActCode display 'VR'

// Condition Category Codes
code "health-concern": 'health-concern' from "USCoreConditionCategory" display 'Health Concern'

code "Systolic Blood Pressure": '8480-6' from FHIRCommon.LOINC
code "Diastolic Blood Pressure": '8462-4' from FHIRCommon.LOINC
code "BMI": '39156-5' from FHIRCommon.LOINC

context Patient

define fluent function race(patient Patient):
  (patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-race')) E
    return {
      ombCategory: (E.exts('ombCategory')) o return o.value as FHIR.Coding,
      detailed: (E.exts('detailed')) d return d.value as FHIR.Coding,
      text: E.ext('text').value as FHIR.string
    }

define fluent function ethnicity(patient Patient):
  (patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity')) E
    return {
      ombCategory: E.ext('ombCategory').value as FHIR.Coding,
      detailed: (E.exts('detailed')) d return d.value as FHIR.Coding,
      text: E.ext('text').value as FHIR.string
    }

define fluent function tribalAffiliation(patient Patient):
  (patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-tribal-affiliation')) E
    return {
      tribalAffiliation: E.ext('tribalAffiliation').value as CodeableConcept,
      isEnrolled: E.ext('isEnrolled').value as boolean
    }

define fluent function birthSex(patient Patient):
  patient.ext('http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex').value as FHIR.code

define fluent function systolic(bloodPressure Observation):
  singleton from (
    bloodPressure.component C
      where C.code ~ "Systolic Blood Pressure"
  )

define fluent function diastolic(bloodPressure Observation):
  singleton from (
    bloodPressure.component C
      where C.code ~ "Diastolic Blood Pressure"
  )

/*
@description: Returns true if the given condition is a health concern
*/
define fluent function isHealthConcern(condition FHIR.Condition):
  exists (
    condition.category C
      where C ~ "health-concern"
  )

ELM XML Content
Encoded data 
ELM JSON Content
Encoded data 
Generated using version 0.5.3-cibuild of the sample-content-ig Liquid templates