Quality Measure Implementation Guide, published by HL7 International / Clinical Quality Information. This guide is not an authorized publication; it is the continuous build for version 1.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/HL7/fhir-cqm/ and changes regularly. See the Directory of published versions
Bundle sde-example-artifact-bundle of type transaction
Entry 1 - fullUrl = urn:uuid:31244296-3e84-4e17-94b1-4159d64e41db
Resource Library:
Request:
PUT Library/FHIRHelpers
Entry 2 - fullUrl = urn:uuid:aa99c584-12e5-46bb-8b30-ab10cfe26471
Resource Library:
Metadata Title FHIRCommon Version 4.0.1 Experimental true Type Logic Library Parameter Name: Patient
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: PatientData Requirement Type: Patient
Profile(s): Patient
Library Content CQL Content /* @author: Bryn Rhodes @description: Common terminologies and functions used in FHIR-based CQL artifacts */ library FHIRCommon version '4.0.1' using FHIR version '4.0.1' include FHIRHelpers version '4.0.1' codesystem "LOINC": 'http://loinc.org' codesystem "SNOMEDCT": 'http://snomed.info/sct' codesystem "RoleCode": 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' codesystem "Diagnosis Role": 'http://terminology.hl7.org/CodeSystem/diagnosis-role' codesystem "RequestIntent": 'http://terminology.hl7.org/CodeSystem/request-intent' codesystem "MedicationRequestCategory": 'http://terminology.hl7.org/CodeSystem/medicationrequest-category' codesystem "ConditionClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-clinical' codesystem "ConditionVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status' codesystem "AllergyIntoleranceClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical' codesystem "AllergyIntoleranceVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-verification' valueset "Active Condition": 'http://fhir.org/guides/cqf/common/ValueSet/active-condition' valueset "Inactive Condition": 'http://fhir.org/guides/cqf/common/ValueSet/inactive-condition' code "Birthdate": '21112-8' from "LOINC" display 'Birth date' code "Dead": '419099009' from "SNOMEDCT" display 'Dead' code "ER": 'ER' from "RoleCode" display 'Emergency room' code "ICU": 'ICU' from "RoleCode" display 'Intensive care unit' code "Billing": 'billing' from "Diagnosis Role" display 'Billing' // Condition Clinical Status Codes - Consider value sets for these code "active": 'active' from "ConditionClinicalStatusCodes" code "recurrence": 'recurrence' from "ConditionClinicalStatusCodes" code "relapse": 'relapse' from "ConditionClinicalStatusCodes" code "inactive": 'inactive' from "ConditionClinicalStatusCodes" code "remission": 'remission' from "ConditionClinicalStatusCodes" code "resolved": 'resolved' from "ConditionClinicalStatusCodes" // Condition Verification Status Codes - Consider value sets for these code "unconfirmed": 'unconfirmed' from ConditionVerificationStatusCodes code "provisional": 'provisional' from ConditionVerificationStatusCodes code "differential": 'differential' from ConditionVerificationStatusCodes code "confirmed": 'confirmed' from ConditionVerificationStatusCodes code "refuted": 'refuted' from ConditionVerificationStatusCodes code "entered-in-error": 'entered-in-error' from ConditionVerificationStatusCodes code "allergy-active": 'active' from "AllergyIntoleranceClinicalStatusCodes" code "allergy-inactive": 'inactive' from "AllergyIntoleranceClinicalStatusCodes" code "allergy-resolved": 'resolved' from "AllergyIntoleranceClinicalStatusCodes" // Allergy/Intolerance Verification Status Codes - Consider value sets for these code "allergy-unconfirmed": 'unconfirmed' from AllergyIntoleranceVerificationStatusCodes code "allergy-confirmed": 'confirmed' from AllergyIntoleranceVerificationStatusCodes code "allergy-refuted": 'refuted' from AllergyIntoleranceVerificationStatusCodes // MedicationRequest Category Codes code "Community": 'community' from "MedicationRequestCategory" display 'Community' code "Discharge": 'discharge' from "MedicationRequestCategory" display 'Discharge' // Diagnosis Role Codes code "AD": 'AD' from "Diagnosis Role" display 'Admission diagnosis' code "DD": 'DD' from "Diagnosis Role" display 'Discharge diagnosis' code "CC": 'CC' from "Diagnosis Role" display 'Chief complaint' code "CM": 'CM' from "Diagnosis Role" display 'Comorbidity diagnosis' code "pre-op": 'pre-op' from "Diagnosis Role" display 'pre-op diagnosis' code "post-op": 'post-op' from "Diagnosis Role" display 'post-op diagnosis' code "billing": 'billing' from "Diagnosis Role" display 'billing diagnosis' context Patient /* @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. 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 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, '1', 'Error', 'Cannot compute a single interval from a Timing type') when choice is FHIR.string then Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value') else null as Interval<DateTime> end /* @description: Returns an interval representing the normalized Abatement of a given Condition resource. @comment: NOTE: Due to the complexity of determining an interval from a String, this function will throw a run-time exception if used with a Condition instance that has a String as the abatement value. */ define function ToAbatementInterval(condition Condition): if condition.abatement is FHIR.dateTime then Interval[FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime), FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime)] else if condition.abatement is FHIR.Period then FHIRHelpers.ToInterval(condition.abatement as FHIR.Period) else if condition.abatement is FHIR.string then Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value') else if condition.abatement is FHIR.Age then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age) + 1 year) else if condition.abatement is FHIR.Range then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).low), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).high) + 1 year) else if condition.abatement is FHIR.boolean then Interval[end of ToInterval(condition.onset), condition.recordedDate) else null /* @description: Returns an interval representing the normalized prevalence period of a given Condition resource. @comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from onset to abatement as specified in the given Condition. */ define function ToPrevalenceInterval(condition Condition): if condition.clinicalStatus ~ "active" or condition.clinicalStatus ~ "recurrence" or condition.clinicalStatus ~ "relapse" then Interval[start of ToInterval(condition.onset), end of ToAbatementInterval(condition)] else Interval[start of ToInterval(condition.onset), end of ToAbatementInterval(condition)) /* @description: Returns any extensions defined on the given resource with the specified url. @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info. */ define function Extensions(domainResource DomainResource, url String): domainResource.extension E where E.url = url return E /* @description: Returns the single extension (if present) on the given resource with the specified url. @comment: This function uses singleton from to ensure that a run-time exception is thrown if there is more than one extension on the given resource with the specified url. */ define function Extension(domainResource DomainResource, url String): singleton from "Extensions"(domainResource, url) /* @description: Returns any extensions defined on the given element with the specified url. @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info. */ define function Extensions(element Element, url String): element.extension E where E.url = url return E /* @description: Returns the single extension (if present) on the given element with the specified url. @comment: This function uses singleton from to ensure that a run-time exception is thrown if there is more than one extension on the given resource with the specified url. */ define function Extension(element Element, url String): singleton from Extensions(element, url) /* @description: Returns any modifier extensions defined on the given resource with the specified url. @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info. */ define function ModifierExtensions(domainResource DomainResource, url String): domainResource.modifierExtension E where E.url = url return E /* @description: Returns the single modifier extension (if present) on the given resource with the specified url. @comment: This function uses singleton from to ensure that a run-time exception is thrown if there is more than one extension on the given resource with the specified url. */ define function ModifierExtension(domainResource DomainResource, url String): singleton from ModifierExtensions(domainResource, url) /* @description: Returns any modifier extensions defined on the given element with the specified url. @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info. */ define function ModifierExtensions(element BackboneElement, url String): element.modifierExtension E where E.url = url return E /* @description: Returns the single modifier extension (if present) on the given element with the specified url. @comment: This function uses singleton from to ensure that a run-time exception is thrown if there is more than one extension on the given resource with the specified url. */ define function ModifierExtension(element BackboneElement, url String): singleton from ModifierExtensions(element, url) /* @description: Returns any base-FHIR extensions defined on the given resource with the specified id. @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info. */ define function BaseExtensions(domainResource DomainResource, id String): domainResource.extension E where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id) return E /* @description: Returns the single base-FHIR extension (if present) on the given resource with the specified id. @comment: This function uses singleton from to ensure that a run-time exception is thrown if there is more than one extension on the given resource with the specified url. */ define function BaseExtension(domainResource DomainResource, id String): singleton from BaseExtensions(domainResource, id) /* @description: Returns any base-FHIR extensions defined on the given element with the specified id. @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info. */ define function BaseExtensions(element Element, id String): element.extension E where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id) return E /* @description: Returns the single base-FHIR extension (if present) on the given element with the specified id. @comment: This function uses singleton from to ensure that a run-time exception is thrown if there is more than one extension on the given resource with the specified url. */ define function BaseExtension(element Element, id String): singleton from BaseExtensions(element, id) /* @description: Returns any base-FHIR modifier extensions defined on the given resource with the specified id. @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info. */ define function BaseModifierExtensions(domainResource DomainResource, id String): domainResource.modifierExtension E where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id) return E /* @description: Returns the single base-FHIR modifier extension (if present) on the given resource with the specified id. @comment: This function uses singleton from to ensure that a run-time exception is thrown if there is more than one extension on the given resource with the specified url. */ define function BaseModifierExtension(domainResource DomainResource, id String): singleton from BaseModifierExtensions(domainResource, id) /* @description: Returns any base-FHIR modifier extensions defined on the given element with the specified id. @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info. */ define function BaseModifierExtensions(element BackboneElement, id String): element.modifierExtension E where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id) return E /* @description: Returns the single base-FHIR extension (if present) on the given element with the specified id. @comment: This function uses singleton from to ensure that a run-time exception is thrown if there is more than one extension on the given resource with the specified url. */ define function BaseModifierExtension(element BackboneElement, id String): singleton from BaseModifierExtensions(element, id)
ELM XML Content Encoded data (291380 characters)
ELM JSON Content Encoded data (554336 characters)
Generated using version 0.4.9 of the sample-content-ig Liquid templates
Request:
PUT Library/FHIRCommon
Entry 3 - fullUrl = urn:uuid:b3463968-f67d-42ef-8494-cd4ea42e87b9
Resource Library:
Metadata Title MAT Global Common Functions FHIRR4 Version 6.1.000 Experimental true Type Logic Library Parameter Name: Measurement Period
Use: In
Min Cardinality: 0
Max Cardinality: 1
Type: PeriodParameter Name: Patient
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: PatientParameter Name: Inpatient Encounter
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: EncounterData Requirement Type: Patient
Profile(s): Patient
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period
Code Filter(s):
Path: type
ValueSet: Encounter Inpatient
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: Observation Services
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period
Code Filter(s):
Path: type
ValueSet: Emergency Department Visit
Data Requirement Type: Condition
Profile(s): Condition
Must Support Elements: id
Data Requirement Type: Location
Profile(s): Location
Must Support Elements: id
Data Requirement Type: Provenance
Profile(s): Provenance
Must Support Elements: target
Code Filter(s):
Path: target
Library Content CQL Content library MATGlobalCommonFunctionsFHIR4 version '6.1.000' /*@update: BTR 2020-03-31 -> Incremented version to 5.0.000 Updated FHIR version to 4.0.1 Changed timezone keyword to timezoneoffset for use with CQL 1.4 Removed Normalize Onset in favor of more general Normalize Interval Updated CodeSystems for ConditionVerificationStatusCodes and RoleCodes @update: BTR 2021-05-13 -> Added ActiveCondition Codes and Inactive Condition Codes value sets Added function documentation throughout Fixed EDVisit not using Last Updated prevalence period to use an inclusive boundary if the condition is active Added HasStart, HasEnd, Earliest, and Latest functions Removed ToDate and Age calculation functions @update: BTR 2021-06-25 -> Added GetBaseExtension overloads for Element*/ using FHIR version '4.0.1' include FHIRHelpers version '4.0.1' called FHIRHelpers codesystem "ConditionClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-clinical' codesystem "AllergyIntoleranceClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical' codesystem "AllergyIntoleranceVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-verification' codesystem "Diagnosis Role": 'http://terminology.hl7.org/CodeSystem/diagnosis-role' codesystem "LOINC": 'http://loinc.org' codesystem "MedicationRequestCategory": 'http://terminology.hl7.org/CodeSystem/medicationrequest-category' codesystem "ConditionVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status' codesystem "SNOMEDCT": 'http://snomed.info/sct' codesystem "RoleCode": 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' valueset "Emergency Department Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292' valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307' valueset "Observation Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143' code "active": 'active' from "ConditionClinicalStatusCodes" display 'active' code "allergy-active": 'active' from "AllergyIntoleranceClinicalStatusCodes" display 'allergy-active' code "allergy-confirmed": 'confirmed' from "AllergyIntoleranceVerificationStatusCodes" display 'allergy-confirmed' code "allergy-inactive": 'inactive' from "AllergyIntoleranceClinicalStatusCodes" display 'allergy-inactive' code "allergy-refuted": 'refuted' from "AllergyIntoleranceVerificationStatusCodes" display 'allergy-refuted' code "allergy-resolved": 'resolved' from "AllergyIntoleranceClinicalStatusCodes" display 'allergy-resolved' code "allergy-unconfirmed": 'unconfirmed' from "AllergyIntoleranceVerificationStatusCodes" display 'allergy-unconfirmed' code "Billing": 'billing' from "Diagnosis Role" display 'Billing' code "Birthdate": '21112-8' from "LOINC" display 'Birth date' code "Community": 'community' from "MedicationRequestCategory" display 'Community' code "confirmed": 'confirmed' from "ConditionVerificationStatusCodes" display 'confirmed' code "Dead": '419099009' from "SNOMEDCT" display 'Dead' code "differential": 'differential' from "ConditionVerificationStatusCodes" display 'differential' code "Discharge": 'discharge' from "MedicationRequestCategory" display 'Discharge' code "entered-in-error": 'entered-in-error' from "ConditionVerificationStatusCodes" display 'entered-in-error' code "ER": 'ER' from "RoleCode" display 'Emergency room' code "ICU": 'ICU' from "RoleCode" display 'Intensive care unit' code "inactive": 'inactive' from "ConditionClinicalStatusCodes" display 'inactive' code "provisional": 'provisional' from "ConditionVerificationStatusCodes" display 'provisional' code "recurrence": 'recurrence' from "ConditionClinicalStatusCodes" display 'recurrence' code "refuted": 'refuted' from "ConditionVerificationStatusCodes" display 'refuted' code "relapse": 'relapse' from "ConditionClinicalStatusCodes" display 'relapse' code "remission": 'remission' from "ConditionClinicalStatusCodes" display 'remission' code "resolved": 'resolved' from "ConditionClinicalStatusCodes" display 'resolved' code "unconfirmed": 'unconfirmed' from "ConditionVerificationStatusCodes" display 'unconfirmed' parameter "Measurement Period" Interval<DateTime> default Interval[@2019-01-01T00:00:00.0, @2020-01-01T00:00:00.0) context Patient define "Inpatient Encounter": [Encounter: "Encounter Inpatient"] EncounterInpatient where EncounterInpatient.status = 'finished' and "LengthInDays"(EncounterInpatient.period) <= 120 and EncounterInpatient.period ends during "Measurement Period" /*Calculates the difference in calendar days between the start and end of the given interval.*/ define function "LengthInDays"(Value Interval<DateTime> ): difference in days between start of Value and end of Value /*Returns the most recent emergency department visit, if any, that occurs 1 hour or less prior to the given encounter.*/ define function "ED Visit"(TheEncounter FHIR.Encounter ): Last( [Encounter: "Emergency Department Visit"] EDVisit where EDVisit.status = 'finished' and EDVisit.period ends 1 hour or less on or before start of FHIRHelpers.ToInterval(TheEncounter.period) sort by end of period ) /*Hospitalization returns the total interval for admission to discharge for the given encounter, or for the admission of any immediately prior emergency department visit to the discharge of the given encounter.*/ define function "Hospitalization"(TheEncounter FHIR.Encounter ): ( "ED Visit"(TheEncounter) ) X return if X is null then TheEncounter.period else Interval[start of FHIRHelpers.ToInterval(X.period), end of FHIRHelpers.ToInterval(TheEncounter.period)] /*Returns list of all locations within an encounter, including locations for immediately prior ED visit.*/ define function "Hospitalization Locations"(TheEncounter FHIR.Encounter ): ( "ED Visit"(TheEncounter) ) EDEncounter return if EDEncounter is null then TheEncounter.location else flatten { EDEncounter.location, TheEncounter.location } /*Returns the length of stay in days (i.e. the number of days between admission and discharge) for the given encounter, or from the admission of any immediately prior emergency department visit to the discharge of the encounter*/ define function "Hospitalization Length of Stay"(TheEncounter FHIR.Encounter ): LengthInDays("Hospitalization"(TheEncounter)) /*Returns admission time for an encounter or for immediately prior emergency department visit.*/ define function "Hospital Admission Time"(TheEncounter FHIR.Encounter ): start of "Hospitalization"(TheEncounter) /*Hospital Discharge Time returns the discharge time for an encounter*/ define function "Hospital Discharge Time"(TheEncounter FHIR.Encounter ): end of FHIRHelpers.ToInterval(TheEncounter.period) /*Returns earliest arrival time for an encounter including any prior ED visit.*/ define function "Hospital Arrival Time"(TheEncounter FHIR.Encounter ): start of FHIRHelpers.ToInterval(First( ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation sort by start of FHIRHelpers.ToInterval(period) ).period) // TODO - fix these (must fetch Location resources and compare id to reference) /*Returns the latest departure time for encounter including any prior ED visit. */ /* define function "Hospital Departure Time"(TheEncounter FHIR.Encounter): end of FHIRHelpers.ToInterval(Last( ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation sort by start of FHIRHelpers.ToInterval(period) ).period) define function "Emergency Department Arrival Time"(TheEncounter FHIR.Encounter): start of FHIRHelpers.ToInterval(( singleton from ( ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation where HospitalLocation.type ~ "ER" ) ).period) define function "First Inpatient Intensive Care Unit"(TheEncounter FHIR.Encounter): First( ( TheEncounter.location ) HospitalLocation where HospitalLocation.type ~ "ICU" and HospitalLocation.period during TheEncounter.period sort by start of FHIRHelpers.ToInterval(period) ) */ /*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.*/ /* TODO: define function "HospitalizationWithObservationAndOutpatientSurgeryService"(Encounter "Encounter, Performed" ): Encounter Visit let ObsVisit: Last(["Encounter, Performed": "Observation Services"] LastObs where LastObs.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod sort by end of relevantPeriod ), VisitStart: Coalesce(start of ObsVisit.relevantPeriod, start of Visit.relevantPeriod), EDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED where LastED.relevantPeriod ends 1 hour or less on or before VisitStart sort by end of relevantPeriod ), VisitStartWithED: Coalesce(start of EDVisit.relevantPeriod, VisitStart), OutpatientSurgeryVisit: Last(["Encounter, Performed": "Outpatient Surgery Service"] LastSurgeryOP where LastSurgeryOP.relevantPeriod ends 1 hour or less on or before VisitStartWithED sort by end of relevantPeriod ) return Interval[Coalesce(start of OutpatientSurgeryVisit.relevantPeriod, VisitStartWithED), end of Visit.relevantPeriod] */ /*Hospitalization with Observation returns the total interval from the start of any immediately prior emergency department visit through the observation visit to the discharge of the given encounter*/ define function "HospitalizationWithObservation"(TheEncounter FHIR.Encounter ): TheEncounter Visit let ObsVisit: Last([Encounter: "Observation Services"] LastObs where 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.period ends 1 hour or less on or before VisitStart sort by end of period ) return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period] /** * Normalizes the input argument to an interval representation. * 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.*/ define function "Normalize Interval"(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, '1', 'Error', 'Cannot compute a single interval from a Timing type') when choice is FHIR.string then Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value') else null as Interval<DateTime> end /** * Returns an interval representing the abatement of the given condition, if an abatement element is present, null otherwise. This function uses the semantics of Normalize Interval to interpret the abatement element.*/ define function "Normalize Abatement"(condition Condition ): if condition.abatement is FHIR.dateTime then Interval[FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime), FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime)] else if condition.abatement is FHIR.Period then FHIRHelpers.ToInterval(condition.abatement as FHIR.Period) else if condition.abatement is FHIR.string then Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value') else if condition.abatement is FHIR.Age then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age) + 1 year) else if condition.abatement is FHIR.Range then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).low), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).high) + 1 year) else if condition.abatement is FHIR.boolean then Interval[end of "Normalize Interval"(condition.onset), condition.recordedDate) else null /*Returns an interval representing the period during which the condition was prevalent (i.e. onset to abatement) If the condition is "active", then abatement being unknown would indicate the condition is ongoing, and the ending boundary of the prevalence period is inclusive, otherwise, the abatement is considered unknown and the ending boundary of the prevalence period is exclusive. Note that when using this function it should be noted that many clinical systems do not actually capture abatement, so care should be taken when using this function to meet clinical intent.*/ define function "Prevalence Period"(condition Condition ): if condition.clinicalStatus ~ "active" or condition.clinicalStatus ~ "recurrence" or condition.clinicalStatus ~ "relapse" then Interval[start of "Normalize Interval"(condition.onset), end of "Normalize Abatement"(condition)] else Interval[start of "Normalize Interval"(condition.onset), end of "Normalize Abatement"(condition)) /*Returns the tail of the given uri (i.e. everything after the last slash in the URI).*/ define function "GetId"(uri String ): Last(Split(uri, '/')) /*Returns the Condition resources referenced by the diagnosis element of the Encounter*/ define function "EncounterDiagnosis"(Encounter Encounter ): Encounter.diagnosis D return singleton from ([Condition] C where C.id = "GetId"(D.condition.reference)) // Returns the condition that is specified as the principal diagnosis for the encounter // TODO: BTR 2019-07-30: Shouldn't need the FHIRHelpers reference here, investigate define function "PrincipalDiagnosis"(Encounter Encounter ): (singleton from (Encounter.diagnosis D where FHIRHelpers.ToInteger(D.rank) = 1)) PD return singleton from ([Condition] C where C.id = "GetId"(PD.condition.reference)) // Returns the location for the given location reference /*Returns the Location resource specified by the given reference*/ define function "GetLocation"(reference Reference ): singleton from ( [Location] L where L.id = GetId(reference.reference) ) /*NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info.*/ define function "GetExtensions"(domainResource DomainResource, url String ): domainResource.extension E where E.url = ('http://hl7.org/fhir/us/qicore/StructureDefinition/' + url) return E define function "GetExtension"(domainResource DomainResource, url String ): singleton from "GetExtensions"(domainResource, url) /*NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info.*/ define function "GetExtensions"(element Element, url String ): element.extension E where E.url = (url) return E define function "GetExtension"(element Element, url String ): singleton from "GetExtensions"(element, url) /*NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info.*/ define function "GetBaseExtensions"(domainResource DomainResource, url String ): domainResource.extension E where E.url = ('http://hl7.org/fhir/StructureDefinition/' + url) return E define function "GetBaseExtension"(domainResource DomainResource, url String ): singleton from "GetBaseExtensions"(domainResource, url) /*@description: Returns any base-FHIR extensions defined on the given element with the specified id. @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access content that is defined by extensions but not yet surfaced in the CQL model info.*/ define function "BaseExtensions"(element Element, id String ): element.extension E where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id) return E /*@description: Returns the single base-FHIR extension (if present) on the given element with the specified id. @comment: This function uses singleton from to ensure that a run-time exception is thrown if there is more than one extension on the given resource with the specified url.*/ define function "BaseExtension"(element Element, id String ): singleton from BaseExtensions(element, id) /*NOTE: Provenance is not the preferred approach, this is provided only as an illustration for what using Provenance could look like, and is not a tested pattern*/ define function "GetProvenance"(resource Resource ): singleton from ([Provenance: target in resource.id]) define function "GetMedicationCode"(request MedicationRequest ): if request.medication is CodeableConcept then request.medication as CodeableConcept else (singleton from ([Medication] M where M.id = GetId((request.medication as Reference).reference))).code /*Given an interval, return true if the interval has a starting boundary specified (i.e. the start of the interval is not null and not the minimum DateTime value)*/ define function "HasStart"(period Interval<DateTime> ): not ( start of period is null or start of period = minimum DateTime ) /*Given an interval, return true if the interval has an ending boundary specified (i.e. the end of the interval is not null and not the maximum DateTime value)*/ define function "HasEnd"(period Interval<DateTime> ): not ( end of period is null or end of period = maximum DateTime ) /*Given an interval, return the ending point if the interval has an ending boundary specified, otherwise, return the starting point*/ define function "Latest"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range> ): ("Normalize Interval"(choice)) period return if ( HasEnd(period)) then end of period else start of period /*Given an interval, return the starting point if the interval has a starting boundary specified, otherwise, return the ending point*/ define function "Earliest"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range> ): ("Normalize Interval"(choice)) period return if (HasStart(period)) then start of period else end of period
ELM XML Content Encoded data (413356 characters)
ELM JSON Content Encoded data (782204 characters)
Generated using version 0.4.9 of the sample-content-ig Liquid templates
Request:
PUT Library/MATGlobalCommonFunctionsFHIR4
Entry 4 - fullUrl = urn:uuid:c6098378-cb38-4ae2-a096-3a3cc5c620d5
Resource Library:
Metadata Title SupplementalDataElementsFHIR4 Version 2.0.000 Experimental true Type Logic Library Parameter Name: Patient
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: PatientParameter Name: SDE Ethnicity
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: CodingParameter Name: SDE Payer
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: ResourceParameter Name: SDE Race
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: CodingParameter Name: SDE Sex
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: CodingData Requirement Type: Patient
Profile(s): Patient
Must Support Elements: url, extension, value
Data Requirement Type: Coverage
Profile(s): Coverage
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: Payer Type
Library Content CQL Content library SupplementalDataElementsFHIR4 version '2.0.000' /*@update: @@BTR 2020-03-31 -> Incremented version to 2.0.0 Updated FHIR version to 4.0.1 @@@*/ using FHIR version '4.0.1' include FHIRHelpers version '4.0.1' called FHIRHelpers valueset "Ethnicity": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.837' valueset "ONC Administrative Sex": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1' valueset "Payer": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591' valueset "Race": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.836' context Patient define "SDE Ethnicity": (flatten ( Patient.extension Extension where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity' return Extension.extension )) E where E.url = 'ombCategory' or E.url = 'detailed' return E.value as Coding define "SDE Payer": [Coverage: type in "Payer"] Payer return { code: Payer.type, period: Payer.period } define "SDE Race": (flatten ( Patient.extension Extension where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race' return Extension.extension )) E where E.url = 'ombCategory' or E.url = 'detailed' return E.value as Coding define "SDE Sex": case when Patient.gender = 'male' then Code { code: 'M', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Male' } when Patient.gender = 'female' then Code { code: 'F', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Female' } else null end
ELM XML Content Encoded data (42384 characters)
ELM JSON Content Encoded data (76656 characters)
Generated using version 0.4.9 of the sample-content-ig Liquid templates
Request:
PUT Library/SupplementalDataElementsFHIR4
Entry 5 - fullUrl = urn:uuid:e3b78b9e-96ee-43fb-aeea-22a7681a1538
Resource Library:
Metadata Title NHSN Glycemic Control Hypoglycemic Initial Population Version 0.0.002 Experimental true Type Logic Library Parameter Name: Measurement Period
Use: In
Min Cardinality: 0
Max Cardinality: 1
Type: PeriodParameter Name: Patient
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: PatientParameter Name: Inpatient Encounter
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: EncounterParameter Name: Patient Hospital Locations
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: EncounterParameter Name: Antidiabetic Drugs Administered or Ordered
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: ResourceParameter Name: Initial Population
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: EncounterParameter Name: SDE Chief Complaint
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: EncounterParameter Name: SDE Condition
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: ConditionParameter Name: SDE Condition during Encounter
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: ConditionParameter Name: SDE Encounter Discharge Dispositions
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: EncounterParameter Name: SDE Encounter Locations
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: EncounterParameter Name: SDE Medication Administration
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: MedicationAdministrationParameter Name: SDE Medication Request
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: MedicationRequestParameter Name: SDE Blood Glucose Observation
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: ObservationParameter Name: SDE Payer
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: ResourceParameter Name: SDE Specimen
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: SpecimenParameter Name: SDE Minimal Patient
Use: Out
Min Cardinality: 0
Max Cardinality: 1
Type: PatientParameter Name: SDE Minimal Medication Requests
Use: Out
Min Cardinality: 0
Max Cardinality: *
Type: MedicationRequestData Requirement Type: Patient
Profile(s): Patient
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: class
Code Filter(s):
Path: class
Code(s): ActCode IMP: inpatient encounter, ActCode ACUTE: inpatient acute, ActCode NONAC: inpatient non-acute, ActCode SS: short stay
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, status, period
Code Filter(s):
Path: type
ValueSet: Encounter Inpatient
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: location, period
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, class, period
Code Filter(s):
Path: type
ValueSet: Observation Services
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: type, class, period
Code Filter(s):
Path: type
ValueSet: Emergency Department Visit
Data Requirement Type: Location
Profile(s): Location
Must Support Elements: id
Data Requirement Type: Medication
Profile(s): Medication
Must Support Elements: id
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Must Support Elements: medication, status, effective
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, authoredOn
Data Requirement Type: Specimen
Profile(s): Specimen
Must Support Elements: id, collection, collection.collected
Data Requirement Type: Condition
Profile(s): Condition
Must Support Elements: onset, category
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, effective, specimen, specimen.collection, specimen.collection.collected, category
Code Filter(s):
Path: code
ValueSet: Blood Glucose Laboratory and Point of Care Tests
Data Requirement Type: Coverage
Profile(s): Coverage
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: Payer Type
Library Content CQL Content library NHSNGlycemicControlHypoglycemicInitialPopulation version '0.0.002' using FHIR version '4.0.1' include FHIRHelpers version '4.0.1' called FHIRHelpers include SupplementalDataElementsFHIR4 version '2.0.000' called SDE include MATGlobalCommonFunctionsFHIR4 version '6.1.000' called Global codesystem "ActCode": 'http://terminology.hl7.org/CodeSystem/v3-ActCode' codesystem "Diagnosis Role": 'http://terminology.hl7.org/CodeSystem/diagnosis-role' codesystem "Specimen Type": 'http://terminology.hl7.org/CodeSystem/v2-0487' codesystem "Observation Category": 'http://terminology.hl7.org/CodeSystem/observation-category' codesystem "Condition Category": 'http://terminology.hl7.org/CodeSystem/condition-category' valueset "Blood Glucose Laboratory and Point of Care Tests": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.38' valueset "Inpatient, Emergency, and Observation Locations": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.265' valueset "Discharge Disposition": 'http://terminology.hl7.org/ValueSet/encounter-discharge-disposition' valueset "Antidiabetic Medications": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.58' valueset "Emergency Department Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292' valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307' valueset "Observation Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143' code "Chief Complaint": 'CC' from "Diagnosis Role" display 'Chief complaint' code "emergency": 'EMER' from "ActCode" display 'emergency' code "inpatient acute": 'ACUTE' from "ActCode" display 'inpatient acute' code "inpatient encounter": 'IMP' from "ActCode" display 'inpatient encounter' code "inpatient non-acute": 'NONAC' from "ActCode" display 'inpatient non-acute' code "observation encounter": 'OBSENC' from "ActCode" display 'observation encounter' code "short stay": 'SS' from "ActCode" display 'short stay' code "laboratory": 'laboratory' from "Observation Category" display 'Laboratory' code "encounter-diagnosis": 'encounter-diagnosis' from "Condition Category" display'encounter-diagnosis' parameter "Measurement Period" Interval<DateTime> default Interval[@2022-01-01T00:00:00.0, @2022-01-31T00:00:00.0) context Patient define "Initial Population": ("Inpatient Encounter" union "Patient Hospital Locations") InpatientEncounters with "Antidiabetic Drugs Administered or Ordered" ADD such that Coalesce(start of Global."Normalize Interval"(ADD.effective), ADD.authoredOn) during "HospitalizationWithObservationOrEmergency"(InpatientEncounters) and Coalesce(start of Global."Normalize Interval"(ADD.effective), ADD.authoredOn) during "Measurement Period" define "Inpatient Encounter": [Encounter: class in {"inpatient encounter", "inpatient acute", "inpatient non-acute", "short stay"}] union [Encounter: "Encounter Inpatient"] Encounters where Encounters.status in {'in-progress', 'finished'} and Encounters.period overlaps "Measurement Period" define "Patient Hospital Locations": [Encounter] Encounters where exists( Encounters.location EncounterLocation where Global.GetLocation(EncounterLocation.location).type in "Inpatient, Emergency, and Observation Locations" and EncounterLocation.period during Encounters.period ) define "Antidiabetic Drugs Administered or Ordered": ([MedicationAdministration] ADDMedAdmin where GetMedicationCode(ADDMedAdmin.medication) in "Antidiabetic Medications" and ADDMedAdmin.status ~ 'completed') union ( [MedicationRequest] MedicationRequests where GetMedicationCode(MedicationRequests.medication) in "Antidiabetic Medications" ) define function "GetMedicationCode"(choice Choice<FHIR.CodeableConcept, FHIR.Reference>): case when choice is FHIR.CodeableConcept then choice as FHIR.CodeableConcept when choice is FHIR.Reference then GetMedication(choice as FHIR.Reference).code else null as FHIR.CodeableConcept end define function "GetMedication"(reference Reference ): singleton from ( [Medication] M where M.id = Global.GetId(reference.reference) ) define function "HospitalizationWithObservationOrEmergency"(TheEncounter FHIR.Encounter ): TheEncounter Visit let ObsVisit: Last([Encounter: "Observation Services"] LastObs where LastObs.class ~ "observation encounter" 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.class ~ "emergency" and LastED.period ends 1 hour or less on or before start of Visit.period sort by end of period ) return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period] define function "GetSpecimen"(reference Reference): singleton from ( [Specimen] S where S.id = Global.GetId(reference.reference) ) define function "GetPatientExtensions"(domainResource DomainResource): domainResource.extension E where E.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race' or E.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity' or E.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex' or E.url = 'https://hl7.org/fhir/us/core/StructureDefinition-us-core-genderIdentity' return E define function "GetPatientAddress"(addresses List<FHIR.Address>): addresses address return FHIR.Address{ postalCode: address.postalCode } define function "MedicationRequestResource"(medicationRequest MedicationRequest): medicationRequest m return MedicationRequest{ id: FHIR.id {value: 'new-' + m.id}, medication: GetMedicationCode(m.medication), dosageInstruction: m.dosageInstruction } //Supplement Data Elements define "SDE Chief Complaint": "Initial Population" IP with IP.diagnosis InitialPopulationDiagnosis such that InitialPopulationDiagnosis.use ~ "Chief Complaint" define "SDE Condition": [Condition] Conditions with "Initial Population" InitialPopulation such that Global."Normalize Interval"(Conditions.onset) overlaps InitialPopulation.period define "SDE Condition during Encounter": [Condition] ConditionEncounterDiagnosis with ConditionEncounterDiagnosis.category Category such that Category ~ "encounter-diagnosis" and exists("Initial Population") define "SDE Encounter Discharge Dispositions": "Initial Population" DischargeDispositions where DischargeDispositions.hospitalization.dischargeDisposition in "Discharge Disposition" define "SDE Encounter Locations": "Initial Population" InitialPopulation where exists ( InitialPopulation.location InitialPopulationLocation where (Global.GetLocation(InitialPopulationLocation.location).type in "Inpatient, Emergency, and Observation Locations" and InitialPopulationLocation.period during InitialPopulation.period) ) define "SDE Medication Administration": [MedicationAdministration] MedicationAdministrations with "Initial Population" InitialPopulation such that start of Global."Normalize Interval"(MedicationAdministrations.effective) during "HospitalizationWithObservationOrEmergency"(InitialPopulation) and start of Global."Normalize Interval"(MedicationAdministrations.effective) during "Measurement Period" define "SDE Medication Request": [MedicationRequest] MedicationRequests with "Initial Population" InitialPopulation such that MedicationRequests.authoredOn during "HospitalizationWithObservationOrEmergency"(InitialPopulation) and MedicationRequests.authoredOn during "Measurement Period" define "SDE Blood Glucose Observation": [Observation: "Blood Glucose Laboratory and Point of Care Tests"] Observations with "Initial Population" InitialPopulation such that start of Global."Normalize Interval"(Observations.effective) during InitialPopulation.period or Global."Normalize Interval"(GetSpecimen(Observations.specimen).collection.collected) during InitialPopulation.period with Observations.category category such that category ~ "laboratory" define "SDE Payer": SDE."SDE Payer" Payer with "Initial Population" InitialPopulation such that start of Payer.period before end of InitialPopulation.period define "SDE Specimen": [Specimen] Specimen with "Initial Population" InitialPopulation such that Global."Normalize Interval"(Specimen.collection.collected) during InitialPopulation.period //Change on CQF ruler happened on 8/12. Check to make sure CQF-Ruler version is dated at or after (version 2.0.0). //Wait 2-3 days before the changes are actually applied to the CQF-Ruler. define "SDE Minimal Patient": Patient{ id: Patient.id, extension: GetPatientExtensions(Patient), identifier: Patient.identifier, gender: Patient.gender, birthDate: Patient.birthDate, deceased: Patient.deceased, address: GetPatientAddress(Patient.address) } define "SDE Minimal Medication Requests": [MedicationRequest] MedicationRequests return MedicationRequestResource(MedicationRequests) /*define "SDE Resource Construction Test Inlib": FHIR.Observation { id: FHIR.id { value: 'observation-sdetestinlib-' + ToString(Now()) }, status: FHIR.ObservationStatus { value: 'final' }, code: FHIR.CodeableConcept { coding: { FHIR.Coding { code: FHIR.code { value: 'days-since-appointment' } } } }, subject: FHIR.Reference { reference: FHIR.string { value: Patient.id.value }} //value: FHIR.integer { value: Abs(difference in days between end of SDE."Last Appointment".period and ToDateTime(Today())) } }*/ define "SDE Ethnicity Coding": SDE."SDE Ethnicity" define "SDE Race Coding": SDE."SDE Race"
Generated using version 0.4.9 of the sample-content-ig Liquid templates
Request:
PUT Library/NHSNGlycemicControlHypoglycemicInitialPopulation
Entry 6 - fullUrl = urn:uuid:61d3ae55-c7b7-484f-96df-4f3ef8c080c0
Resource Measure:
Metadata Title NHSN Glycemic Control, Hypoglycemia Initial Population Version 0.000.01 Identifier nhsnglycemiccontrolhypoglycemicinitialpopulation Experimental true Steward (Publisher) NHSN Description All inpatient encounters (including ED/Observation visits that end within 1 hour of the start of the inpatient encounter) for patients of all ages where at least one ADD was ordered or administered during the encounter that is during the measurement period.
Purpose This measure has been developed to support improvement in clinical care.
Copyright This measure and specifications are subject to further revisions. This performance measure is not a clinical guideline, does not establish a standard of medical care and has not been tested for all potential applications. THE MEASURES AND SPECIFICATIONS ARE PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND.
Measure Scoring Cohort Measure Type Outcome Rationale The NHSN Glycemic Control, Hypoglycemia module provides a mechanism for facilities to report inpatient medication-related hypoglycemia events, and to provide analytic reports based on these data to inform glycemic control quality improvement efforts and patient safety events. The primary objective of the NHSN Glycemic Control, Hypoglycemia module is to facilitate measurement and benchmarking of medication-related hypoglycemia events within a facility. As additional data are collected by NHSN, an additional objective will be to facilitate inter-facility benchmarking and evaluate national-level trends of medication-related hypoglycemia over time. The IP dQM provides the initial population and FHIR line-level data necessary for calculating the module metrics.
Measure Group (Rate) Initial Population ID: initial-population-01
Description:Criteria: Initial PopulationAll inpatient encounters, as well as ED and OBS encounters that end within 1 hour of the start of the inpatient encounter, for patients of all ages where at least one antidiabetic drug (ADD) was ordered or administered during the encounter that is during the measurement period.
Supplemental Data Elements Supplemental Data Element ID: sde-chief-complaint Description: No description provided
Logic Definition: SDE Chief ComplaintSupplemental Data Element ID: sde-condition Description: No description provided
Logic Definition: SDE ConditionSupplemental Data Element ID: sde-condition-during-encounter Description: No description provided
Logic Definition: SDE Condition during EncounterSupplemental Data Element ID: sde-encounter-discharge-dispositions Description: No description provided
Logic Definition: SDE Encounter Discharge DispositionsSupplemental Data Element ID: sde-encounter-locations Description: No description provided
Logic Definition: SDE Encounter LocationsSupplemental Data Element ID: sde-medication-administration Description: No description provided
Logic Definition: SDE Medication AdministrationSupplemental Data Element ID: sde-medication-request Description: No description provided
Logic Definition: SDE Medication RequestSupplemental Data Element ID: sde-blood-glucose-observation Description: No description provided
Logic Definition: SDE Blood Glucose ObservationSupplemental Data Element ID: sde-payer Description: No description provided
Logic Definition: SDE PayerSupplemental Data Element ID: sde-specimen Description: No description provided
Logic Definition: SDE SpecimenSupplemental Data Element ID: sde-minimal-patient Description: No description provided
Logic Definition: SDE Minimal PatientSupplemental Data Element ID: sde-minimal-medication-requests Description: No description provided
Logic Definition: SDE Minimal Medication RequestsMeasure Logic Primary Library NHSN Glycemic Control Hypoglycemic Initial Population Contents Population Criteria
Logic Definitions
Terminology
Dependencies
Data Requirements
Population Criteria Measure Group (Rate) Initial Population Definitiondefine "Initial Population": "Inpatient Encounter" InpatientEncounters with "Antidiabetic Drugs Administered or Ordered" ADD such that Coalesce(start of Global."Normalize Interval"(ADD.effective), ADD.authoredOn) during "HospitalizationWithObservationOrEmergency"(InpatientEncounters) and Coalesce(start of Global."Normalize Interval"(ADD.effective), ADD.authoredOn) during "Measurement Period"
Logic Definitions Logic Definition Library Name: SupplementalDataElementsFHIR4 define "SDE Payer": [Coverage: type in "Payer"] Payer return { code: Payer.type, period: Payer.period }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "Inpatient Encounter": [Encounter: class in {"inpatient encounter", "inpatient acute", "inpatient non-acute", "short stay"}] Encounters where Encounters.status in {'in-progress', 'finished'} and Encounters.period overlaps "Measurement Period"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "Antidiabetic Drugs Administered or Ordered": ([MedicationAdministration] ADDMedAdmin where GetMedicationCode(ADDMedAdmin.medication) in "Antidiabetic Medications" and ADDMedAdmin.status ~ 'completed') union ( [MedicationRequest] MedicationRequests where GetMedicationCode(MedicationRequests.medication) in "Antidiabetic Medications" )
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "Initial Population": "Inpatient Encounter" InpatientEncounters with "Antidiabetic Drugs Administered or Ordered" ADD such that Coalesce(start of Global."Normalize Interval"(ADD.effective), ADD.authoredOn) during "HospitalizationWithObservationOrEmergency"(InpatientEncounters) and Coalesce(start of Global."Normalize Interval"(ADD.effective), ADD.authoredOn) during "Measurement Period"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Medication Request": [MedicationRequest] MedicationRequests with "Initial Population" InitialPopulation such that MedicationRequests.authoredOn during "HospitalizationWithObservationOrEmergency"(InitialPopulation) and MedicationRequests.authoredOn during "Measurement Period"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Encounter Locations": "Initial Population" InitialPopulation where exists ( InitialPopulation.location InitialPopulationLocation where (Global.GetLocation(InitialPopulationLocation.location).type in "Inpatient, Emergency, and Observation Locations" or Global.GetLocation(InitialPopulationLocation.location).physicalType in "Inpatient, Emergency, and Observation Locations") and InitialPopulationLocation.period during InitialPopulation.period )
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Minimal Medication Requests": [MedicationRequest] MedicationRequests return MedicationRequest{ id: MedicationRequests.id, medication: GetMedicationCode(MedicationRequests.medication), dosageInstruction: MedicationRequests.dosageInstruction }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Condition during Encounter": [Condition] ConditionEncounterDiagnosis with ConditionEncounterDiagnosis.category Category such that Category ~ "encounter-diagnosis" and exists("Initial Population")
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Medication Administration": [MedicationAdministration] MedicationAdministrations with "Initial Population" InitialPopulation such that start of Global."Normalize Interval"(MedicationAdministrations.effective) during "HospitalizationWithObservationOrEmergency"(InitialPopulation) and start of Global."Normalize Interval"(MedicationAdministrations.effective) during "Measurement Period"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Blood Glucose Observation": [Observation: "Blood Glucose Laboratory and Point of Care Tests"] Observations with "Initial Population" InitialPopulation such that start of Global."Normalize Interval"(Observations.effective) during InitialPopulation.period or Global."Normalize Interval"(GetSpecimen(Observations.specimen).collection.collected) during InitialPopulation.period with Observations.category category such that category ~ "laboratory"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Condition": [Condition] Conditions with "Initial Population" InitialPopulation such that Global."Normalize Interval"(Conditions.onset) overlaps InitialPopulation.period
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Payer": SDE."SDE Payer" Payer with "Initial Population" InitialPopulation such that start of Payer.period before end of InitialPopulation.period
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Encounter Discharge Dispositions": "Initial Population" DischargeDispositions where DischargeDispositions.hospitalization.dischargeDisposition in "Discharge Disposition"
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation //Change on CQF ruler happened on 8/12. Check to make sure CQF-Ruler version is dated at or after define "SDE Minimal Patient": Patient{ id: Patient.id, gender: Patient.gender, birthDate: Patient.birthDate }
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation define "SDE Specimen": [Specimen] Specimen with "Initial Population" InitialPopulation such that Global."Normalize Interval"(Specimen.collection.collected) during InitialPopulation.period
Logic Definition Library Name: NHSNGlycemicControlHypoglycemicInitialPopulation //Supplement Data Elements define "SDE Chief Complaint": "Initial Population" InitialPopulation with InitialPopulation.diagnosis InitialPopulationDiagnosis such that InitialPopulationDiagnosis.use ~ "Chief Complaint"
Terminology Code System Description: Code system ActCode
Resource: ActCode
Canonical URL: http://terminology.hl7.org/CodeSystem/v3-ActCodeCode System Description: Code system Condition Category
Resource: Condition Category Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/condition-categoryCode System Description: Code system Observation Category
Resource: Observation Category Codes
Canonical URL: http://terminology.hl7.org/CodeSystem/observation-categoryCode System Description: Code system Diagnosis Role
Resource: Diagnosis Role
Canonical URL: http://terminology.hl7.org/CodeSystem/diagnosis-roleValue Set Description: Value set Antidiabetic Medications
Resource: Antidiabetic Medications
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.58Value Set Description: Value set Inpatient, Emergency, and Observation Locations
Resource: Inpatient, Emergency, and Observation Locations
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1046.265Value Set Description: Value set Blood Glucose Laboratory and Point of Care Tests
Resource: Blood Glucose Laboratory and Point of Care Tests
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.38Value Set Description: Value set Payer
Resource: Payer Type
Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591Value Set Description: Value set Discharge Disposition
Resource: Discharge disposition
Canonical URL: http://terminology.hl7.org/ValueSet/encounter-discharge-dispositionDirect Reference Code Display: inpatient encounter
Code: IMP
System: http://terminology.hl7.org/CodeSystem/v3-ActCodeDirect Reference Code Display: inpatient acute
Code: ACUTE
System: http://terminology.hl7.org/CodeSystem/v3-ActCodeDirect Reference Code Display: inpatient non-acute
Code: NONAC
System: http://terminology.hl7.org/CodeSystem/v3-ActCodeDirect Reference Code Display: short stay
Code: SS
System: http://terminology.hl7.org/CodeSystem/v3-ActCodeDirect Reference Code Display: observation encounter
Code: OBSENC
System: http://terminology.hl7.org/CodeSystem/v3-ActCodeDirect Reference Code Display: emergency
Code: EMER
System: http://terminology.hl7.org/CodeSystem/v3-ActCodeDirect Reference Code Display: Encounter Diagnosis
Code: encounter-diagnosis
System: http://terminology.hl7.org/CodeSystem/condition-categoryDirect Reference Code Display: Laboratory
Code: laboratory
System: http://terminology.hl7.org/CodeSystem/observation-categoryDirect Reference Code Display: Chief complaint
Code: CC
System: http://terminology.hl7.org/CodeSystem/diagnosis-roleDependencies 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.1Dependency Description: Library Global
Resource: MAT Global Common Functions FHIRR4version: null6.1.000)
Canonical URL: http://fhir.org/guides/cqf/Library/MATGlobalCommonFunctionsFHIR4|6.1.000Dependency Description: Library SDE
Resource: SupplementalDataElementsFHIR4version: null2.0.000)
Canonical URL: http://fhir.org/guides/cqf/Library/SupplementalDataElementsFHIR4|2.0.000Data Requirements Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: class, period
Data Requirement Type: Encounter
Profile(s): Encounter
Must Support Elements: class, status, period
Code Filter(s):
Path: class
Code(s): ActCode IMP: inpatient encounter, ActCode ACUTE: inpatient acute, ActCode NONAC: inpatient non-acute, ActCode SS: short stay
Data Requirement Type: Medication
Profile(s): Medication
Must Support Elements: id
Data Requirement Type: MedicationAdministration
Profile(s): MedicationAdministration
Must Support Elements: medication, status, effective
Data Requirement Type: MedicationRequest
Profile(s): MedicationRequest
Must Support Elements: medication, authoredOn, id, dosageInstruction
Data Requirement Type: Location
Profile(s): Location
Must Support Elements: id
Data Requirement Type: Condition
Profile(s): Condition
Must Support Elements: category, onset
Data Requirement Type: Specimen
Profile(s): Specimen
Must Support Elements: id, collection, collection.collected
Data Requirement Type: Observation
Profile(s): Observation
Must Support Elements: code, effective, specimen, specimen.collection, specimen.collection.collected, category
Code Filter(s):
Path: code
ValueSet: Blood Glucose Laboratory and Point of Care Tests
Data Requirement Type: Coverage
Profile(s): Coverage
Must Support Elements: type, period
Code Filter(s):
Path: type
ValueSet: Payer Type
Data Requirement Type: Patient
Profile(s): Patient
Generated using version 0.4.9 of the sample-content-ig Liquid templates
Request:
PUT Measure/NHSNGlycemicControlHypoglycemicInitialPopulation