| Library Name |
Name |
| CMS1218HHRFFHIR |
Elective Inpatient Encounter with Age 18 and Older without ED Visit |
|
//---------------------- Supporting definitions for Measure Population Definitions --------------------------------------------------//
// Note: defines that are not referenced elsewhere are at the bottom of this file.
// Supports: Initial Population clause 1
define "Elective Inpatient Encounter with Age 18 and Older without ED Visit":
["Encounter": "Elective Inpatient Encounter"] ElectiveEncounter
where ElectiveEncounter.period ends during day of "Measurement Period"
and ElectiveEncounter.priority ~ "Elective (qualifier value)"
and AgeInYearsAt(date from start of ElectiveEncounter.period) >= 18
and not exists ( ["Encounter": "Emergency Department Visit"] EDVisit
where EDVisit.period ends 1 hour or less before or on start of ElectiveEncounter.period
)
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Elective Inpatient Encounter with Age and without Obstetrical Condition |
|
// Supports: Initial Population clause 1
define "Elective Inpatient Encounter with Age and without Obstetrical Condition":
"Elective Inpatient Encounter with Age 18 and Older without ED Visit" ElectiveEncounter
where not exists ElectiveEncounter.diagnosis EncounterDiagnoses
where EncounterDiagnoses.condition.getCondition ( ).code in "Obstetrical or Pregnancy Related Conditions"
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Elective Inpatient Encounter with OR Procedure within 3 Days |
|
//---------------------- Initial Population Clauses --------------------------------------------------//
// Initial Population - clause 1 - (referenced throughout the measure definitions)
define "Elective Inpatient Encounter with OR Procedure within 3 Days":
"Elective Inpatient Encounter with Age and without Obstetrical Condition" ElectiveEncounter
with ["Procedure": "General and Neuraxial Anesthesia"] SurgeryWithAnesthesia
such that SurgeryWithAnesthesia.performed.earliest ( ) during ElectiveEncounter.hospitalizationInterval ( )
and SurgeryWithAnesthesia.performed.earliest ( ) 3 days or less after start of ElectiveEncounter.hospitalizationInterval ( )
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
General Anesthesia and MAC |
|
// Referenced in numerator supporting clauses
define "General Anesthesia and MAC":
["Procedure": "Anesthesia Requiring Monitored Care"] MAC
union ["Procedure": "General and Neuraxial Anesthesia"] GA
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Anesthesia Procedure List |
|
//---------------------- End Risk Variable Accessory Functions -----------------------------//
//---------------------- Utility Functions --------------------------------------------------//
// Used exclusively in "FirstProcedure" function, below
define "Anesthesia Procedure List":
["Procedure": "General and Neuraxial Anesthesia"] AnesthesiaProcedures
where AnesthesiaProcedures.performed.latest ( ) during day of "Measurement Period"
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Intubation During General Anesthesia and MAC |
|
// Supports: numerator clause 1
define "Intubation During General Anesthesia and MAC":
from
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery,
["Procedure": "Intubation"] ProceduralIntubation,
"General Anesthesia and MAC" ProcedureWithAnesthesia
where ProceduralIntubation.startsDuringAnesthesia ( ProcedureWithAnesthesia, EncounterWithSurgery )
return ProceduralIntubation
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure |
|
//fix
//---------------------- Numerator Clauses --------------------------------------------------//
// Numerator - clause 1
define "Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure":
from
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery,
["Procedure": "Intubation"] EndotrachealTubeIn
let IntubationInterval: EndotrachealTubeIn.interval ( ),
LatestAnesthesiaInterval: "LatestGeneralAnesthesiaOrMAC"(EndotrachealTubeIn).interval ( )
where EndotrachealTubeIn.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
and EndotrachealTubeIn.startsDuringHospitalization ( EncounterWithSurgery )
and IntubationInterval starts after end of LatestAnesthesiaInterval
and EncounterWithSurgery.isNotAtProceduralHospitalLocationDuring ( IntubationInterval )
and not ( "Intubation During General Anesthesia and MAC".id contains EndotrachealTubeIn.id )
return EncounterWithSurgery
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Noninvasive Oxygen Therapy |
|
// Referenced in numerator supporting clauses
define "Noninvasive Oxygen Therapy":
["Procedure": "Non Invasive Oxygen Therapy by Nasal Cannula or Mask"]
union ["Observation": "Non Invasive Oxygen Therapy"]
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy |
|
// Numerator - clause 2
define "Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy":
from
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery,
["Procedure": "Mechanical Ventilation"] Ventilation,
"Noninvasive Oxygen Therapy" OxygenSupport
let VentilationInterval: Ventilation.interval ( ),
LatestAnesthesiaInterval: "LatestGeneralAnesthesiaOrMAC"(Ventilation).interval ( )
where Ventilation.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
and Ventilation.startsDuringHospitalization ( EncounterWithSurgery )
and VentilationInterval starts after end of LatestAnesthesiaInterval
and OxygenSupport.interval ( ) starts during Interval[end of LatestAnesthesiaInterval, start of VentilationInterval]
and EncounterWithSurgery.isNotAtProceduralHospitalLocationDuring ( VentilationInterval )
return EncounterWithSurgery
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Extubation with Preceding Noninvasive Oxygen |
|
// Supports: numerator clause 3
define "Extubation with Preceding Noninvasive Oxygen":
from
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery,
["Procedure": "Removal of endotracheal tube (procedure)"] Extubation,
"Noninvasive Oxygen Therapy" OxygenSupport
let LatestAnesthesia: "LatestGeneralAnesthesiaOrMAC"(Extubation)
where Extubation.startsDuringHospitalization ( EncounterWithSurgery )
and Extubation.startsAfterAnesthesia ( LatestAnesthesia, EncounterWithSurgery )
and OxygenSupport.interval ( ) starts during Interval[end of LatestAnesthesia.interval ( ), start of Extubation.interval ( )]
return Extubation
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Extubation During General Anesthesia |
|
// Supports: numerator clause 3
define "Extubation During General Anesthesia":
from
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery,
["Procedure": "Removal of endotracheal tube (procedure)"] Extubation,
"General Anesthesia and MAC" Anesthesia
where Extubation.startsDuringAnesthesia ( Anesthesia, EncounterWithSurgery )
return Extubation
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia |
|
//fix
// Numerator - clause 3
define "Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia":
from
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery,
["Procedure": "Removal of endotracheal tube (procedure)"] Extubation
let ExtubationInterval: Extubation.interval ( ),
LatestAnesthesiaInterval: "LatestGeneralAnesthesiaOrMAC"(Extubation).interval ( )
where Extubation.isDuringHospitalization ( EncounterWithSurgery )
and Extubation.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
and ExtubationInterval starts more than 48 hours after end of LatestAnesthesiaInterval
and not ( ( "Extubation with Preceding Noninvasive Oxygen".id contains Extubation.id )
and not ( "Extubation During General Anesthesia".id contains Extubation.id )
)
and EncounterWithSurgery.isNotAtProceduralHospitalLocation ( )
return EncounterWithSurgery
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia |
|
// Numerator - clause 4
define "Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia":
from
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery,
["Procedure": "Mechanical Ventilation"] Ventilation
let VentilationInterval: Ventilation.interval ( ),
LatestAnesthesiaInterval: "LatestGeneralAnesthesiaOrMAC"(Ventilation).interval ( )
where VentilationInterval starts 48 hours or more after end of LatestAnesthesiaInterval
and VentilationInterval starts 72 hours or less after end of LatestAnesthesiaInterval
and Ventilation.starts30DaysOrLessAfterFirstProcedure ( EncounterWithSurgery )
and Ventilation.startsDuringHospitalization ( EncounterWithSurgery )
and not ( "Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy".id contains EncounterWithSurgery.id )
and EncounterWithSurgery.isNotAtProceduralHospitalLocation ( )
return EncounterWithSurgery
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Numerator |
|
define "Numerator":
"Encounter with Intubation Outside of Procedural Area within 30 Days of End of First OR Procedure"
union "Encounter with Mechanical Ventilation Outside of Procedural Area within 30 Days of End of First OR Procedure and Preceded by Non Invasive Oxygen Therapy"
union "Encounter with Extubation Outside of Procedural Area within 30 Days of End of First OR Procedure More Than 48 Hours After End of Anesthesia"
union "Encounter with Mechanical Ventilation within 30 Days of End of First OR Procedure and Between 48 and 72 Hours After End of OR Procedure and not Preceded by Non Invasive Oxygen Therapy or Anesthesia"
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Initial Population |
|
//---------------------- Measure Population Definitions --------------------------------------------------//
define "Initial Population":
"Elective Inpatient Encounter with OR Procedure within 3 Days"
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Denominator |
|
define "Denominator":
"Initial Population"
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Degenerative Neurological Disorder |
|
//---------------------- Denominator Exclusion Clauses------------------------------------------------//
// Denominator Exclusions - clause 1
define "Encounter with Degenerative Neurological Disorder":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
where exists ( EncounterWithSurgery.diagnosis EncounterDiagnosis
where EncounterDiagnosis.condition.getCondition ( ).code in "Degenerative Neurological Disorder"
)
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with High Risk to Airway Head Neck and Thoracic Surgery |
|
// Denominator Exclusions - clause 2
define "Encounter with High Risk to Airway Head Neck and Thoracic Surgery":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
with ["Procedure": "Head, Neck, and Thoracic Surgeries with High Risk Airway Compromise"] HeadNeckProcedures
such that HeadNeckProcedures.startsDuringHospitalization ( EncounterWithSurgery )
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure |
|
// Denominator Exclusions - clause 3
define "Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
with ["Procedure": "Mechanical Ventilation"] Ventilation
such that Ventilation.interval ( ) starts more than 1 hour before start of FirstAnesthesiaDuringHospitalization(EncounterWithSurgery).interval ( )
and Ventilation.startsDuringHospitalization ( EncounterWithSurgery )
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Neuromuscular Disorder |
|
// Denominator Exclusions - clause 4
define "Encounter with Neuromuscular Disorder":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
where exists ( EncounterWithSurgery.diagnosis EncounterDiagnosis
where EncounterDiagnosis.condition.getCondition ( ).code in "Neuromuscular Disorder"
)
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure |
|
// Denominator Exclusions - clause 5
define "Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure":
from
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery,
["Observation": "Carbon Dioxide Partial Pressure in Arterial Blood"] CarbonDioxide,
["Observation": "Arterial Blood pH"] BloodpH
let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery),
FirstProcedureTime: FirstProcedure.interval ( )
where CarbonDioxide.interval ( ) starts 48 hours or less before start of FirstProcedureTime
and CarbonDioxide.value as Quantity > 50 'mm[Hg]'
and BloodpH.interval ( ) starts 48 hours or less before start of FirstProcedureTime
and BloodpH.value as Quantity < 7.30 '[pH]'
and FirstProcedure is not null
return EncounterWithSurgery
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure |
|
//fix
// Denominator Exclusions - clause 6
define "Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery)
with ["Observation": "Oxygen Partial Pressure in Arterial Blood"] Oxygen
such that Oxygen.interval ( ) starts 48 hours or less before start of FirstProcedure.interval ( )
and Oxygen.value as Quantity < 50 'mm[Hg]'
and FirstProcedure is not null
return EncounterWithSurgery
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Principal Diagnosis of Acute Respiratory Failure |
|
// Denominator Exclusions - clause 7
define "Encounter with Principal Diagnosis of Acute Respiratory Failure":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
where exists ( EncounterWithSurgery.diagnosis Diagnosis
where Diagnosis.condition.getCondition ( ).code in "Acute Respiratory Failure"
and Diagnosis.rank = 1
)
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Diagnosis of Acute Respiratory Failure Present on Admission |
|
// Denominator Exclusions - clause 8
define "Encounter with Diagnosis of Acute Respiratory Failure Present on Admission":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
where EncounterWithSurgery.diagnosisPresentOnAdmission ( ) in "Present on Admission or Clinically Undetermined"
and exists ( EncounterWithSurgery.diagnosis Diagnosis
where Diagnosis.condition.getCondition ( ).code in "Acute Respiratory Failure"
)
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Tracheostomy Present on Admission |
|
//fix
// Denominator Exclusions - clause 9
define "Encounter with Tracheostomy Present on Admission":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
where EncounterWithSurgery.diagnosisPresentOnAdmission ( ) in "Present on Admission or Clinically Undetermined"
and exists ( EncounterWithSurgery.diagnosis Dx
where Dx.condition.getCondition ( ).code in "Tracheostomy Diagnoses"
)
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Tracheostomy Before Day of First OR Procedure |
|
// Supports: denominator exclusions clause 10
define "Encounter with Tracheostomy Before Day of First OR Procedure":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery)
with ["Procedure": "Tracheostomy Procedures"] TracheostomySurgery
such that TracheostomySurgery.startsDuringHospitalization ( EncounterWithSurgery )
and TracheostomySurgery.interval ( ) starts before day of FirstProcedure.interval ( )
and FirstProcedure is not null
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Tracheostomy Same Day of First OR Procedure |
|
// Supports: denominator exclusions clause 10
define "Encounter with Tracheostomy Same Day of First OR Procedure":
"Elective Inpatient Encounter with OR Procedure within 3 Days" EncounterWithSurgery
let FirstProcedure: FirstAnesthesiaDuringHospitalization(EncounterWithSurgery)
with ["Procedure": "Tracheostomy Procedures"] TracheostomySurgery
such that TracheostomySurgery.startsDuringHospitalization ( EncounterWithSurgery )
and TracheostomySurgery.interval ( ) starts during day of FirstProcedure.interval ( )
and FirstProcedure is not null
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure |
|
// Denominator Exclusions - clause 10
define "Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure":
"Encounter with Tracheostomy Before Day of First OR Procedure"
union "Encounter with Tracheostomy Same Day of First OR Procedure"
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
Denominator Exclusions |
|
define "Denominator Exclusions":
"Encounter with Degenerative Neurological Disorder"
union "Encounter with High Risk to Airway Head Neck and Thoracic Surgery"
union "Encounter with Mechanical Ventilation that Starts More than One Hour Prior to Start of First OR Procedure"
union "Encounter with Neuromuscular Disorder"
union "Encounter with PaCO2 Greater Than 50 and Arterial pH Less Than 7.30 within 48 Hours Prior to Start of First OR Procedure"
union "Encounter with PaO2 Less Than 50 within 48 Hours Prior to Start of First OR Procedure"
union "Encounter with Principal Diagnosis of Acute Respiratory Failure"
union "Encounter with Diagnosis of Acute Respiratory Failure Present on Admission"
union "Encounter with Tracheostomy Present on Admission"
union "Encounter with Tracheostomy Prior to or on the Same Day of First OR Procedure"
|
| 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 |
| CQMCommon |
getCondition |
|
/*
@description: Returns the Condition resource for the given reference
*/
define fluent function getCondition(reference Reference):
singleton from ([Condition] C where C.id = reference.reference.getId())
|
| Library Name |
Name |
| QICoreCommon |
getId |
|
/*
@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, '/'))
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
hospitalizationInterval |
|
define fluent function hospitalizationInterval(enc Encounter):
enc.hospitalizationWithObservationAndOutpatientSurgeryService ( )
|
| Library Name |
Name |
| CQMCommon |
hospitalizationWithObservationAndOutpatientSurgeryService |
|
/*
@description: Hospitalization with Observation and Outpatient Surgery Service returns the total interval from the start of any immediately prior emergency department visit, outpatient surgery visit or observation visit to the discharge of the given encounter.
*/
define fluent function hospitalizationWithObservationAndOutpatientSurgeryService(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
),
VisitStartWithED: Coalesce(start of EDVisit.period, VisitStart),
OutpatientSurgeryVisit: Last([Encounter: "Outpatient Surgery Service"] LastSurgeryOP
where LastSurgeryOP.period ends 1 hour or less on or before VisitStartWithED
sort by end of period
)
return Interval[Coalesce(start of OutpatientSurgeryVisit.period, VisitStartWithED), end of Visit.period]
|
| Library Name |
Name |
| HospitalHarm |
interval |
|
// interval
// Given an encounter, procedure or observation resource, returns a normalized Interval object, calculated using QICoreCommon.ToInterval for the given type of resource.
// Usage: theEncounter.interval()
define fluent function interval(choice Choice<Procedure,Observation,Encounter>):
case
when choice is Procedure then QICoreCommon.ToInterval ( (choice as Procedure).performed )
when choice is Observation then QICoreCommon.ToInterval ( (choice as Observation).effective )
when choice is Encounter then QICoreCommon.ToInterval ( (choice as Encounter).period )
else null as Interval<DateTime>
end
|
| Library Name |
Name |
| QICoreCommon |
ToInterval |
|
/*
@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval
@comment: Normalizes a choice type of DateTime, Quanitty, Interval<DateTime>, or Interval<Quantity> types
to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible
representations for timing-valued elements in QICore, allowing this function to be used across any resource.
The input can be provided as a DateTime, Quantity, Interval<DateTime> or Interval<Quantity>.
The intent of this function is to provide a clear and concise mechanism to treat single
elements that have multiple possible representations as intervals so that logic doesn't have to account
for the variability. More complex calculations (such as medication request period or dispense period
calculation) need specific guidance and consideration. That guidance may make use of this function, but
the focus of this function is on single element calculations where the semantics are unambiguous.
If the input is a DateTime, the result a DateTime Interval beginning and ending on that DateTime.
If the input is a Quantity, the quantity is expected to be a calendar-duration interpreted as an Age,
and the result is a DateTime Interval beginning on the Date the patient turned that age and ending immediately before one year later.
If the input is a DateTime Interval, the result is the input.
If the input is a Quantity Interval, the quantities are expected to be calendar-durations interpreted as an Age, and the result
is a DateTime Interval beginning on the date the patient turned the age given as the start of the quantity interval, and ending
immediately before one year later than the date the patient turned the age given as the end of the quantity interval.
If the input is a Timing, an error will be thrown indicating that Timing calculations are not implemented. Any other input will reslt in a null DateTime Interval
@deprecated: This function is deprecated. Use the fluent function `toInterval()` instead
*/
define function ToInterval(choice Choice<DateTime, Quantity, Interval<DateTime>, Interval<Quantity>, Timing>):
case
when choice is DateTime then
Interval[choice as DateTime, choice as DateTime]
when choice is Interval<DateTime> then
choice as Interval<DateTime>
when choice is Quantity then
Interval[Patient.birthDate + (choice as Quantity),
Patient.birthDate + (choice as Quantity) + 1 year)
when choice is Interval<Quantity> then
Interval[Patient.birthDate + (choice.low as Quantity),
Patient.birthDate + (choice.high as Quantity) + 1 year)
when choice is Timing then
Message(null, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') as Interval<DateTime>
else
null as Interval<DateTime>
end
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
LatestGeneralAnesthesiaOrMAC |
|
define function "LatestGeneralAnesthesiaOrMAC"(event Procedure):
Last("General Anesthesia and MAC" ProcedureList
where ProcedureList.interval() ends before start of event.interval()
sort by start of QICoreCommon.ToInterval(performed)
)
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
starts30DaysOrLessAfterFirstProcedure |
|
define fluent function starts30DaysOrLessAfterFirstProcedure(procedure Procedure, encounter Encounter):
procedure.interval ( ) starts 30 days or less after end of FirstAnesthesiaDuringHospitalization(encounter).interval ( )
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
FirstAnesthesiaDuringHospitalization |
|
// Returns the first anesthesia procedure that starts during the hospitalization encounter.
define function "FirstAnesthesiaDuringHospitalization"(QualifyingEncounter Encounter):
First("Anesthesia Procedure List" anesthesia
where anesthesia.startsDuringHospitalization(QualifyingEncounter)
sort by start of performed
)
|
| Library Name |
Name |
| HospitalHarm |
startsDuringHospitalization |
|
// startsDuringHospitalization
// Given an encounter, returns true if the calling observation effective time or procedure performed starts during that encounter.
// The interval of the encounter is
// determined by calling the CQCommon function 'HospitalizationWithObservationAndOutpatientSurgeryService'wth the encounter as the argument.
// Usage: theObservation.startsDuringHospitalization(anEncounter)
define fluent function startsDuringHospitalization(choice Choice<Procedure,Observation>, enc Encounter):
case
when choice is Procedure then QICoreCommon.ToInterval ( (choice as Procedure).performed ) starts during CQMCommon."HospitalizationWithObservationAndOutpatientSurgeryService" ( enc )
when choice is Observation then QICoreCommon.ToInterval ( (choice as Observation).effective ) starts during CQMCommon."HospitalizationWithObservationAndOutpatientSurgeryService" ( enc )
else false
end
|
| Library Name |
Name |
| CQMCommon |
HospitalizationWithObservationAndOutpatientSurgeryService |
|
/*
@description: Hospitalization with Observation and Outpatient Surgery Service returns the total interval from the start of any immediately prior emergency department visit, outpatient surgery visit or observation visit to the discharge of the given encounter.
@deprecated: This function is deprecated. Use the fluent function `hospitalizationWithObservationAndOutpatientSurgeryService()` instead.
*/
define function "HospitalizationWithObservationAndOutpatientSurgeryService"(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
),
VisitStartWithED: Coalesce(start of EDVisit.period, VisitStart),
OutpatientSurgeryVisit: Last([Encounter: "Outpatient Surgery Service"] LastSurgeryOP
where LastSurgeryOP.period ends 1 hour or less on or before VisitStartWithED
sort by end of period
)
return Interval[Coalesce(start of OutpatientSurgeryVisit.period, VisitStartWithED), end of Visit.period]
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
isNotAtProceduralHospitalLocationDuring |
|
define fluent function isNotAtProceduralHospitalLocationDuring(encounter Encounter, intrvl Interval<DateTime>):
( not exists ( encounter.location EncounterLocation
where EncounterLocation.location.type in "Procedural Hospital Locations"
and EncounterLocation.period starts during intrvl
)
)
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
startsDuringAnesthesia |
|
// and procedure.startsDuringHospitalization(EncounterWithSurgery)
define fluent function startsDuringAnesthesia(procedure Procedure, anesthesia Procedure, encounterWithSurgery Encounter):
procedure.interval ( ) starts during anesthesia.interval ( )
and procedure.startsDuringHospitalization ( encounterWithSurgery )
|
| Library Name |
Name |
| HospitalHarm |
isDuringHospitalization |
|
// isDuringHospitalization
// Given an encounter, returns true if the calling observation effective time or procedure performed occurs during that encounter.
// The interval of the encounter is
// determined by calling the CQCommon function 'HospitalizationWithObservationAndOutpatientSurgeryService'wth the encounter as the argument.
// Usage: theProcedure.isDuringHospitalization(anEncounter)
define fluent function isDuringHospitalization(choice Choice<Procedure,Observation>, enc Encounter):
case
when choice is Procedure then
QICoreCommon.ToInterval ( (choice as Procedure).performed ) during CQMCommon."HospitalizationWithObservationAndOutpatientSurgeryService" ( enc )
when choice is Observation then
QICoreCommon.ToInterval ((choice as Observation).effective ) during CQMCommon."HospitalizationWithObservationAndOutpatientSurgeryService" ( enc )
else false
end
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
startsAfterAnesthesia |
|
define fluent function startsAfterAnesthesia(procedure Procedure, anesthesia Procedure, encounterWithSurgery Encounter):
procedure.interval ( ) starts after anesthesia.interval ( )
and procedure.startsDuringHospitalization ( encounterWithSurgery )
|
| Library Name |
Name |
| CMS1218HHRFFHIR |
isNotAtProceduralHospitalLocation |
|
define fluent function isNotAtProceduralHospitalLocation(encounter Encounter):
( not exists ( encounter.location EncounterLocation
where EncounterLocation.location.type in "Procedural Hospital Locations"
)
)
|
| Library Name |
Name |
| HospitalHarm |
diagnosisPresentOnAdmission |
|
// diagnosisPresentOnAdmission
// Given an Encounter, this function returns the Present On Admission code of encounter's diagnosis, if present. Returns null otherwiese.
// Usage: anEncouner.diagnosisPresentOnAdmission()
define fluent function diagnosisPresentOnAdmission(enc Encounter):
(singleton from (
enc.diagnosis.extension E where E.url = 'http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-diagnosisPresentOnAdmission'
)).value as Concept
|