| 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 |
| PCSBPScreeningFollowUpFHIR |
SDE Sex |
|
define "SDE Sex":
SDE."SDE Sex"
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Qualifying Encounter during Measurement Period |
|
define "Qualifying Encounter during Measurement Period":
[Encounter: "Encounter to Screen for Blood Pressure"] ValidEncounter
where ValidEncounter.period during day of "Measurement Period"
and ValidEncounter.status ~ 'finished'
and ValidEncounter.class !~ "virtual"
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Normal Blood Pressure Reading |
|
define "Encounter with Normal Blood Pressure Reading":
"Qualifying Encounter during Measurement Period" QualifyingEncounter
let EncounterLastBP: Last(["observation-bp"] BloodPressure
where BloodPressure.effective.toInterval() ends during QualifyingEncounter.period
and BloodPressure.status in { 'final', 'amended', 'corrected' }
sort by start of effective.toInterval()
)
where EncounterLastBP.SystolicBP.value in Interval[1 'mm[Hg]', 120 'mm[Hg]' )
and EncounterLastBP.DiastolicBP.value in Interval[1 'mm[Hg]', 80 'mm[Hg]' )
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Elevated Blood Pressure Reading SBP 120 to 129 AND DBP less than 80 |
|
define "Encounter with Elevated Blood Pressure Reading SBP 120 to 129 AND DBP less than 80":
"Qualifying Encounter during Measurement Period" QualifyingEncounter
let EncounterLastBP: Last(["observation-bp"] BloodPressure
where BloodPressure.effective.toInterval() ends during QualifyingEncounter.period
and BloodPressure.status in { 'final', 'amended', 'corrected' }
sort by start of effective.toInterval()
)
where ( EncounterLastBP.SystolicBP.value in Interval[120 'mm[Hg]', 129 'mm[Hg]']
and EncounterLastBP.DiastolicBP.value in Interval[1 'mm[Hg]', 80 'mm[Hg]' )
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Follow up with Rescreen Within 6 Months |
|
define "Follow up with Rescreen Within 6 Months":
[ServiceRequest: "Follow Up Within 6 Months"] FollowUp
where FollowUp.intent ~ 'order'
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
NonPharmacological Interventions |
|
define "NonPharmacological Interventions":
( [ServiceRequest: "Lifestyle Recommendation"]
union [ServiceRequest: "Weight Reduction Recommended"]
union [ServiceRequest: "Dietary Recommendations"]
union [ServiceRequest: "Recommendation to Increase Physical Activity"]
union [ServiceRequest: "Referral or Counseling for Alcohol Consumption"] ) NonPharmaInterventions
where NonPharmaInterventions.intent ~ 'order'
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Referral to Alternate or Primary Healthcare Professional for Hypertensive Reading |
|
define "Referral to Alternate or Primary Healthcare Professional for Hypertensive Reading":
[ServiceRequest: "Referral to Primary Care or Alternate Provider"] Referral
where Referral.reasonCode in "Finding of Elevated Blood Pressure or Hypertension"
and Referral.intent ~ 'order'
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Elevated Blood Pressure Reading SBP 120 to 129 AND DBP less than 80 and Interventions |
|
define "Encounter with Elevated Blood Pressure Reading SBP 120 to 129 AND DBP less than 80 and Interventions":
( "Encounter with Elevated Blood Pressure Reading SBP 120 to 129 AND DBP less than 80" ElevatedEncounter
with "Follow up with Rescreen Within 6 Months" Twoto6MonthRescreen
such that Twoto6MonthRescreen.authoredOn during day of ElevatedEncounter.period
with "NonPharmacological Interventions" NonPharmInterventions
such that NonPharmInterventions.authoredOn during day of ElevatedEncounter.period
)
union ( "Encounter with Elevated Blood Pressure Reading SBP 120 to 129 AND DBP less than 80" ElevatedEncounter
with "Referral to Alternate or Primary Healthcare Professional for Hypertensive Reading" Referral
such that Referral.authoredOn during day of ElevatedEncounter.period
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Hypertensive Reading Within Year Prior |
|
define "Encounter with Hypertensive Reading Within Year Prior":
( "Qualifying Encounter during Measurement Period" QualifyingEncounter
let EncounterLastBP: Last(["observation-bp"] BloodPressure
where BloodPressure.effective.toInterval() ends 1 year or less before or on start of QualifyingEncounter.period
and BloodPressure.status in { 'final', 'amended', 'corrected' }
sort by start of effective.toInterval()
)
where ( EncounterLastBP.SystolicBP.value > 0 'mm[Hg]'
and EncounterLastBP.DiastolicBP.value > 0 'mm[Hg]'
and ( EncounterLastBP.SystolicBP.value >= 130 'mm[Hg]'
or EncounterLastBP.DiastolicBP.value >= 80 'mm[Hg]'
)
)
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with First Hypertensive Reading SBP Greater than or Equal to 130 OR DBP Greater than or Equal to 80 |
|
define "Encounter with First Hypertensive Reading SBP Greater than or Equal to 130 OR DBP Greater than or Equal to 80":
( "Qualifying Encounter during Measurement Period" QualifyingEncounter
let EncounterLastBP: Last(["observation-bp"] BloodPressure
where BloodPressure.effective.toInterval() ends during day of QualifyingEncounter.period
sort by start of effective.toInterval()
)
where ( ( EncounterLastBP.SystolicBP.value > 0 'mm[Hg]'
and EncounterLastBP.DiastolicBP.value > 0 'mm[Hg]'
)
and ( EncounterLastBP.SystolicBP.value >= 130 'mm[Hg]'
or EncounterLastBP.DiastolicBP.value >= 80 'mm[Hg]'
)
)
)
except "Encounter with Hypertensive Reading Within Year Prior"
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
First Hypertensive Reading Interventions or Referral to Alternate Professional |
|
define "First Hypertensive Reading Interventions or Referral to Alternate Professional":
( [ServiceRequest: "Follow Up Within 4 Weeks"] FourWeekRescreen
with "NonPharmacological Interventions" NonPharmInterventionsHTN
such that FourWeekRescreen.authoredOn during day of "Measurement Period"
and NonPharmInterventionsHTN.authoredOn during day of "Measurement Period"
and FourWeekRescreen.intent ~ 'order'
)
union ( "Referral to Alternate or Primary Healthcare Professional for Hypertensive Reading" )
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with First Hypertensive Reading SBP Greater than or Equal to 130 OR DBP Greater than or Equal to 80 and Interventions |
|
define "Encounter with First Hypertensive Reading SBP Greater than or Equal to 130 OR DBP Greater than or Equal to 80 and Interventions":
"Encounter with First Hypertensive Reading SBP Greater than or Equal to 130 OR DBP Greater than or Equal to 80" FirstHTNEncounter
with "First Hypertensive Reading Interventions or Referral to Alternate Professional" FirstHTNIntervention
such that FirstHTNIntervention.authoredOn during day of FirstHTNEncounter.period
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 |
|
define "Encounter with Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89":
( "Qualifying Encounter during Measurement Period" QualifyingEncounter
let EncounterLastBP: Last(["observation-bp"] BloodPressure
where BloodPressure.effective.toInterval() ends during day of QualifyingEncounter.period
and BloodPressure.status in { 'final', 'amended', 'corrected' }
sort by start of effective.toInterval()
)
where ( ( EncounterLastBP.SystolicBP.value in Interval[130 'mm[Hg]', 139 'mm[Hg]']
or EncounterLastBP.DiastolicBP.value in Interval[80 'mm[Hg]', 89 'mm[Hg]']
)
and not ( EncounterLastBP.SystolicBP.value >= 140 'mm[Hg]'
or EncounterLastBP.DiastolicBP.value >= 90 'mm[Hg]'
)
)
and ( exists "Encounter with Hypertensive Reading Within Year Prior" )
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Laboratory Test or ECG for Hypertension |
|
define "Laboratory Test or ECG for Hypertension":
( [ServiceRequest: "12 lead EKG panel"]
union [ServiceRequest: "EKG study"]
union [ServiceRequest: "Laboratory Tests for Hypertension"] ) EKGLab
where EKGLab.intent ~ 'order'
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 and Interventions |
|
define "Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 and Interventions":
"Follow up with Rescreen Within 6 Months" Rescreen2to6
with "Laboratory Test or ECG for Hypertension" LabECGIntervention
such that Rescreen2to6.authoredOn during day of "Measurement Period"
and LabECGIntervention.authoredOn during day of "Measurement Period"
with "NonPharmacological Interventions" NonPharmSecondIntervention
such that NonPharmSecondIntervention.authoredOn during day of "Measurement Period"
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 and Interventions |
|
define "Encounter with Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 and Interventions":
( "Encounter with Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89" SecondHTNEncounterReading
with "Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 and Interventions" EncounterInterventions
such that EncounterInterventions.authoredOn during day of SecondHTNEncounterReading.period
)
union ( "Encounter with Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89" SecondHTNEncounterReading
with "Referral to Alternate or Primary Healthcare Professional for Hypertensive Reading" ReferralForHTN
such that ReferralForHTN.authoredOn during day of SecondHTNEncounterReading.period
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 |
|
define "Encounter with Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90":
( "Qualifying Encounter during Measurement Period" QualifyingEncounter
let EncounterLastBP: Last(["observation-bp"] BloodPressure
where BloodPressure.effective.toInterval() ends during QualifyingEncounter.period
and BloodPressure.status in { 'final', 'amended', 'corrected' }
sort by start of effective.toInterval()
)
where ( EncounterLastBP.SystolicBP.value > 0 'mm[Hg]'
and EncounterLastBP.DiastolicBP.value > 0 'mm[Hg]'
and ( EncounterLastBP.SystolicBP.value >= 140 'mm[Hg]'
or EncounterLastBP.DiastolicBP.value >= 90 'mm[Hg]'
)
)
and ( exists "Encounter with Hypertensive Reading Within Year Prior" )
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 Interventions |
|
define "Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 Interventions":
( [ServiceRequest: "Follow Up Within 4 Weeks"] WeeksRescreen
with "Laboratory Test or ECG for Hypertension" ECGLabTest
such that WeeksRescreen.authoredOn during day of "Measurement Period"
and ECGLabTest.authoredOn during day of "Measurement Period"
and WeeksRescreen.intent ~ 'order'
and ECGLabTest.intent ~ 'order'
with "NonPharmacological Interventions" HTNInterventions
such that HTNInterventions.authoredOn during day of "Measurement Period"
with ["MedicationRequest": "Pharmacologic Therapy for Hypertension"] Medications
such that Medications.authoredOn during day of "Measurement Period"
and Medications.status ~ 'active'
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 and Interventions |
|
define "Encounter with Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 and Interventions":
( "Encounter with Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90" SecondHTNEncounterReading140Over90
with "Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 Interventions" SecondHTN140Over90Interventions
such that SecondHTN140Over90Interventions.authoredOn during day of SecondHTNEncounterReading140Over90.period
)
union "Encounter with Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90" SecondHTNEncounterReading140Over90
with "Referral to Alternate or Primary Healthcare Professional for Hypertensive Reading" ReferralToProfessional
such that ReferralToProfessional.authoredOn during day of SecondHTNEncounterReading140Over90.period
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Numerator |
|
define "Numerator":
"Encounter with Normal Blood Pressure Reading"
union ( "Encounter with Elevated Blood Pressure Reading SBP 120 to 129 AND DBP less than 80 and Interventions" )
union ( "Encounter with First Hypertensive Reading SBP Greater than or Equal to 130 OR DBP Greater than or Equal to 80 and Interventions" )
union ( "Encounter with Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 and Interventions" )
union ( "Encounter with Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 and Interventions" )
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Initial Population |
|
define "Initial Population":
"Qualifying Encounter during Measurement Period" QualifyingEncounter
where AgeInYearsAt(start of "Measurement Period") >= 18
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Denominator |
|
define "Denominator":
"Initial Population"
|
| 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 |
| PCSBPScreeningFollowUpFHIR |
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 |
| PCSBPScreeningFollowUpFHIR |
SDE Ethnicity |
|
define "SDE Ethnicity":
SDE."SDE Ethnicity"
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Denominator Exclusions |
|
define "Denominator Exclusions":
"Qualifying Encounter during Measurement Period" QualifyingEncounter
with [Condition: "Diagnosis of Hypertension"] Hypertension
such that ( Hypertension.isProblemListItem ( )
or Hypertension.isHealthConcern ( )
)
and Hypertension.prevalenceInterval ( ) starts before or on day of QualifyingEncounter.period
|
| 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 |
| PCSBPScreeningFollowUpFHIR |
SDE Race |
|
define "SDE Race":
SDE."SDE Race"
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Medical Reason for Not Obtaining or Patient Declined Blood Pressure Measurement |
|
define "Encounter with Medical Reason for Not Obtaining or Patient Declined Blood Pressure Measurement":
"Qualifying Encounter during Measurement Period" QualifyingEncounter
with ( [ObservationNotDone: code ~ "Systolic blood pressure"]
union [ObservationNotDone: code ~ "Diastolic blood pressure"] ) NoBPScreen
such that NoBPScreen.issued during day of QualifyingEncounter.period
and ( NoBPScreen.notDoneReason in "Patient Declined"
or NoBPScreen.notDoneReason in "Medical Reason"
)
and NoBPScreen.status = 'cancelled'
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
NonPharmacological Intervention Not Ordered |
|
define "NonPharmacological Intervention Not Ordered":
( [ServiceNotRequested: "Lifestyle Recommendation"]
union [ServiceNotRequested: "Weight Reduction Recommended"]
union [ServiceNotRequested: "Dietary Recommendations"]
union [ServiceNotRequested: "Recommendation to Increase Physical Activity"]
union [ServiceNotRequested: "Referral or Counseling for Alcohol Consumption"] ) NonPharmIntervention
where NonPharmIntervention.reasonRefused in "Patient Declined"
and NonPharmIntervention.status = 'completed'
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Laboratory Test or ECG for Hypertension Not Ordered |
|
define "Laboratory Test or ECG for Hypertension Not Ordered":
( [ServiceNotRequested: code = "12 lead EKG panel"]
union [ServiceNotRequested: code = "EKG study"]
union [ServiceNotRequested: "Laboratory Tests for Hypertension"] ) LabECGNotDone
where LabECGNotDone.reasonRefused in "Patient Declined"
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 Interventions Declined |
|
define "Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 Interventions Declined":
( ( ( [ServiceNotRequested: "Referral to Primary Care or Alternate Provider"]
union [ServiceNotRequested: "Follow Up Within 6 Months"] ) SecondHTNDeclinedReferralAndFollowUp
where SecondHTNDeclinedReferralAndFollowUp.reasonRefused in "Patient Declined"
and SecondHTNDeclinedReferralAndFollowUp.status = 'completed'
)
union "Laboratory Test or ECG for Hypertension Not Ordered"
union "NonPharmacological Intervention Not Ordered"
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 Interventions Declined |
|
define "Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 Interventions Declined":
( ( ( [ServiceNotRequested: "Referral to Primary Care or Alternate Provider"]
union [ServiceNotRequested: "Follow Up Within 4 Weeks"] ) SecondHTN140Over90ReferralFollowUpNotDone
where SecondHTN140Over90ReferralFollowUpNotDone.reasonRefused in "Patient Declined"
and SecondHTN140Over90ReferralFollowUpNotDone.status = 'completed'
)
union ( [MedicationNotRequested: "Pharmacologic Therapy for Hypertension"] MedicationRequestNotOrdered
where MedicationRequestNotOrdered.status = 'completed'
)
union "Laboratory Test or ECG for Hypertension Not Ordered"
union "NonPharmacological Intervention Not Ordered"
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Encounter with Order for Hypertension Follow Up Declined by Patient |
|
define "Encounter with Order for Hypertension Follow Up Declined by Patient":
( ( "Encounter with Elevated Blood Pressure Reading SBP 120 to 129 AND DBP less than 80" ElevatedBPEncounter
with ( [ServiceNotRequested: "Referral to Primary Care or Alternate Provider"]
union [ServiceNotRequested: "Follow Up Within 6 Months"] ) ElevatedBPDeclinedInterventions
such that ElevatedBPDeclinedInterventions.reasonRefused in "Patient Declined"
and ElevatedBPDeclinedInterventions.authoredOn during day of ElevatedBPEncounter.period
and ElevatedBPDeclinedInterventions.status = 'completed'
)
union ( "Encounter with Elevated Blood Pressure Reading SBP 120 to 129 AND DBP less than 80" ElevatedBPEncounter
with "NonPharmacological Intervention Not Ordered" NotOrdered
such that NotOrdered.authoredOn during day of ElevatedBPEncounter.period
)
union ( "Encounter with First Hypertensive Reading SBP Greater than or Equal to 130 OR DBP Greater than or Equal to 80" FirstHTNEncounter
with ( [ServiceNotRequested: "Follow Up Within 4 Weeks"]
union [ServiceNotRequested: "Referral to Primary Care or Alternate Provider"] ) FirstHTNDeclinedInterventions
such that FirstHTNDeclinedInterventions.reasonRefused in "Patient Declined"
and FirstHTNDeclinedInterventions.authoredOn during day of FirstHTNEncounter.period
and FirstHTNDeclinedInterventions.status = 'completed'
)
union ( "Encounter with First Hypertensive Reading SBP Greater than or Equal to 130 OR DBP Greater than or Equal to 80" FirstHTNEncounter
with "NonPharmacological Intervention Not Ordered" NoNonPharm
such that NoNonPharm.authoredOn during day of FirstHTNEncounter.period
)
union ( "Encounter with Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89" SecondHTNEncounter
with "Second Hypertensive Reading SBP 130 to 139 OR DBP 80 to 89 Interventions Declined" SecondHTNDeclinedInterventions
such that SecondHTNDeclinedInterventions.authoredOn during day of SecondHTNEncounter.period
)
union ( "Encounter with Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90" SecondHTN140Over90Encounter
with "Second Hypertensive Reading SBP Greater than or Equal to 140 OR DBP Greater than or Equal to 90 Interventions Declined" SecondHTN140Over90DeclinedInterventions
such that SecondHTN140Over90DeclinedInterventions.authoredOn during day of SecondHTN140Over90Encounter.period
)
)
|
| Library Name |
Name |
| PCSBPScreeningFollowUpFHIR |
Denominator Exceptions |
|
define "Denominator Exceptions":
"Encounter with Medical Reason for Not Obtaining or Patient Declined Blood Pressure Measurement"
union "Encounter with Order for Hypertension Follow Up Declined by Patient"
|
| Library Name |
Name |
| FHIRHelpers |
ToInterval |
|
/*
@description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)
value to a CQL DateTime Interval
@comment: If the start value of the given period is unspecified, the starting
boundary of the resulting interval will be open (meaning the start of the interval
is unknown, as opposed to interpreted as the beginning of time).
*/
define function ToInterval(period FHIR.Period):
if period is null then
null
else
if period."start" is null then
Interval(period."start".value, period."end".value]
else
Interval[period."start".value, period."end".value]
|
| Library Name |
Name |
| FHIRHelpers |
ToString |
|
define function ToString(value uri): value.value
|
| Library Name |
Name |
| FHIRHelpers |
ToString |
|
define function ToString(value string): value.value
|
| Library Name |
Name |
| FHIRHelpers |
ToConcept |
|
/*
@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.
*/
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
}
|
| 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 |
| QICoreCommon |
isProblemListItem |
|
/*
@description: Returns true if the given condition is a problem list item.
*/
define fluent function isProblemListItem(condition Condition):
exists (condition.category C
where C ~ "problem-list-item"
)
|
| Library Name |
Name |
| QICoreCommon |
isHealthConcern |
|
/*
@description: Returns true if the given condition is a health concern
*/
define fluent function isHealthConcern(condition Condition):
exists (condition.category C
where C ~ "health-concern"
)
|
| 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 |
| QICoreCommon |
abatementInterval |
|
/*
@description: Returns an interval representing the normalized abatement of a given Condition.
@comment: If the abatement element of the Condition is represented as a DateTime, the result
is an interval beginning and ending on that DateTime.
If the abatement is represented as a Quantity, the quantity is expected to be a calendar-duration and is interpreted as the age of the patient. The
result is an interval from the date the patient turned that age to immediately before one year later.
If the abatement is represented as a Quantity Interval, the quantities are expected to be calendar-durations and are interpreted as an age range during
which the abatement occurred. The result is an interval from the date the patient turned the starting age of the quantity interval, and ending immediately
before one year later than the date the patient turned the ending age of the quantity interval.
*/
define fluent function abatementInterval(condition Condition):
if condition.abatement is DateTime then
Interval[condition.abatement as DateTime, condition.abatement as DateTime]
else if condition.abatement is Quantity then
Interval[Patient.birthDate + (condition.abatement as Quantity),
Patient.birthDate + (condition.abatement as Quantity) + 1 year)
else if condition.abatement is Interval<Quantity> then
Interval[Patient.birthDate + (condition.abatement.low as Quantity),
Patient.birthDate + (condition.abatement.high as Quantity) + 1 year)
else if condition.abatement is Interval<DateTime> then
Interval[condition.abatement.low, condition.abatement.high)
else null as Interval<DateTime>
|