Your User Friendly Name for MyContentIG Here
0.4.6 - CI Build International flag

Your User Friendly Name for MyContentIG Here, published by HL7 International - [Some] Work Group. This guide is not an authorized publication; it is the continuous build for version 0.4.6 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/sample-content-ig/ and changes regularly. See the Directory of published versions

Measure: Discharged on Antithrombotic Therapy FHIR Example

Official URL: http://somewhere.org/fhir/uv/mycontentig/Measure/DischargedonAntithromboticTherapyFHIRExample Version: 0.4.6
Draft as of 2024-05-06 Computable Name: DischargedonAntithromboticTherapyFHIRExample
Other Identifiers: Short Name (use: usual, ), UUID:4f57e4a2-097b-45f8-9c85-91b35ea92dc1 (use: official, ), UUID:e0b5379f-4b9c-4177-a530-d744fa95d080 (use: official, ), Publisher (use: official, )

Usage:Program: EH/CAH

Copyright/Legal: Measure specifications are in the Public Domain

LOINC(R) copyright 2004-2022 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2022 International Health Terminology Standards Development Organisation. ICD-10 copyright 2021 World Health Organization. All Rights Reserved.

Ischemic stroke patients prescribed or continuing to take antithrombotic therapy at hospital discharge

UNKNOWN

Knowledge Artifact Metadata
Name (machine-readable) DischargedonAntithromboticTherapyFHIRExample
Title (human-readable) Discharged on Antithrombotic Therapy FHIR Example
Status Draft
Experimental false
Description

Ischemic stroke patients prescribed or continuing to take antithrombotic therapy at hospital discharge

Purpose

UNKNOWN

