Metadata Title Example Catheter-Associated Urinary Tract Infection Standardized Infection Ratio (SIR) Version 2.0.0-ballot Identifier urn:oid:2.16.840.1.113883.4.642.40.61.29.27 Status Draft Experimental true Jurisdiction 001 from http://unstats.un.org/unsd/methods/m49/m49.htm Topic Health Quality Measure Document Steward (Publisher) HL7 International / Clinical Quality Information Description Example measure illustrating an approach to representing the Catheter-Associated Urinary Tract Infection (CAUTI) Standardized Infection Ratio (SIR) measure. See https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/blob/master/Source/Cooking%20With%20CQL/93/CAUTI.md for more detailed discussion of the example. Measure Group (Rate) (ID: group-1) Basis Location Scoring Ratio Initial Population ID: denominator-initial-population Description: No description provided Criteria: Denominator Initial Population Initial Population ID: numerator-initial-population Description: No description provided Criteria: Numerator Initial Population Denominator ID: denominator Description: No description provided Criteria: Denominator Input Population: denominator-initial-population Numerator ID: numerator Description: No description provided Criteria: Numerator Input Population: numerator-initial-population Measure Observation ID: denominator-observation Description: No description provided Criteria: Denominator Observation Input Population: denominator AggregateMethod: sum Measure Observation ID: numerator-observation Description: No description provided Criteria: Numerator Observation Input Population: numerator AggregateMethod: sum Measure Logic Primary Library CAUTI Standardized Infection Ratio (SIR) Contents Population Criteria Logic Definitions Terminology Dependencies Data Requirements Parameters Population Criteria Measure Group (Rate) (ID: group-1) Initial Population define "Denominator Initial Population": [Location] L with Elements."Encounter During Measurement Period" E such that E.location.location.references(L) Definition Initial Population define "Numerator Initial Population": exists (Elements."Encounter During Measurement Period") Definition Denominator define "Denominator": "Denominator Initial Population" Definition Numerator define "Numerator": "Numerator Initial Population" Definition Measure Observation define function "Denominator Observation"(location Location): Sum( from (Parameters."Location Parameters"(location)) P, Parameters."Critical Access Hospital Parameters" H where P ~ H.parameter return all H.parameterEstimate ) * Elements."Patient Days"(location) Definition Measure Observation define function "Numerator Observation"(): Count(Elements."Catheter-Associated UTI") Definition Logic Definitions Logic Definition Library Name: CAUTIParameters /* @description: CAUTI Risk Adjustment factors for Critical Access Hospitals @comment: Source: https://www.cdc.gov/nhsn/2022rebaseline/tables/table-10.html */ define "Critical Access Hospital Parameters": List<Tuple { parameter String, parameterEstimate Decimal, standardError Decimal, pValue String }> { // Intercept Tuple { parameter: 'Intercept', parameterEstimate: -7.6495, standardError: 0.1492, pValue: '<0.0001' }, // Average length of stay >= 6.5 days Tuple { parameter: 'Average length of stay >= 6.5', parameterEstimate: 0.4257, standardError: 0.1564, pValue: '0.0065' }, // Average length of stay < 6.5 days Tuple { parameter: 'Average length of stay < 6.5 days', parameterEstimate: 0.0, standardError: 0.0, pValue: 'REFERENT' }, // Proportion of total beds that are ICU < 0.16 Tuple { parameter: 'Proportion of total beds that are ICU < 0.16', parameterEstimate: 0.4189, standardError: 0.1708, pValue: '0.0142' }, // Proportion of total beds that are ICU >= 0.16 Tuple { parameter: 'Proportion of total beds that are ICU >= 0.16', parameterEstimate: 0.0, standardError: 0.0, pValue: 'REFERENT' } } Logic Definition Library Name: CAUTIParameters /* @description: Returns the characteristic codes for the given facility */ define function "Location Parameters"(location Location): { 'Intercept', location.averageLengthOfStayParameter(), location.proportionOfBedsICUParameter() } Logic Definition Library Name: CAUTIParameters // These would need to access computed data for these characteristics for the location define fluent function averageLengthOfStayParameter(location Location): 'Average length of stay >= 6.5 days' Logic Definition Library Name: CAUTIParameters define fluent function proportionOfBedsICUParameter(location Location): 'Proportion of total beds that are ICU < 0.16' Logic Definition Library Name: CAUTIElements define "Encounter During Measurement Period": [Encounter] E where E.period during "Measurement Period" Logic Definition Library Name: CAUTIElements define "Urine Culture With Bacterium": [Observation: "Urine Culture"] O where O.status = 'final' and exists ( O.component C where C.code in "Bacterium Presence" and C.value >= 10000 '[CFU]/mL' ) Logic Definition Library Name: CAUTIElements define "UTI": "Urine Culture With Bacterium" U let DOE: date from start of U.effective.toInterval(), IWP: Interval[DOE - 3 days, DOE + 3 days] where start of U.effective.toInterval() during "Measurement Period" return { urineCultureResult: U, dateOfEvent: DOE, infectionWindowPeriod: IWP } Logic Definition Library Name: CAUTIElements define "Catheter Inserted Procedure": [Procedure: "Catheter Inserted"] P where P.status = 'completed' Logic Definition Library Name: CAUTIElements define "Catheter Removed Procedure": [Procedure: "Catheter Removed"] P where P.status = 'completed' Logic Definition Library Name: CAUTIElements define "Catheter Usage": "Catheter Inserted Procedure" I let catheterRemoved: First( "Catheter Removed Procedure" R where R.performed.toInterval() starts after I.performed.toInterval() sort by start of performed.toInterval() ) return Interval[ date from start of I.performed.toInterval(), date from start of catheterRemoved.performed.toInterval() ] Logic Definition Library Name: CAUTIElements define "Catheter-Associated UTI": "UTI" U where exists ( "Catheter Usage" Usage where start of Usage before U.dateOfEvent and end of Usage on or after U.dateOfEvent - 1 day and duration in days of Usage > 2 ) Logic Definition Library Name: CAUTIElements define function "Patient Days"(location Location): Sum( "Encounter During Measurement Period" E where E.location.location.references(location) return all duration in days of E.period ) Logic Definition Library Name: CAUTISIR define "Denominator Initial Population": [Location] L with Elements."Encounter During Measurement Period" E such that E.location.location.references(L) Logic Definition Library Name: CAUTISIR define "Numerator Initial Population": exists (Elements."Encounter During Measurement Period") Logic Definition Library Name: CAUTISIR define "Numerator": "Numerator Initial Population" Logic Definition Library Name: CAUTISIR define "Denominator": "Denominator Initial Population" Logic Definition Library Name: CAUTISIR define function "Denominator Observation"(location Location): Sum( from (Parameters."Location Parameters"(location)) P, Parameters."Critical Access Hospital Parameters" H where P ~ H.parameter return all H.parameterEstimate ) * Elements."Patient Days"(location) Logic Definition Library Name: CAUTISIR define function "Numerator Observation"(): Count(Elements."Catheter-Associated UTI") Logic Definition Library Name: FHIRCommon /* @description: Returns true if any of the given references are to the given resource @comment: Returns true if the `id` element of the given resource exactly equals the tail of any of the given references. NOTE: This function assumes resources from the same source server. */ define fluent function references(references List<FHIR.Reference>, resource FHIR.Resource): exists (references R where R.references(resource)) Logic Definition Library Name: FHIRCommon /* @description: Returns true if the given reference is to the given resource @comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference. NOTE: This function assumes resources from the same source server. */ define fluent function references(reference FHIR.Reference, resource FHIR.Resource): resource.id = Last(Split(reference.reference, '/')) Logic Definition Library Name: FHIRCommon /* @description: Normalizes a value that is a choice of timing-valued types to an equivalent interval @comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range 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 FHIR, allowing this function to be used across any resource. The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range. 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 Period, the result is a DateTime Interval. If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing. If the input is an instant, the result is a DateTime Interval beginning and ending on that instant. If the input is a string, an error is raised indicating a single interval cannot be computed from a string. If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age, and ending immediately prior to when the patient was the given Age plus one year. If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given by the low end of the Range, and ending immediately prior to when the patient was the Age given by the high end of the Range plus one year. NOTE: Due to the complexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used with a Timing or String. */ define fluent function toInterval(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>): case when choice is FHIR.dateTime then Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)] when choice is FHIR.Period then FHIRHelpers.ToInterval(choice as FHIR.Period) when choice is FHIR.instant then Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)] when choice is FHIR.Age then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year) when choice is FHIR.Range then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year) when choice is FHIR.Timing then Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') when choice is FHIR.string then Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported') else null as Interval<DateTime> end Logic Definition Library Name: FHIRHelpers /* @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] Logic Definition Library Name: FHIRHelpers define function ToString(value string): value.value Logic Definition Library Name: FHIRHelpers define function ToString(value ObservationStatus): value.value Logic Definition Library Name: FHIRHelpers /* @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 } Logic Definition Library Name: FHIRHelpers /* @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 } Logic Definition Library Name: FHIRHelpers /* @description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity) value to a CQL Quantity @comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`) an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used. @seealso: ToCalendarUnit */ define function ToQuantity(quantity FHIR.Quantity): case when quantity is null then null when quantity.value is null then null when quantity.comparator is not null then Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.') when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org' or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) } else Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')') end Logic Definition Library Name: FHIRHelpers /* @description: Converts a UCUM definite duration unit to a CQL calendar duration unit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities) topic of the CQL specification. @comment: Note that for durations above days (or weeks), the conversion is understood to be approximate */ define function ToCalendarUnit(unit System.String): case unit when 'ms' then 'millisecond' when 's' then 'second' when 'min' then 'minute' when 'h' then 'hour' when 'd' then 'day' when 'wk' then 'week' when 'mo' then 'month' when 'a' then 'year' else unit end Logic Definition Library Name: FHIRHelpers define function ToDateTime(value dateTime): value.value Logic Definition Library Name: FHIRHelpers define function ToDateTime(value instant): value.value Logic Definition Library Name: FHIRHelpers define function ToDate(value date): value.value Logic Definition Library Name: FHIRHelpers define function ToString(value ProcedureStatus): value.value Terminology Value Set Description: Value set Urine Culture Resource: http://example.org/ValueSet/urine-culture Canonical URL: http://example.org/ValueSet/urine-culture Value Set Description: Value set Bacterium Presence Resource: http://example.org/ValueSet/bacterium-presence Canonical URL: http://example.org/ValueSet/bacterium-presence Value Set Description: Value set Catheter Inserted Resource: http://example.org/ValueSet/catheter-inserted Canonical URL: http://example.org/ValueSet/catheter-inserted Value Set Description: Value set Catheter Removed Resource: http://example.org/ValueSet/catheter-removed Canonical URL: http://example.org/ValueSet/catheter-removed Dependencies Dependency Description: FHIR model information Resource: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1 Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1 Dependency Description: Library Elements Resource: CAUTI Elements Canonical URL: http://hl7.org/fhir/uv/cqm/Library/CAUTIElements Dependency Description: Library FHIRHelpers Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1 Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1 Dependency Description: Library FHIRCommon Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0 Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0 Dependency Description: Library Parameters Resource: CAUTI Parameters Canonical URL: http://hl7.org/fhir/uv/cqm/Library/CAUTIParameters Data Requirements Data Requirement Type: Encounter Profile(s): Encounter Must Support Elements: period, location Data Requirement Type: Location Profile(s): Location Data Requirement Type: Observation Profile(s): Observation Must Support Elements: code, status, component, effective Code Filter(s): Path: code ValueSet: http://example.org/ValueSet/urine-culture Data Requirement Type: Patient Profile(s): Patient Data Requirement Type: Procedure Profile(s): Procedure Must Support Elements: code, status, performed Code Filter(s): Path: code ValueSet: http://example.org/ValueSet/catheter-removed Data Requirement Type: Procedure Profile(s): Procedure Must Support Elements: code, status, performed Code Filter(s): Path: code ValueSet: http://example.org/ValueSet/catheter-inserted Parameters Name Use Card. Type Documentation Measurement Period In 0..1 Period Denominator Initial Population Out 0..* Location Numerator Out 0..1 boolean Denominator Out 0..* Location Numerator Initial Population Out 0..1 boolean Generated using version 0.5.4 of the sample-content-ig Liquid templates
define "Encounter During Measurement Period": [Encounter] E where E.period during "Measurement Period"
define "Denominator Initial Population": [Location] L with Elements."Encounter During Measurement Period" E such that E.location.location.references(L)
define "Numerator Initial Population": exists (Elements."Encounter During Measurement Period")
define "Numerator": "Numerator Initial Population"
/* @description: CAUTI Risk Adjustment factors for Critical Access Hospitals @comment: Source: https://www.cdc.gov/nhsn/2022rebaseline/tables/table-10.html */ define "Critical Access Hospital Parameters": List<Tuple { parameter String, parameterEstimate Decimal, standardError Decimal, pValue String }> { // Intercept Tuple { parameter: 'Intercept', parameterEstimate: -7.6495, standardError: 0.1492, pValue: '<0.0001' }, // Average length of stay >= 6.5 days Tuple { parameter: 'Average length of stay >= 6.5', parameterEstimate: 0.4257, standardError: 0.1564, pValue: '0.0065' }, // Average length of stay < 6.5 days Tuple { parameter: 'Average length of stay < 6.5 days', parameterEstimate: 0.0, standardError: 0.0, pValue: 'REFERENT' }, // Proportion of total beds that are ICU < 0.16 Tuple { parameter: 'Proportion of total beds that are ICU < 0.16', parameterEstimate: 0.4189, standardError: 0.1708, pValue: '0.0142' }, // Proportion of total beds that are ICU >= 0.16 Tuple { parameter: 'Proportion of total beds that are ICU >= 0.16', parameterEstimate: 0.0, standardError: 0.0, pValue: 'REFERENT' } }
define "Denominator": "Denominator Initial Population"
define "Urine Culture With Bacterium": [Observation: "Urine Culture"] O where O.status = 'final' and exists ( O.component C where C.code in "Bacterium Presence" and C.value >= 10000 '[CFU]/mL' )
define "UTI": "Urine Culture With Bacterium" U let DOE: date from start of U.effective.toInterval(), IWP: Interval[DOE - 3 days, DOE + 3 days] where start of U.effective.toInterval() during "Measurement Period" return { urineCultureResult: U, dateOfEvent: DOE, infectionWindowPeriod: IWP }
define "Catheter Inserted Procedure": [Procedure: "Catheter Inserted"] P where P.status = 'completed'
define "Catheter Removed Procedure": [Procedure: "Catheter Removed"] P where P.status = 'completed'
define "Catheter Usage": "Catheter Inserted Procedure" I let catheterRemoved: First( "Catheter Removed Procedure" R where R.performed.toInterval() starts after I.performed.toInterval() sort by start of performed.toInterval() ) return Interval[ date from start of I.performed.toInterval(), date from start of catheterRemoved.performed.toInterval() ]
define "Catheter-Associated UTI": "UTI" U where exists ( "Catheter Usage" Usage where start of Usage before U.dateOfEvent and end of Usage on or after U.dateOfEvent - 1 day and duration in days of Usage > 2 )
/* @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]
/* @description: Returns true if any of the given references are to the given resource @comment: Returns true if the `id` element of the given resource exactly equals the tail of any of the given references. NOTE: This function assumes resources from the same source server. */ define fluent function references(references List<FHIR.Reference>, resource FHIR.Resource): exists (references R where R.references(resource))
/* @description: Returns true if the given reference is to the given resource @comment: Returns true if the `id` element of the given resource exactly equals the tail of the given reference. NOTE: This function assumes resources from the same source server. */ define fluent function references(reference FHIR.Reference, resource FHIR.Resource): resource.id = Last(Split(reference.reference, '/'))
define function ToString(value string): value.value
define function "Denominator Observation"(location Location): Sum( from (Parameters."Location Parameters"(location)) P, Parameters."Critical Access Hospital Parameters" H where P ~ H.parameter return all H.parameterEstimate ) * Elements."Patient Days"(location)
/* @description: Returns the characteristic codes for the given facility */ define function "Location Parameters"(location Location): { 'Intercept', location.averageLengthOfStayParameter(), location.proportionOfBedsICUParameter() }
// These would need to access computed data for these characteristics for the location define fluent function averageLengthOfStayParameter(location Location): 'Average length of stay >= 6.5 days'
define fluent function proportionOfBedsICUParameter(location Location): 'Proportion of total beds that are ICU < 0.16'
define function "Patient Days"(location Location): Sum( "Encounter During Measurement Period" E where E.location.location.references(location) return all duration in days of E.period )
define function "Numerator Observation"(): Count(Elements."Catheter-Associated UTI")
define function ToString(value ObservationStatus): value.value
/* @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 }
/* @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 }
/* @description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity) value to a CQL Quantity @comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`) an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used. @seealso: ToCalendarUnit */ define function ToQuantity(quantity FHIR.Quantity): case when quantity is null then null when quantity.value is null then null when quantity.comparator is not null then Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.') when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org' or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) } else Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')') end
/* @description: Converts a UCUM definite duration unit to a CQL calendar duration unit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities) topic of the CQL specification. @comment: Note that for durations above days (or weeks), the conversion is understood to be approximate */ define function ToCalendarUnit(unit System.String): case unit when 'ms' then 'millisecond' when 's' then 'second' when 'min' then 'minute' when 'h' then 'hour' when 'd' then 'day' when 'wk' then 'week' when 'mo' then 'month' when 'a' then 'year' else unit end
/* @description: Normalizes a value that is a choice of timing-valued types to an equivalent interval @comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range 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 FHIR, allowing this function to be used across any resource. The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range. 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 Period, the result is a DateTime Interval. If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing. If the input is an instant, the result is a DateTime Interval beginning and ending on that instant. If the input is a string, an error is raised indicating a single interval cannot be computed from a string. If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age, and ending immediately prior to when the patient was the given Age plus one year. If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given by the low end of the Range, and ending immediately prior to when the patient was the Age given by the high end of the Range plus one year. NOTE: Due to the complexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used with a Timing or String. */ define fluent function toInterval(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>): case when choice is FHIR.dateTime then Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)] when choice is FHIR.Period then FHIRHelpers.ToInterval(choice as FHIR.Period) when choice is FHIR.instant then Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)] when choice is FHIR.Age then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year) when choice is FHIR.Range then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year) when choice is FHIR.Timing then Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a Timing value is not supported') when choice is FHIR.string then Message(null as Interval<DateTime>, true, 'NOT_IMPLEMENTED', 'Error', 'Calculation of an interval from a String value is not supported') else null as Interval<DateTime> end
define function ToDateTime(value dateTime): value.value
define function ToDateTime(value instant): value.value
define function ToDate(value date): value.value
define function ToString(value ProcedureStatus): value.value
Example Catheter-Associated Urinary Tract Infection Standardized Infection Ratio (SIR)
HL7 International / Clinical Quality Information
Example measure illustrating an approach to representing the Catheter-Associated Urinary Tract Infection (CAUTI) Standardized Infection Ratio (SIR) measure. See https://github.com/cqframework/CQL-Formatting-and-Usage-Wiki/blob/master/Source/Cooking%20With%20CQL/93/CAUTI.md for more detailed discussion of the example.