Library Name |
Name |
SupplementalDataElements |
SDE Sex |
|
define "SDE Sex":
case
when Patient.gender = 'male' then "M"
when Patient.gender = 'female' then "F"
else null
end
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
SDE Sex |
|
define "SDE Sex":
SDE."SDE Sex"
|
Library Name |
Name |
AHAOverall |
Heart Failure Outpatient Encounter |
|
/*
@description: Returns certain finished encounter types that overlap a Heart Failure condition and are during the measurement period:
* care services in long term residential facility (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1014)
* home healthcare services (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1016)
* nursing facility visits (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012)
* office visits (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001)
* outpatient consolutations (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008)
*/
define "Heart Failure Outpatient Encounter":
( [Encounter: "Care Services in Long Term Residential Facility"]
union [Encounter: "Home Healthcare Services"]
union [Encounter: "Nursing Facility Visit"]
union [Encounter: "Office Visit"]
union [Encounter: "Outpatient Consultation"]
) QualifyingEncounter
with [Condition: "Heart Failure"] HeartFailure
such that HeartFailure.prevalenceInterval() overlaps QualifyingEncounter.period
and HeartFailure.isConfirmedActiveDiagnosis()
where QualifyingEncounter.period during day of "Measurement Period"
and QualifyingEncounter.isFinished()
|
Library Name |
Name |
AHAOverall |
Moderate or Severe LVSD Findings |
|
/*
@description: Returns a union of the following:
* Observations where the final, amended or correction ejection fraction result is <= 40
* Moderate or Severe LVSD conditions where the diagnosis has been confirmed as active
*/
define "Moderate or Severe LVSD Findings":
( [Observation: "Ejection Fraction"] EjectionFraction
where EjectionFraction.value as Quantity <= 40 '%'
and EjectionFraction.status in {'final', 'amended', 'corrected'}
)
union (
( [Condition: "Moderate or Severe LVSD"]
union ( [Condition: "Left ventricular systolic dysfunction (disorder)"] LVSDDiagnosis
where LVSDDiagnosis.severity in "Moderate or Severe" )
) ModerateOrSevereLVSD
where ModerateOrSevereLVSD.isConfirmedActiveDiagnosis()
)
|
Library Name |
Name |
AHAOverall |
Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD |
|
/*
@description: Returns heart failure outpatient encounters that start before the end of a moderate or severe LVSD finding
*/
define "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD":
"Heart Failure Outpatient Encounter" HFOutpatientEncounter
with "Moderate or Severe LVSD Findings" LVSDFindings
such that Coalesce(LVSDFindings.prevalenceInterval(), LVSDFindings.effective.toInterval()) starts before end of HFOutpatientEncounter.period
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Beta Blocker Therapy for LVSD Ordered |
|
define "Has Beta Blocker Therapy for LVSD Ordered":
exists ( [MedicationRequest: "Beta Blocker Therapy for LVSD"] BetaBlockerOrdered
where BetaBlockerOrdered.isOrderedDuringHeartFailureOutpatientEncounter ( )
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Is Currently Taking Beta Blocker Therapy for LVSD |
|
define "Is Currently Taking Beta Blocker Therapy for LVSD":
exists ( ["MedicationRequest": "Beta Blocker Therapy for LVSD"] ActiveBetaBlocker
where ActiveBetaBlocker.overlapsAfterHeartFailureOutpatientEncounter ( )
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Numerator |
|
define "Numerator":
"Has Beta Blocker Therapy for LVSD Ordered"
or "Is Currently Taking Beta Blocker Therapy for LVSD"
|
Library Name |
Name |
AHAOverall |
Qualifying Outpatient Encounter During Measurement Period |
|
/*
@description: Returns certain finished encounter types that occurred during the measurement period:
* office visits (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1001)
* outpatient consolutations (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1008)
* nursing facility visits (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1012)
* care services in long term residential facility (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1014)
* home healthcare services (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.464.1003.101.12.1016)
* patient provider interactions (http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.526.3.1012)
*/
define "Qualifying Outpatient Encounter During Measurement Period":
( [Encounter: "Office Visit"]
union [Encounter: "Outpatient Consultation"]
union [Encounter: "Nursing Facility Visit"]
union [Encounter: "Care Services in Long Term Residential Facility"]
union [Encounter: "Home Healthcare Services"]
union [Encounter: "Patient Provider Interaction"] ) ValidEncounter
where ValidEncounter.period during day of "Measurement Period"
and ValidEncounter.isFinished()
|
Library Name |
Name |
AHAOverall |
Is Adults With Two Qualifying Outpatient Encounters and One Heart Failure Outpatient Encounter During the Measurement Period |
|
/*
@description: Returns true if the patient meets the following criteria:
* 18 years of age or older, has two
* Has two Qualifying Outpatient Encounters During Measurement Period
* Has a Heart Failure Outpatient Encounter
*/
define "Is Adults With Two Qualifying Outpatient Encounters and One Heart Failure Outpatient Encounter During the Measurement Period":
AgeInYearsAt(date from start of "Measurement Period") >= 18
and exists ( "Qualifying Outpatient Encounter During Measurement Period" Encounter1
with "Qualifying Outpatient Encounter During Measurement Period" Encounter2
such that Encounter2.id !~ Encounter1.id
)
and exists "Heart Failure Outpatient Encounter"
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Initial Population |
|
define "Initial Population":
AHA."Is Adults With Two Qualifying Outpatient Encounters and One Heart Failure Outpatient Encounter During the Measurement Period"
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Denominator |
|
define "Denominator":
"Initial Population"
and exists AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD"
|
Library Name |
Name |
SupplementalDataElements |
SDE Payer |
|
define "SDE Payer":
[Coverage: type in "Payer Type"] Payer
return {
code: Payer.type,
period: Payer.period
}
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
SDE Payer |
|
define "SDE Payer":
SDE."SDE Payer"
|
Library Name |
Name |
SupplementalDataElements |
SDE Ethnicity |
|
define "SDE Ethnicity":
Patient.ethnicity E
return Tuple {
codes: { E.ombCategory } union E.detailed,
display: E.text
}
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
SDE Ethnicity |
|
define "SDE Ethnicity":
SDE."SDE Ethnicity"
|
Library Name |
Name |
AHAOverall |
Has Heart Transplant |
|
/*
@description: Returns completed heart tansplant procedures that start before the end of a heart failure outpatient encounter with history of moderate or severe LVSD
*/
define "Has Heart Transplant":
exists (
[Procedure: "Heart Transplant"] HeartTransplant
with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
such that HeartTransplant.performed.toInterval() starts before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
where HeartTransplant.status = 'completed'
)
|
Library Name |
Name |
AHAOverall |
Has Heart Transplant Complications |
|
/*
@description: Returns true if patient has confirmed heart transplant complications that start before the end of a heart failure outpatient encounter with history of moderate or severe LVSD
*/
define "Has Heart Transplant Complications":
exists (
[Condition: "Heart Transplant Complications"] HeartTransplantComplications
let diagnosisStart: Coalesce( HeartTransplantComplications.recordedDate, start of HeartTransplantComplications.prevalenceInterval() )
with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
such that diagnosisStart before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
where HeartTransplantComplications.isConfirmedActiveDiagnosis()
)
|
Library Name |
Name |
AHAOverall |
Has Left Ventricular Assist Device |
|
/*
@description: Returns true if patient has a completed LVAD placement that starts before the end of a heart failure outpatient encounter with history of moderate or severe LVSD
*/
define "Has Left Ventricular Assist Device":
exists (
[Procedure: "Left Ventricular Assist Device Placement"] LVADOutpatient
with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
such that LVADOutpatient.performed.toInterval() starts before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
where LVADOutpatient.status = 'completed'
)
|
Library Name |
Name |
AHAOverall |
Has Left Ventricular Assist Device Complications |
|
/*
@description: Returns true if patient has active LVAD complications that start before the end of a heart failure outpatient encounter with history of moderate or severe LVSD
*/
define "Has Left Ventricular Assist Device Complications":
exists (
[Condition: "Left Ventricular Assist Device Complications"] LVADComplications
let diagnosisStart: Coalesce( LVADComplications.recordedDate, start of LVADComplications.prevalenceInterval() )
with "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
such that diagnosisStart before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
where LVADComplications.isConfirmedActiveDiagnosis()
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Denominator Exclusions |
|
define "Denominator Exclusions":
AHA."Has Heart Transplant"
or AHA."Has Heart Transplant Complications"
or AHA."Has Left Ventricular Assist Device"
or AHA."Has Left Ventricular Assist Device Complications"
|
Library Name |
Name |
SupplementalDataElements |
SDE Race |
|
define "SDE Race":
Patient.race R
return Tuple {
codes: R.ombCategory union R.detailed,
display: R.text
}
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
SDE Race |
|
define "SDE Race":
SDE."SDE Race"
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Consecutive Heart Rates Less than 50 |
|
define "Has Consecutive Heart Rates Less than 50":
exists ( from
["observation-heartrate"] HeartRate,
AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
let PriorHeartRate: Last(["observation-heartrate"] MostRecentPriorHeartRate
where MostRecentPriorHeartRate.effective.toInterval() during ModerateOrSevereLVSDHFOutpatientEncounter.period
and MostRecentPriorHeartRate.effective.toInterval() before HeartRate.effective.toInterval()
sort by start of effective.toInterval()
)
where HeartRate.effective.toInterval ( ) during ModerateOrSevereLVSDHFOutpatientEncounter.period
and HeartRate.status in { 'final', 'amended', 'corrected' }
and HeartRate.value < 50 '/min'
and PriorHeartRate.value < 50 '/min'
return HeartRate
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Hypotension Diagnosis |
|
define "Has Hypotension Diagnosis":
exists ( ["Condition": "Hypotension"] Hypotension
where Hypotension.overlapsHeartFailureOutpatientEncounter ( )
and Hypotension.isConfirmedActiveDiagnosis ( )
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Asthma Diagnosis |
|
define "Has Asthma Diagnosis":
exists ( [Condition: "Asthma"] Asthma
where Asthma.overlapsHeartFailureOutpatientEncounter ( )
and Asthma.isConfirmedActiveDiagnosis ( )
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Diagnosis of Allergy or Intolerance to Beta Blocker Therapy |
|
define "Has Diagnosis of Allergy or Intolerance to Beta Blocker Therapy":
exists ( ( ["Condition": "Allergy to Beta Blocker Therapy"]
union ["Condition": "Intolerance to Beta Blocker Therapy"] ) BetaBlockerAllergyOrIntoleranceDiagnosis
where BetaBlockerAllergyOrIntoleranceDiagnosis.overlapsAfterHeartFailureOutpatientEncounter ( )
and BetaBlockerAllergyOrIntoleranceDiagnosis.isConfirmedActiveDiagnosis ( )
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Bradycardia Diagnosis |
|
define "Has Bradycardia Diagnosis":
exists ( [Condition: "Bradycardia"] Bradycardia
where Bradycardia.overlapsHeartFailureOutpatientEncounter ( )
and Bradycardia.isConfirmedActiveDiagnosis ( )
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Allergy or Intolerance to Beta Blocker Therapy Ingredient |
|
/*
@commentedOut: implies logic
@commentedOutReason: implies not available in cql-execution. Reference https://github.com/cqframework/cql-execution/issues/319.
*/
define "Has Allergy or Intolerance to Beta Blocker Therapy Ingredient":
exists ( ( [AllergyIntolerance: "Beta Blocker Therapy Ingredient"]
union [AllergyIntolerance: "Substance with beta adrenergic receptor antagonist mechanism of action (substance)"] ) BetaBlockerAllergyIntolerance
where BetaBlockerAllergyIntolerance.overlapsAfterHeartFailureOutpatientEncounter ( )
and ( /*https://oncprojectracking.healthit.gov/support/browse/BONNIEMAT-1771 - issue with implies operator tied to a non-supported feature in cql-exectuion
For cql-execution issue, reference https://github.com/cqframework/cql-execution/issues/319.
( BetaBlockerAllergyIntolerance.clinicalStatus is not null implies
BetaBlockerAllergyIntolerance.clinicalStatus !~ QICoreCommon."allergy-inactive" )
or */
BetaBlockerAllergyIntolerance.clinicalStatus ~ QICoreCommon."allergy-active"
)
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Atrioventricular Block Diagnosis |
|
define "Has Atrioventricular Block Diagnosis":
exists ( [Condition: "Atrioventricular Block"] AtrioventricularBlock
where AtrioventricularBlock.overlapsHeartFailureOutpatientEncounter ( )
and AtrioventricularBlock.isConfirmedActiveDiagnosis ( )
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Diagnosis of Cardiac Pacer in Situ |
|
define "Has Diagnosis of Cardiac Pacer in Situ":
exists ( ["Condition": "Cardiac Pacer in Situ"] CardiacPacerDiagnosis
where CardiacPacerDiagnosis.overlapsAfterHeartFailureOutpatientEncounter ( )
and CardiacPacerDiagnosis.isConfirmedActiveDiagnosis ( )
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Has Cardiac Pacer Device Implanted |
|
define "Has Cardiac Pacer Device Implanted":
exists ( [Procedure: "Cardiac Pacer"] ImplantedCardiacPacer
with AHA."Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
such that ImplantedCardiacPacer.performed.toInterval ( ) starts before end of ModerateOrSevereLVSDHFOutpatientEncounter.period
where ImplantedCardiacPacer.status = 'completed'
)
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Atrioventricular Block without Cardiac Pacer |
|
define "Atrioventricular Block without Cardiac Pacer":
"Has Atrioventricular Block Diagnosis"
and not "Has Diagnosis of Cardiac Pacer in Situ"
and not "Has Cardiac Pacer Device Implanted"
|
Library Name |
Name |
HFBetaBlockerTherapyforLVSDFHIR |
Denominator Exceptions |
|
/*
@commentedOuf: Temporary removal of "Has Medical or Patient Reason for Not Ordering Beta Blocker for LVSD"
@commentedOufReason: Negation issue noted in https://github.com/cqframework/cql-execution/issues/296, which is tied to https://oncprojectracking.healthit.gov/support/browse/BONNIEMAT-1455
*/
define "Denominator Exceptions":
"Has Consecutive Heart Rates Less than 50"
//or "Has Medical or Patient Reason for Not Ordering Beta Blocker for LVSD"*/or "Has Arrhythmia Diagnosis"
or "Has Hypotension Diagnosis"
or "Has Asthma Diagnosis"
or "Has Diagnosis of Allergy or Intolerance to Beta Blocker Therapy"
or "Has Bradycardia Diagnosis"
or "Has Allergy or Intolerance to Beta Blocker Therapy Ingredient"
or "Atrioventricular Block without Cardiac Pacer"
|
Library Name |
Name |
AHAOverall |
isOrderedDuringHeartFailureOutpatientEncounter |
|
/*
@description: Returns true if the given MedicationRequest is ordered during the heart failure outpatient encounter with history of moderate or severe LVSD at any point
*/
define fluent function isOrderedDuringHeartFailureOutpatientEncounter(MedicationRequest MedicationRequest):
exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
where MedicationRequest.authoredOn during day of ModerateOrSevereLVSDHFOutpatientEncounter.period
and MedicationRequest.status in {'active', 'completed'}
and MedicationRequest.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
/*Issue: The logic commented out below was added to the logic due to an issue described in the authoring patterns for QI-Core: https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns---QICore-v4.1.1#medication-ordered. However, when this logic is present, it causes an issue in Coverage calculation for resources that must be QI-Core compliant, because the inverse cannot be tested for a QI-Core MedicationRequest profile instance. This logic was commented out to achieve 100% Coverage. This requirement is really to handle what would happen if a MedicationRequest instance that could be set to 'false' were provided, but this should not happen within a trusted environment where QI-Core profile instances must be provided.*/
// and MedicationRequest.doNotPerform is not true
)
|
Library Name |
Name |
QICoreCommon |
prevalenceInterval |
|
/*
@description: Returns an interval representing the normalized prevalence period of a given Condition.
@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from
onset to abatement as specified in the given Condition. If the condition is active, or has an abatement date the resulting
interval will have a closed ending boundary. Otherwise, the resulting interval will have an open ending boundary.
*/
define fluent function prevalenceInterval(condition Condition):
if condition.clinicalStatus ~ "active"
or condition.clinicalStatus ~ "recurrence"
or condition.clinicalStatus ~ "relapse" then
Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]
else
(end of condition.abatementInterval()) abatementDate
return if abatementDate is null then
Interval[start of condition.onset.toInterval(), abatementDate)
else
Interval[start of condition.onset.toInterval(), abatementDate]
|
Library Name |
Name |
AHAOverall |
isConfirmedActiveDiagnosis |
|
/*
@description: Returns true if the given Condition is confirmed as active
*/
define fluent function isConfirmedActiveDiagnosis(condition Condition):
condition.isActive()
and condition.verificationStatus ~ QICoreCommon."confirmed"
|
Library Name |
Name |
QICoreCommon |
isActive |
|
/* Candidates for FHIRCommon */
/*
@description: Returns true if the given condition has a clinical status of active, recurrence, or relapse
*/
define fluent function isActive(condition Condition):
condition.clinicalStatus ~ "active"
or condition.clinicalStatus ~ "recurrence"
or condition.clinicalStatus ~ "relapse"
|
Library Name |
Name |
AHAOverall |
isFinished |
|
/*
@description: Returns true if the given Encounter is finished
*/
define fluent function isFinished(Encounter Encounter):
Encounter.status = 'finished'
|
Library Name |
Name |
AHAOverall |
overlapsAfterHeartFailureOutpatientEncounter |
|
/*
@overloaded
@description: Returns true if the given MedicationRequest overlaps after the day of the heart failure outpatient encounter with history of moderate or severe LVSD
*/
define fluent function overlapsAfterHeartFailureOutpatientEncounter(MedicationRequest MedicationRequest):
exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
where First( ( collapse (MedicationRequest.dosageInstruction.timing.repeat.bounds DoseTime
return DoseTime.toInterval()) ) DrugPeriods
sort by start of $this ) overlaps after day of ModerateOrSevereLVSDHFOutpatientEncounter.period
and MedicationRequest.status in { 'active', 'completed' }
and MedicationRequest.intent in { 'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order' }
/*Issue: The logic commented out below was added to the logic due to an issue described in the authoring patterns for QI-Core: https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/wiki/Authoring-Patterns---QICore-v4.1.1#medication-ordered. However, when this logic is present, it causes an issue in Coverage calculation for resources that must be QI-Core compliant, because the inverse cannot be tested for a QI-Core MedicationRequest profile instance. This logic was commented out to achieve 100% Coverage. This requirement is really to handle what would happen if a MedicationRequest instance that could be set to 'false' were provided, but this should not happen within a trusted environment where QI-Core profile instances must be provided.*/
// and Event.doNotPerform is not true
)
|
Library Name |
Name |
FHIRHelpers |
ToString |
|
define function ToString(value uri): value.value
|
Library Name |
Name |
FHIRHelpers |
ToCode |
|
/*
@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.
*/
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
}
|
Library Name |
Name |
AHAOverall |
overlapsHeartFailureOutpatientEncounter |
|
/*
@description: Returns true if the given Condition overlaps the heart failure outpatient encounter with history of moderate or severe LVSD at any point
*/
define fluent function overlapsHeartFailureOutpatientEncounter(Condition Condition):
exists ( "Heart Failure Outpatient Encounter with History of Moderate or Severe LVSD" ModerateOrSevereLVSDHFOutpatientEncounter
where Condition.prevalenceInterval() overlaps day of ModerateOrSevereLVSDHFOutpatientEncounter.period
and Condition.isConfirmedActiveDiagnosis()
)
|