Clinical Usage The "Nonelective Inpatient Encounter" value set intends to capture all non-scheduled hospitalizations. This value set is a subset of the "Inpatient encounter" value set, excluding concepts that specifically refer to elective hospital admissions. Non-elective admissions include emergency, urgent and unplanned admissions. The "MedicationRequest" datatype refers to the discharge medication list and is intended to express medications ordered for post-discharge use. The denominator population includes patients with inpatient hospitalizations and patients from Acute Hospital Care at Home programs, who are treated and billed as inpatients but receive care in their home. This eCQM is an episode-based measure. An episode is defined as each inpatient hospitalization or encounter that ends during the measurement period. This FHIR-based measure has been derived from the QDM-based measure: CMS104v12. Please refer to the HL7 QI-Core Implementation Guide (http://hl7.org/fhir/us/qicore/index.html) for more information on QI-Core and mapping recommendations from QDM to QI-Core 4.1.1 (http://hl7.org/fhir/us/qicore/qdm-to-qicore.html).
Approval Date 2023-08-01
Effective Period 2024-01-01..2024-12-31
Use Context Program (Details: UsageContextType code program = ' Program ', stated as ' null '): EH/CAH
Measure Developer The Joint Commission: https://www.jointcommission.org/
Measure Steward HL7 International - [Some] Work Group
Steward Contact Details http://hl7.org/Special/committees/[something]
Copyright

Measure specifications are in the Public Domain

LOINC(R) copyright 2004-2022 Regenstrief Institute, Inc. This material contains SNOMED Clinical Terms(R) (SNOMED CT[R]) copyright 2004-2022 International Health Terminology Standards Development Organisation. ICD-10 copyright 2021 World Health Organization. All Rights Reserved.

Measure Metadata
Short Name Identifier CMS104FHIR
Version Independent Identifier urn:uuid:4f57e4a2-097b-45f8-9c85-91b35ea92dc1
Version Specific Identifier urn:uuid:e0b5379f-4b9c-4177-a530-d744fa95d080
Publisher (CMS) Identifier 104FHIR
Version Number 0.4.6
Rationale

The effectiveness of antithrombotic agents in reducing stroke mortality, stroke-related morbidity and recurrence rates has been studied in several large clinical trials. While the use of these agents for patients with acute ischemic stroke and transient ischemic attacks continues to be the subject of study, substantial evidence is available from completed studies. Data at this time suggest that antithrombotic therapy should be prescribed at discharge following acute ischemic stroke to reduce stroke mortality and morbidity as long as no contraindications exist.

or patients with a stroke due to a cardioembolic source (e.g. atrial fibrillation, mechanical heart valve), warfarin is recommended unless contraindicated. In recent years, novel oral anticoagulant agents (NOACs) have been developed and approved by the U.S. Food and Drug Administration (FDA) for stroke prevention, and may be considered as an alternative to warfarin for select patients. Anticoagulation therapy is not generally recommended for secondary stroke prevention in patients presumed to have a non-cardioembolic stroke. Anticoagulants at doses to prevent venous thromboembolism are insufficient antithrombotic therapy to prevent recurrent ischemic stroke or transient ischemic attack (TIA).

Clinical Recommendation Statement

Clinical trial results suggest that antithrombotic therapy should be prescribed at discharge following acute ischemic stroke to reduce stroke mortality and morbidity as long as no contraindications exist

Supplemental Data Guidance Patient's Ethnicity: Hispanic or Latino Not Hispanic or Latino Patient's Payer: Categories of types of health care payer entities as defined by the US Public Health Data Consortium SOP code system Patient's Race: Native Hawaiian or Other Pacific Islander Asian American Indian or Alaska Native Other Race White Black or African American Patient's Sex: Gender identity restricted to only Male and Female used in administrative situations requiring a restriction to these two categories.
Measure Population Criteria (ID: 64403d17d4d7050edabb0562)
Initial Population ID: 937BAF2A-D36A-4EE5-B2B2-762A0FE04502
Description:

Inpatient hospitalizations for patients age 18 and older, discharged from inpatient care (non-elective admissions) with a principal diagnosis of ischemic or hemorrhagic stroke and a length of stay less than or equal to 120 days that ends during the measurement period

Logic Definition: Initial Population
Denominator ID: 302C1DCC-7FE6-41EF-A94E-FDAE24B7BB1B
Description:

Inpatient hospitalizations for patients with a principal diagnosis of Ischemic stroke

Logic Definition: Denominator
Denominator Exclusion ID: 4B649804-9C55-4949-8CE0-01B462CAA74C
Description:

- Inpatient hospitalizations for patients admitted for elective carotid intervention. This exclusion is implicitly modeled by only including non-elective hospitalizations. - Inpatient hospitalizations for patients discharged to another hospital - Inpatient hospitalizations for patients who left against medical advice - Inpatient hospitalizations for patients who expired - Inpatient hospitalizations for patients discharged to home for hospice care - Inpatient hospitalizations for patients discharged to a health care facility for hospice care - Inpatient hospitalizations for patients with comfort measures documented

Logic Definition: Denominator Exclusions
Denominator Exception ID: 516A3DD0-69B0-49EF-BBD3-12809CDC843E
Description:

- Inpatient hospitalizations for patients with a documented reason for not prescribing antithrombotic therapy at discharge. - Inpatient hospitalizations for patients who receive Prasugrel as an antithrombotic therapy at discharge.

Logic Definition: Denominator Exceptions
Numerator ID: 99961E3A-EFC4-4858-A3EE-F7F1D5B222FB
Description:

Inpatient hospitalizations for patients prescribed or continuing to take antithrombotic therapy at hospital discharge

Logic Definition: Numerator
Numerator Exclusion ID: 5f33f3ea-6ffb-4897-85dd-872dd7ac55b8
Description: No description provided
Population Basis Encounter
Scoring Proportion
Type Process
Supplemental Data Elements
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 Discharged on Antithrombotic Therapy FHIR Example
Dependency Description: Library SDE
Resource: Supplemental Data Elements Example
Canonical URL: http://somewhere.org/fhir/uv/mycontentig/Library/SupplementalDataElementsExample
Dependency Description: Library TJC
Resource: TJC Overall Example
Canonical URL: http://somewhere.org/fhir/uv/mycontentig/Library/TJCOverallExample
Dependency Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/Library/FHIRHelpers|4.0.1
Dependency Description: Library CQMCommon
Resource: CQM Common Example
Canonical URL: http://somewhere.org/fhir/uv/mycontentig/Library/CQMCommonExample
Dependency Description: Library QICoreCommon
Resource: QICore Common Example
Canonical URL: http://somewhere.org/fhir/uv/mycontentig/Library/QICoreCommonExample
Dependency Description: Code system MedicationRequestCategory
Resource: MedicationRequest Category Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/medicationrequest-category
Dependency Description: Value set Nonelective Inpatient Encounter
Resource: Non-Elective Inpatient Encounter
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.424
Dependency Description: Value set Hemorrhagic Stroke
Resource: Hemorrhagic Stroke
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.212
Dependency Description: Value set Ischemic Stroke
Resource: Ischemic Stroke
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.247
Dependency Description: Value set Antithrombotic Therapy for Ischemic Stroke
Resource: Antithrombotic Therapy
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.62
Dependency Description: Value set Payer Type
Resource: Payer
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
Dependency Description: Value set Discharge To Acute Care Facility
Resource: Discharge To Acute Care Facility
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.87
Dependency Description: Value set Left Against Medical Advice
Resource: Left Against Medical Advice
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.308
Dependency Description: Value set Patient Expired
Resource: Patient Expired
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.309
Dependency Description: Value set Discharged to Home for Hospice Care
Resource: Discharged to Home for Hospice Care
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.209
Dependency Description: Value set Discharged to Health Care Facility for Hospice Care
Resource: Discharged to Health Care Facility for Hospice Care
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.207
Dependency Description: Value set Comfort Measures
Resource: Comfort Measures
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/1.3.6.1.4.1.33895.1.3.0.45
Dependency Description: Value set Observation Services
Resource: Observation Services
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143
Dependency Description: Value set Emergency Department Visit
Resource: Emergency Department Visit
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
Dependency Description: Value set Medical Reason For Not Providing Treatment
Resource: Medical Reason
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.473
Dependency Description: Value set Patient Refusal
Resource: Patient Refusal
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.93
Dependency Description: Value set Pharmacological Contraindications For Antithrombotic Therapy
Resource: Pharmacological Contraindications For Antithrombotic Therapy
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1110.52
Direct Reference Code Display: Community
Code: community
System: http://terminology.hl7.org/CodeSystem/medicationrequest-category
Direct Reference Code Display: Discharge
Code: discharge
System: http://terminology.hl7.org/CodeSystem/medicationrequest-category
Parameter Name: Measurement Period
Use: In
Min Cardinality: 0
Max Cardinality: 1
Type: Period
Parameter Name: SDE Sex
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: Coding
Parameter Name: Numerator
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: Denominator
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Payer
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: Initial Population
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Ethnicity
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: Resource
Parameter Name: Denominator Exclusions
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Parameter Name: SDE Race
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: Resource
Parameter Name: Denominator Exceptions
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: Resource
Measure Logic Data Requirements
Data Requirement Type: Patient
Profile(s): QICore Patient
Must Support Elements: url, extension
Data Requirement Type: Encounter
Profile(s): QICore Encounter
Must Support Elements: type, period, rank, rank.value, condition, condition.reference, condition.reference.value, hospitalization, hospitalization.dischargeDisposition
Code Filter(s):
Path: type
ValueSet: Non-Elective Inpatient Encounter
Data Requirement Type: Encounter
Profile(s): QICore Encounter
Must Support Elements: type, status, status.value, period, rank, rank.value, condition, condition.reference, condition.reference.value, hospitalization, hospitalization.dischargeDisposition
Code Filter(s):
Path: type
ValueSet: Observation Services
Data Requirement Type: Encounter
Profile(s): QICore Encounter
Must Support Elements: type, status, status.value, period, rank, rank.value, condition, condition.reference, condition.reference.value, hospitalization, hospitalization.dischargeDisposition
Code Filter(s):
Path: type
ValueSet: Emergency Department Visit
Data Requirement Type: Condition
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-condition
Must Support Elements: id, id.value
Data Requirement Type: MedicationRequest
Profile(s): QICore MedicationRequest
Must Support Elements: medication, authoredOn, authoredOn.value, status, status.value, intent, intent.value, doNotPerform, doNotPerform.value
Code Filter(s):
Path: medication
ValueSet: Antithrombotic Therapy
Data Requirement Type: MedicationRequest
Profile(s): QICore MedicationRequest
Must Support Elements: medication, authoredOn, authoredOn.value, status, status.value, intent, intent.value, doNotPerform, doNotPerform.value
Code Filter(s):
Path: medication
ValueSet: Pharmacological Contraindications For Antithrombotic Therapy
Data Requirement Type: MedicationRequest
Profile(s): QICore MedicationRequest
Must Support Elements: medication.reference, authoredOn, authoredOn.value, status, status.value, intent, intent.value, doNotPerform, doNotPerform.value
Data Requirement Type: Medication
Profile(s): QICore Medication
Must Support Elements: id
Data Requirement Type: Coverage
Profile(s): QICore Coverage
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: Payer
Data Requirement Type: ServiceRequest
Profile(s): QICore ServiceRequest
Must Support Elements: code, status, status.value, intent, intent.value, doNotPerform, doNotPerform.value
Code Filter(s):
Path: code
ValueSet: Comfort Measures
Data Requirement Type: Procedure
Profile(s): QICore Procedure
Must Support Elements: code, status, status.value
Code Filter(s):
Path: code
ValueSet: Comfort Measures
Data Requirement Type: MedicationRequest
Profile(s): http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-mednotrequested
Must Support Elements: medication, reasonCode, intent, intent.value, authoredOn, authoredOn.value
Code Filter(s):
Path: medication
ValueSet: Antithrombotic Therapy
Measure Logic Definitions
Logic Definition Library Name: SupplementalDataElementsExample
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
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "SDE Sex":
  SDE."SDE Sex"
Logic Definition Library Name: TJCOverallExample
define "Non Elective Inpatient Encounter":
  ["Encounter": "Nonelective Inpatient Encounter"] NonElectiveEncounter
        where NonElectiveEncounter.period ends during day of "Measurement Period"
Logic Definition Library Name: TJCOverallExample
define "All Stroke Encounter":
  "Non Elective Inpatient Encounter" NonElectiveEncounter
  let ConditionCode: NonElectiveEncounter.principalDiagnosis().code
    where ( ConditionCode in "Hemorrhagic Stroke"
       or   ConditionCode in "Ischemic Stroke" )
Logic Definition Library Name: TJCOverallExample
define "Encounter with Principal Diagnosis and Age":
  "All Stroke Encounter" AllStrokeEncounter
    where AgeInYearsAt(date from start of AllStrokeEncounter.period ) >= 18
Logic Definition Library Name: TJCOverallExample
define "Ischemic Stroke Encounter":
  "Encounter with Principal Diagnosis and Age" EncounterWithAge
    where EncounterWithAge.principalDiagnosis().code in "Ischemic Stroke"
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Numerator":
  TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
    with ["MedicationRequest": "Antithrombotic Therapy for Ischemic Stroke"] DischargeAntithrombotic
      such that DischargeAntithrombotic.authoredOn during IschemicStrokeEncounter.period
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Denominator":
  TJC."Ischemic Stroke Encounter"
Logic Definition Library Name: SupplementalDataElementsExample
define "SDE Payer":
  [Coverage: type in "Payer Type"] Payer
    return {
      code: Payer.type,
      period: Payer.period
    }
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "SDE Payer":
  SDE."SDE Payer"
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Initial Population":
  TJC."Encounter with Principal Diagnosis and Age"
Logic Definition Library Name: SupplementalDataElementsExample
define "SDE Ethnicity":
  Patient.ethnicity E
    return Tuple {
      codes: { E.ombCategory } union E.detailed,
      display: E.text
    }
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "SDE Ethnicity":
  SDE."SDE Ethnicity"
Logic Definition Library Name: TJCOverallExample
define "Ischemic Stroke Encounters with Discharge Disposition":
  "Ischemic Stroke Encounter" IschemicStrokeEncounter
  let DischDisp: IschemicStrokeEncounter.hospitalization.dischargeDisposition
  	where  DischDisp in "Discharge To Acute Care Facility"
		or DischDisp in "Left Against Medical Advice"
		or DischDisp in "Patient Expired"
		or DischDisp in "Discharged to Home for Hospice Care"
		or DischDisp in "Discharged to Health Care Facility for Hospice Care"
Logic Definition Library Name: TJCOverallExample
define "Intervention Comfort Measures":
  ( ["ServiceRequest": code in "Comfort Measures"] SR
    where SR.status in { 'active', 'completed', 'on-hold' }
      and SR.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
      and SR.doNotPerform is not true
  )  
  union ( ["Procedure": "Comfort Measures"] InterventionPerformed
        where InterventionPerformed.status in { 'completed', 'in-progress' }
  )
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Encounter with Comfort Measures during Hospitalization for Patients with Documented Ischemic Stroke":
  "Denominator" Encounter
    with TJC."Intervention Comfort Measures" ComfortMeasure
      such that Coalesce(start of ComfortMeasure.performed.toInterval(), ComfortMeasure.authoredOn) during Encounter.hospitalizationWithObservation ( )
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Denominator Exclusions":
  TJC."Ischemic Stroke Encounters with Discharge Disposition"
    union "Encounter with Comfort Measures during Hospitalization for Patients with Documented Ischemic Stroke"
Logic Definition Library Name: SupplementalDataElementsExample
define "SDE Race":
  Patient.race R
    return Tuple {
      codes: R.ombCategory union R.detailed,
      display: R.text
    }
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "SDE Race":
  SDE."SDE Race"
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Reason for Not Giving Antithrombotic at Discharge":
  ["MedicationNotRequested": "Antithrombotic Therapy for Ischemic Stroke"] NoAntithromboticDischarge
    where ( NoAntithromboticDischarge.reasonCode in "Medical Reason For Not Providing Treatment"
        or NoAntithromboticDischarge.reasonCode in "Patient Refusal"
    )
      and ( NoAntithromboticDischarge.isCommunity ( )
          or NoAntithromboticDischarge.isDischarge ( )
      )
      and NoAntithromboticDischarge.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Encounter with Documented Reason for No Antithrombotic At Discharge":
  TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
    with "Reason for Not Giving Antithrombotic at Discharge" NoDischargeAntithrombotic
      such that NoDischargeAntithrombotic.authoredOn during IschemicStrokeEncounter.period
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Pharmacological Contraindications for Antithrombotic Therapy at Discharge":
  ["MedicationRequest": "Pharmacological Contraindications For Antithrombotic Therapy"] Pharmacological
    where ( Pharmacological.isCommunity ( )
        or Pharmacological.isDischarge ( )
    )
      and Pharmacological.status in { 'active', 'completed' }
      and Pharmacological.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
      and Pharmacological.doNotPerform is not true
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Encounter with Pharmacological Contraindications for Antithrombotic Therapy at Discharge":
  TJC."Ischemic Stroke Encounter" IschemicStrokeEncounter
    with "Pharmacological Contraindications for Antithrombotic Therapy at Discharge" DischargePharmacological
      such that DischargePharmacological.authoredOn during IschemicStrokeEncounter.period
Logic Definition Library Name: DischargedonAntithromboticTherapyFHIRExample
define "Denominator Exceptions":
  "Encounter with Documented Reason for No Antithrombotic At Discharge"
    union "Encounter with Pharmacological Contraindications for Antithrombotic Therapy at Discharge"
Logic Definition Library Name: CQMCommonExample
/*
@description: Returns the condition that is specified as the principal diagnosis for the encounter
*/
define fluent function principalDiagnosis(Encounter Encounter ):
	singleton from ((Encounter.diagnosis D where D.rank = 1) PD
      return singleton from ([Condition] C where C.id = PD.condition.reference.getId())
	)
Logic Definition Library Name: QICoreCommonExample
/*
@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: FHIRHelpers
define function ToString(value uri): value.value
Logic Definition Library Name: FHIRHelpers
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: CQMCommonExample
/*
@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
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: QICoreCommonExample
/*
@description: Returns true if the given MedicationRequest has a category of Community
*/
define fluent function isCommunity(medicationRequest MedicationNotRequested):
  exists (medicationRequest.category C
    where C ~ Community
  )
Logic Definition Library Name: QICoreCommonExample
/*
@description: Returns true if the given MedicationRequest has a category of Discharge
*/
define fluent function isDischarge(medicationRequest MedicationNotRequested):
  exists (medicationRequest.category C
    where C ~ Discharge
  )
Generated using version 0.4.6 of the sample-content-ig Liquid templates