Title: FHIR Helpers Id: FHIRHelpers Version: 4.0.1 Url: http://fhir.org/guides/cqf/common/Library/FHIRHelpers Status: draft Experimental: true Type: system: http://terminology.hl7.org/CodeSystem/library-type code: logic-library display: Logic Library Related Artifacts: Dependencies http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1 Content: text/cql /*#xD; @author: Bryn Rhodes#xD; @description: This library defines functions to convert between FHIR#xD; data types and CQL system-defined types, as well as functions to support#xD; FHIRPath implementation. For more information, see the FHIRHelpers wiki page:#xD; https://github.com/cqframework/clinical_quality_language/wiki/FHIRHelpers#xD; @allowFluent: true#xD; */#xD; library FHIRHelpers version '4.0.1'#xD; #xD; using FHIR version '4.0.1'#xD; #xD; define function ToInterval(period FHIR.Period):#xD; if period is null then#xD; null#xD; else#xD; if period."start" is null then#xD; Interval(period."start".value, period."end".value]#xD; else#xD; Interval[period."start".value, period."end".value]#xD; #xD; define function ToCalendarUnit(unit System.String):#xD; case unit#xD; when 'ms' then 'millisecond'#xD; when 's' then 'second'#xD; when 'min' then 'minute'#xD; when 'h' then 'hour'#xD; when 'd' then 'day'#xD; when 'wk' then 'week'#xD; when 'mo' then 'month'#xD; when 'a' then 'year'#xD; else unit#xD; end#xD; #xD; define function ToQuantity(quantity FHIR.Quantity):#xD; case#xD; when quantity is null then null#xD; when quantity.value is null then null#xD; when quantity.comparator is not null then#xD; Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.')#xD; when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'#xD; or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then#xD; System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }#xD; else#xD; Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')#xD; end#xD; #xD; define function ToQuantityIgnoringComparator(quantity FHIR.Quantity):#xD; case#xD; when quantity is null then null#xD; when quantity.value is null then null#xD; when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'#xD; or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then#xD; System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }#xD; else#xD; Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')#xD; end#xD; #xD; define function ToInterval(quantity FHIR.Quantity):#xD; if quantity is null then null else#xD; case quantity.comparator.value#xD; when '<' then#xD; Interval[#xD; null,#xD; ToQuantityIgnoringComparator(quantity)#xD; )#xD; when '<=' then#xD; Interval[#xD; null,#xD; ToQuantityIgnoringComparator(quantity)#xD; ]#xD; when '>=' then#xD; Interval[#xD; ToQuantityIgnoringComparator(quantity),#xD; null#xD; ]#xD; when '>' then#xD; Interval(#xD; ToQuantityIgnoringComparator(quantity),#xD; null#xD; ]#xD; else#xD; Interval[ToQuantity(quantity), ToQuantity(quantity)]#xD; end#xD; #xD; define function ToRatio(ratio FHIR.Ratio):#xD; if ratio is null then#xD; null#xD; else#xD; System.Ratio { numerator: ToQuantity(ratio.numerator), denominator: ToQuantity(ratio.denominator) }#xD; #xD; define function ToInterval(range FHIR.Range):#xD; if range is null then#xD; null#xD; else#xD; Interval[ToQuantity(range.low), ToQuantity(range.high)]#xD; #xD; define function ToCode(coding FHIR.Coding):#xD; if coding is null then#xD; null#xD; else#xD; System.Code {#xD; code: coding.code.value,#xD; system: coding.system.value,#xD; version: coding.version.value,#xD; display: coding.display.value#xD; }#xD; #xD; define function ToConcept(concept FHIR.CodeableConcept):#xD; if concept is null then#xD; null#xD; else#xD; System.Concept {#xD; codes: concept.coding C return ToCode(C),#xD; display: concept.text.value#xD; }#xD; #xD; define function reference(reference String):#xD; if reference is null then#xD; null#xD; else#xD; Reference { reference: string { value: reference } }#xD; #xD; define function resolve(reference String) returns Resource: external#xD; define function resolve(reference Reference) returns Resource: external#xD; define function reference(resource Resource) returns Reference: external#xD; define function extension(element Element, url String) returns List<Element>: external#xD; define function extension(resource Resource, url String) returns List<Element>: external#xD; define function hasValue(element Element) returns Boolean: external#xD; define function getValue(element Element) returns Any: external#xD; define function ofType(identifier String) returns List<Any>: external#xD; define function is(identifier String) returns Boolean: external#xD; define function as(identifier String) returns Any: external#xD; define function elementDefinition(element Element) returns ElementDefinition: external#xD; define function slice(element Element, url String, name String) returns List<Element>: external#xD; define function checkModifiers(resource Resource) returns Resource: external#xD; define function checkModifiers(resource Resource, modifier String) returns Resource: external#xD; define function checkModifiers(element Element) returns Element: external#xD; define function checkModifiers(element Element, modifier String) returns Element: external#xD; define function conformsTo(resource Resource, structure String) returns Boolean: external#xD; define function memberOf(code code, valueSet String) returns Boolean: external#xD; define function memberOf(coding Coding, valueSet String) returns Boolean: external#xD; define function memberOf(concept CodeableConcept, valueSet String) returns Boolean: external#xD; define function subsumes(coding Coding, subsumedCoding Coding) returns Boolean: external#xD; define function subsumes(concept CodeableConcept, subsumedConcept CodeableConcept) returns Boolean: external#xD; define function subsumedBy(coding Coding, subsumingCoding Coding) returns Boolean: external#xD; define function subsumedBy(concept CodeableConcept, subsumingConcept CodeableConcept) returns Boolean: external#xD; define function htmlChecks(element Element) returns Boolean: external#xD; #xD; define function ToString(value AccountStatus): value.value#xD; define function ToString(value ActionCardinalityBehavior): value.value#xD; define function ToString(value ActionConditionKind): value.value#xD; define function ToString(value ActionGroupingBehavior): value.value#xD; define function ToString(value ActionParticipantType): value.value#xD; define function ToString(value ActionPrecheckBehavior): value.value#xD; define function ToString(value ActionRelationshipType): value.value#xD; define function ToString(value ActionRequiredBehavior): value.value#xD; define function ToString(value ActionSelectionBehavior): value.value#xD; define function ToString(value ActivityDefinitionKind): value.value#xD; define function ToString(value ActivityParticipantType): value.value#xD; define function ToString(value AddressType): value.value#xD; define function ToString(value AddressUse): value.value#xD; define function ToString(value AdministrativeGender): value.value#xD; define function ToString(value AdverseEventActuality): value.value#xD; define function ToString(value AggregationMode): value.value#xD; define function ToString(value AllergyIntoleranceCategory): value.value#xD; define function ToString(value AllergyIntoleranceCriticality): value.value#xD; define function ToString(value AllergyIntoleranceSeverity): value.value#xD; define function ToString(value AllergyIntoleranceType): value.value#xD; define function ToString(value AppointmentStatus): value.value#xD; define function ToString(value AssertionDirectionType): value.value#xD; define function ToString(value AssertionOperatorType): value.value#xD; define function ToString(value AssertionResponseTypes): value.value#xD; define function ToString(value AuditEventAction): value.value#xD; define function ToString(value AuditEventAgentNetworkType): value.value#xD; define function ToString(value AuditEventOutcome): value.value#xD; define function ToString(value BindingStrength): value.value#xD; define function ToString(value BiologicallyDerivedProductCategory): value.value#xD; define function ToString(value BiologicallyDerivedProductStatus): value.value#xD; define function ToString(value BiologicallyDerivedProductStorageScale): value.value#xD; define function ToString(value BundleType): value.value#xD; define function ToString(value CapabilityStatementKind): value.value#xD; define function ToString(value CarePlanActivityKind): value.value#xD; define function ToString(value CarePlanActivityStatus): value.value#xD; define function ToString(value CarePlanIntent): value.value#xD; define function ToString(value CarePlanStatus): value.value#xD; define function ToString(value CareTeamStatus): value.value#xD; define function ToString(value CatalogEntryRelationType): value.value#xD; define function ToString(value ChargeItemDefinitionPriceComponentType): value.value#xD; define function ToString(value ChargeItemStatus): value.value#xD; define function ToString(value ClaimResponseStatus): value.value#xD; define function ToString(value ClaimStatus): value.value#xD; define function ToString(value ClinicalImpressionStatus): value.value#xD; define function ToString(value CodeSearchSupport): value.value#xD; define function ToString(value CodeSystemContentMode): value.value#xD; define function ToString(value CodeSystemHierarchyMeaning): value.value#xD; define function ToString(value CommunicationPriority): value.value#xD; define function ToString(value CommunicationRequestStatus): value.value#xD; define function ToString(value CommunicationStatus): value.value#xD; define function ToString(value CompartmentCode): value.value#xD; define function ToString(value CompartmentType): value.value#xD; define function ToString(value CompositionAttestationMode): value.value#xD; define function ToString(value CompositionStatus): value.value#xD; define function ToString(value ConceptMapEquivalence): value.value#xD; define function ToString(value ConceptMapGroupUnmappedMode): value.value#xD; define function ToString(value ConditionalDeleteStatus): value.value#xD; define function ToString(value ConditionalReadStatus): value.value#xD; define function ToString(value ConsentDataMeaning): value.value#xD; define function ToString(value ConsentProvisionType): value.value#xD; define function ToString(value ConsentState): value.value#xD; define function ToString(value ConstraintSeverity): value.value#xD; define function ToString(value ContactPointSystem): value.value#xD; define function ToString(value ContactPointUse): value.value#xD; define function ToString(value ContractPublicationStatus): value.value#xD; define function ToString(value ContractStatus): value.value#xD; define function ToString(value ContributorType): value.value#xD; define function ToString(value CoverageStatus): value.value#xD; define function ToString(value CurrencyCode): value.value#xD; define function ToString(value DayOfWeek): value.value#xD; define function ToString(value DaysOfWeek): value.value#xD; define function ToString(value DetectedIssueSeverity): value.value#xD; define function ToString(value DetectedIssueStatus): value.value#xD; define function ToString(value DeviceMetricCalibrationState): value.value#xD; define function ToString(value DeviceMetricCalibrationType): value.value#xD; define function ToString(value DeviceMetricCategory): value.value#xD; define function ToString(value DeviceMetricColor): value.value#xD; define function ToString(value DeviceMetricOperationalStatus): value.value#xD; define function ToString(value DeviceNameType): value.value#xD; define function ToString(value DeviceRequestStatus): value.value#xD; define function ToString(value DeviceUseStatementStatus): value.value#xD; define function ToString(value DiagnosticReportStatus): value.value#xD; define function ToString(value DiscriminatorType): value.value#xD; define function ToString(value DocumentConfidentiality): value.value#xD; define function ToString(value DocumentMode): value.value#xD; define function ToString(value DocumentReferenceStatus): value.value#xD; define function ToString(value DocumentRelationshipType): value.value#xD; define function ToString(value EligibilityRequestPurpose): value.value#xD; define function ToString(value EligibilityRequestStatus): value.value#xD; define function ToString(value EligibilityResponsePurpose): value.value#xD; define function ToString(value EligibilityResponseStatus): value.value#xD; define function ToString(value EnableWhenBehavior): value.value#xD; define function ToString(value EncounterLocationStatus): value.value#xD; define function ToString(value EncounterStatus): value.value#xD; define function ToString(value EndpointStatus): value.value#xD; define function ToString(value EnrollmentRequestStatus): value.value#xD; define function ToString(value EnrollmentResponseStatus): value.value#xD; define function ToString(value EpisodeOfCareStatus): value.value#xD; define function ToString(value EventCapabilityMode): value.value#xD; define function ToString(value EventTiming): value.value#xD; define function ToString(value EvidenceVariableType): value.value#xD; define function ToString(value ExampleScenarioActorType): value.value#xD; define function ToString(value ExplanationOfBenefitStatus): value.value#xD; define function ToString(value ExposureState): value.value#xD; define function ToString(value ExtensionContextType): value.value#xD; define function ToString(value FHIRAllTypes): value.value#xD; define function ToString(value FHIRDefinedType): value.value#xD; define function ToString(value FHIRDeviceStatus): value.value#xD; define function ToString(value FHIRResourceType): value.value#xD; define function ToString(value FHIRSubstanceStatus): value.value#xD; define function ToString(value FHIRVersion): value.value#xD; define function ToString(value FamilyHistoryStatus): value.value#xD; define function ToString(value FilterOperator): value.value#xD; define function ToString(value FlagStatus): value.value#xD; define function ToString(value GoalLifecycleStatus): value.value#xD; define function ToString(value GraphCompartmentRule): value.value#xD; define function ToString(value GraphCompartmentUse): value.value#xD; define function ToString(value GroupMeasure): value.value#xD; define function ToString(value GroupType): value.value#xD; define function ToString(value GuidanceResponseStatus): value.value#xD; define function ToString(value GuidePageGeneration): value.value#xD; define function ToString(value GuideParameterCode): value.value#xD; define function ToString(value HTTPVerb): value.value#xD; define function ToString(value IdentifierUse): value.value#xD; define function ToString(value IdentityAssuranceLevel): value.value#xD; define function ToString(value ImagingStudyStatus): value.value#xD; define function ToString(value ImmunizationEvaluationStatus): value.value#xD; define function ToString(value ImmunizationStatus): value.value#xD; define function ToString(value InvoicePriceComponentType): value.value#xD; define function ToString(value InvoiceStatus): value.value#xD; define function ToString(value IssueSeverity): value.value#xD; define function ToString(value IssueType): value.value#xD; define function ToString(value LinkType): value.value#xD; define function ToString(value LinkageType): value.value#xD; define function ToString(value ListMode): value.value#xD; define function ToString(value ListStatus): value.value#xD; define function ToString(value LocationMode): value.value#xD; define function ToString(value LocationStatus): value.value#xD; define function ToString(value MeasureReportStatus): value.value#xD; define function ToString(value MeasureReportType): value.value#xD; define function ToString(value MediaStatus): value.value#xD; define function ToString(value MedicationAdministrationStatus): value.value#xD; define function ToString(value MedicationDispenseStatus): value.value#xD; define function ToString(value MedicationKnowledgeStatus): value.value#xD; define function ToString(value MedicationRequestIntent): value.value#xD; define function ToString(value MedicationRequestPriority): value.value#xD; define function ToString(value MedicationRequestStatus): value.value#xD; define function ToString(value MedicationStatementStatus): value.value#xD; define function ToString(value MedicationStatus): value.value#xD; define function ToString(value MessageSignificanceCategory): value.value#xD; define function ToString(value Messageheader_Response_Request): value.value#xD; define function ToString(value MimeType): value.value#xD; define function ToString(value NameUse): value.value#xD; define function ToString(value NamingSystemIdentifierType): value.value#xD; define function ToString(value NamingSystemType): value.value#xD; define function ToString(value NarrativeStatus): value.value#xD; define function ToString(value NoteType): value.value#xD; define function ToString(value NutritiionOrderIntent): value.value#xD; define function ToString(value NutritionOrderStatus): value.value#xD; define function ToString(value ObservationDataType): value.value#xD; define function ToString(value ObservationRangeCategory): value.value#xD; define function ToString(value ObservationStatus): value.value#xD; define function ToString(value OperationKind): value.value#xD; define function ToString(value OperationParameterUse): value.value#xD; define function ToString(value OrientationType): value.value#xD; define function ToString(value ParameterUse): value.value#xD; define function ToString(value ParticipantRequired): value.value#xD; define function ToString(value ParticipantStatus): value.value#xD; define function ToString(value ParticipationStatus): value.value#xD; define function ToString(value PaymentNoticeStatus): value.value#xD; define function ToString(value PaymentReconciliationStatus): value.value#xD; define function ToString(value ProcedureStatus): value.value#xD; define function ToString(value PropertyRepresentation): value.value#xD; define function ToString(value PropertyType): value.value#xD; define function ToString(value ProvenanceEntityRole): value.value#xD; define function ToString(value PublicationStatus): value.value#xD; define function ToString(value QualityType): value.value#xD; define function ToString(value QuantityComparator): value.value#xD; define function ToString(value QuestionnaireItemOperator): value.value#xD; define function ToString(value QuestionnaireItemType): value.value#xD; define function ToString(value QuestionnaireResponseStatus): value.value#xD; define function ToString(value ReferenceHandlingPolicy): value.value#xD; define function ToString(value ReferenceVersionRules): value.value#xD; define function ToString(value ReferredDocumentStatus): value.value#xD; define function ToString(value RelatedArtifactType): value.value#xD; define function ToString(value RemittanceOutcome): value.value#xD; define function ToString(value RepositoryType): value.value#xD; define function ToString(value RequestIntent): value.value#xD; define function ToString(value RequestPriority): value.value#xD; define function ToString(value RequestStatus): value.value#xD; define function ToString(value ResearchElementType): value.value#xD; define function ToString(value ResearchStudyStatus): value.value#xD; define function ToString(value ResearchSubjectStatus): value.value#xD; define function ToString(value ResourceType): value.value#xD; define function ToString(value ResourceVersionPolicy): value.value#xD; define function ToString(value ResponseType): value.value#xD; define function ToString(value RestfulCapabilityMode): value.value#xD; define function ToString(value RiskAssessmentStatus): value.value#xD; define function ToString(value SPDXLicense): value.value#xD; define function ToString(value SearchComparator): value.value#xD; define function ToString(value SearchEntryMode): value.value#xD; define function ToString(value SearchModifierCode): value.value#xD; define function ToString(value SearchParamType): value.value#xD; define function ToString(value SectionMode): value.value#xD; define function ToString(value SequenceType): value.value#xD; define function ToString(value ServiceRequestIntent): value.value#xD; define function ToString(value ServiceRequestPriority): value.value#xD; define function ToString(value ServiceRequestStatus): value.value#xD; define function ToString(value SlicingRules): value.value#xD; define function ToString(value SlotStatus): value.value#xD; define function ToString(value SortDirection): value.value#xD; define function ToString(value SpecimenContainedPreference): value.value#xD; define function ToString(value SpecimenStatus): value.value#xD; define function ToString(value Status): value.value#xD; define function ToString(value StrandType): value.value#xD; define function ToString(value StructureDefinitionKind): value.value#xD; define function ToString(value StructureMapContextType): value.value#xD; define function ToString(value StructureMapGroupTypeMode): value.value#xD; define function ToString(value StructureMapInputMode): value.value#xD; define function ToString(value StructureMapModelMode): value.value#xD; define function ToString(value StructureMapSourceListMode): value.value#xD; define function ToString(value StructureMapTargetListMode): value.value#xD; define function ToString(value StructureMapTransform): value.value#xD; define function ToString(value SubscriptionChannelType): value.value#xD; define function ToString(value SubscriptionStatus): value.value#xD; define function ToString(value SupplyDeliveryStatus): value.value#xD; define function ToString(value SupplyRequestStatus): value.value#xD; define function ToString(value SystemRestfulInteraction): value.value#xD; define function ToString(value TaskIntent): value.value#xD; define function ToString(value TaskPriority): value.value#xD; define function ToString(value TaskStatus): value.value#xD; define function ToString(value TestReportActionResult): value.value#xD; define function ToString(value TestReportParticipantType): value.value#xD; define function ToString(value TestReportResult): value.value#xD; define function ToString(value TestReportStatus): value.value#xD; define function ToString(value TestScriptRequestMethodCode): value.value#xD; define function ToString(value TriggerType): value.value#xD; define function ToString(value TypeDerivationRule): value.value#xD; define function ToString(value TypeRestfulInteraction): value.value#xD; define function ToString(value UDIEntryType): value.value#xD; define function ToString(value UnitsOfTime): value.value#xD; define function ToString(value Use): value.value#xD; define function ToString(value VariableType): value.value#xD; define function ToString(value VisionBase): value.value#xD; define function ToString(value VisionEyes): value.value#xD; define function ToString(value VisionStatus): value.value#xD; define function ToString(value XPathUsageType): value.value#xD; define function ToString(value base64Binary): value.value#xD; define function ToBoolean(value boolean): value.value#xD; define function ToDate(value date): value.value#xD; define function ToDateTime(value dateTime): value.value#xD; define function ToDecimal(value decimal): value.value#xD; define function ToDateTime(value instant): value.value#xD; define function ToInteger(value integer): value.value#xD; define function ToString(value string): value.value#xD; define function ToTime(value time): value.value#xD; define function ToString(value uri): value.value#xD; define function ToString(value xhtml): value.value#xD;
Title: FHIRCommon Id: FHIRCommon Version: 4.0.1 Url: FHIRCommon Status: draft Experimental: true Type: system: http://terminology.hl7.org/CodeSystem/library-type code: logic-library display: Logic Library Related Artifacts: Dependencies http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1 FHIR Helpersversion: null4.0.1) Logical Observation Identifiers, Names and Codes (LOINC) SNOMED CT (all versions) RoleCode Diagnosis Role RequestIntent MedicationRequest Category Codes Condition Clinical Status Codes ConditionVerificationStatus AllergyIntolerance Clinical Status Codes AllergyIntolerance Verification Status CQF Active Condition CQF Inactive Condition Parameters: Name Type Min Max In/Out Patient Patient 0 1 Out Data Requirements: Type Profile MS Code Filter Patient http://hl7.org/fhir/StructureDefinition/Patient Content: text/cql /*#xD; @author: Bryn Rhodes#xD; @description: Common terminologies and functions used in FHIR-based CQL artifacts#xD; */#xD; library FHIRCommon version '4.0.1'#xD; #xD; using FHIR version '4.0.1'#xD; #xD; include FHIRHelpers version '4.0.1'#xD; #xD; codesystem "LOINC": 'http://loinc.org'#xD; codesystem "SNOMEDCT": 'http://snomed.info/sct'#xD; codesystem "RoleCode": 'http://terminology.hl7.org/CodeSystem/v3-RoleCode'#xD; codesystem "Diagnosis Role": 'http://terminology.hl7.org/CodeSystem/diagnosis-role'#xD; codesystem "RequestIntent": 'http://terminology.hl7.org/CodeSystem/request-intent'#xD; codesystem "MedicationRequestCategory": 'http://terminology.hl7.org/CodeSystem/medicationrequest-category'#xD; codesystem "ConditionClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-clinical'#xD; codesystem "ConditionVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status'#xD; codesystem "AllergyIntoleranceClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical'#xD; codesystem "AllergyIntoleranceVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-verification'#xD; #xD; valueset "Active Condition": 'http://fhir.org/guides/cqf/common/ValueSet/active-condition'#xD; valueset "Inactive Condition": 'http://fhir.org/guides/cqf/common/ValueSet/inactive-condition'#xD; #xD; code "Birthdate": '21112-8' from "LOINC" display 'Birth date'#xD; code "Dead": '419099009' from "SNOMEDCT" display 'Dead'#xD; code "ER": 'ER' from "RoleCode" display 'Emergency room'#xD; code "ICU": 'ICU' from "RoleCode" display 'Intensive care unit'#xD; code "Billing": 'billing' from "Diagnosis Role" display 'Billing'#xD; #xD; // Condition Clinical Status Codes - Consider value sets for these#xD; code "active": 'active' from "ConditionClinicalStatusCodes"#xD; code "recurrence": 'recurrence' from "ConditionClinicalStatusCodes"#xD; code "relapse": 'relapse' from "ConditionClinicalStatusCodes"#xD; code "inactive": 'inactive' from "ConditionClinicalStatusCodes"#xD; code "remission": 'remission' from "ConditionClinicalStatusCodes"#xD; code "resolved": 'resolved' from "ConditionClinicalStatusCodes"#xD; #xD; // Condition Verification Status Codes - Consider value sets for these#xD; code "unconfirmed": 'unconfirmed' from ConditionVerificationStatusCodes#xD; code "provisional": 'provisional' from ConditionVerificationStatusCodes#xD; code "differential": 'differential' from ConditionVerificationStatusCodes#xD; code "confirmed": 'confirmed' from ConditionVerificationStatusCodes#xD; code "refuted": 'refuted' from ConditionVerificationStatusCodes#xD; code "entered-in-error": 'entered-in-error' from ConditionVerificationStatusCodes#xD; #xD; code "allergy-active": 'active' from "AllergyIntoleranceClinicalStatusCodes"#xD; code "allergy-inactive": 'inactive' from "AllergyIntoleranceClinicalStatusCodes"#xD; code "allergy-resolved": 'resolved' from "AllergyIntoleranceClinicalStatusCodes"#xD; #xD; // Allergy/Intolerance Verification Status Codes - Consider value sets for these#xD; code "allergy-unconfirmed": 'unconfirmed' from AllergyIntoleranceVerificationStatusCodes#xD; code "allergy-confirmed": 'confirmed' from AllergyIntoleranceVerificationStatusCodes#xD; code "allergy-refuted": 'refuted' from AllergyIntoleranceVerificationStatusCodes#xD; #xD; // MedicationRequest Category Codes#xD; code "Community": 'community' from "MedicationRequestCategory" display 'Community'#xD; code "Discharge": 'discharge' from "MedicationRequestCategory" display 'Discharge'#xD; #xD; // Diagnosis Role Codes#xD; code "AD": 'AD' from "Diagnosis Role" display 'Admission diagnosis'#xD; code "DD": 'DD' from "Diagnosis Role" display 'Discharge diagnosis'#xD; code "CC": 'CC' from "Diagnosis Role" display 'Chief complaint'#xD; code "CM": 'CM' from "Diagnosis Role" display 'Comorbidity diagnosis'#xD; code "pre-op": 'pre-op' from "Diagnosis Role" display 'pre-op diagnosis'#xD; code "post-op": 'post-op' from "Diagnosis Role" display 'post-op diagnosis'#xD; code "billing": 'billing' from "Diagnosis Role" display 'billing diagnosis'#xD; #xD; context Patient#xD; #xD; /*#xD; @description: Normalizes a value that is a choice of timing-valued types to an equivalent interval#xD; @comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range types#xD; to an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible#xD; representations for timing-valued elements in FHIR, allowing this function to be used across any resource. NOTE: Due to the#xD; complexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used#xD; with a Timing or String.#xD; */#xD; define function ToInterval(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>):#xD; case#xD; when choice is FHIR.dateTime then#xD; Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]#xD; when choice is FHIR.Period then#xD; FHIRHelpers.ToInterval(choice as FHIR.Period)#xD; when choice is FHIR.instant then#xD; Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]#xD; when choice is FHIR.Age then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)#xD; when choice is FHIR.Range then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)#xD; when choice is FHIR.Timing then#xD; Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute a single interval from a Timing type')#xD; when choice is FHIR.string then#xD; Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value')#xD; else#xD; null as Interval<DateTime>#xD; end#xD; #xD; /*#xD; @description: Returns an interval representing the normalized Abatement of a given Condition resource.#xD; @comment: NOTE: Due to the complexity of determining an interval from a String, this function will throw#xD; a run-time exception if used with a Condition instance that has a String as the abatement value.#xD; */#xD; define function ToAbatementInterval(condition Condition):#xD; if condition.abatement is FHIR.dateTime then#xD; Interval[FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime), FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime)]#xD; else if condition.abatement is FHIR.Period then#xD; FHIRHelpers.ToInterval(condition.abatement as FHIR.Period)#xD; else if condition.abatement is FHIR.string then#xD; Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value')#xD; else if condition.abatement is FHIR.Age then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age) + 1 year)#xD; else if condition.abatement is FHIR.Range then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).low),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).high) + 1 year)#xD; else if condition.abatement is FHIR.boolean then#xD; Interval[end of ToInterval(condition.onset), condition.recordedDate)#xD; else null#xD; #xD; /*#xD; @description: Returns an interval representing the normalized prevalence period of a given Condition resource.#xD; @comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from#xD; onset to abatement as specified in the given Condition.#xD; */#xD; define function ToPrevalenceInterval(condition Condition):#xD; if condition.clinicalStatus ~ "active"#xD; or condition.clinicalStatus ~ "recurrence"#xD; or condition.clinicalStatus ~ "relapse" then#xD; Interval[start of ToInterval(condition.onset), end of ToAbatementInterval(condition)]#xD; else#xD; Interval[start of ToInterval(condition.onset), end of ToAbatementInterval(condition))#xD; #xD; /*#xD; @description: Returns any extensions defined on the given resource with the specified url.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the#xD; CQL model info.#xD; */#xD; define function Extensions(domainResource DomainResource, url String):#xD; domainResource.extension E#xD; where E.url = url#xD; return E#xD; #xD; /*#xD; @description: Returns the single extension (if present) on the given resource with the specified url.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.#xD; */#xD; define function Extension(domainResource DomainResource, url String):#xD; singleton from "Extensions"(domainResource, url)#xD; #xD; /*#xD; @description: Returns any extensions defined on the given element with the specified url.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the CQL model info.#xD; */#xD; define function Extensions(element Element, url String):#xD; element.extension E#xD; where E.url = url#xD; return E#xD; #xD; /*#xD; @description: Returns the single extension (if present) on the given element with the specified url.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.#xD; */#xD; define function Extension(element Element, url String):#xD; singleton from Extensions(element, url)#xD; #xD; /*#xD; @description: Returns any modifier extensions defined on the given resource with the specified url.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the#xD; CQL model info.#xD; */#xD; define function ModifierExtensions(domainResource DomainResource, url String):#xD; domainResource.modifierExtension E#xD; where E.url = url#xD; return E#xD; #xD; /*#xD; @description: Returns the single modifier extension (if present) on the given resource with the specified url.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.#xD; */#xD; define function ModifierExtension(domainResource DomainResource, url String):#xD; singleton from ModifierExtensions(domainResource, url)#xD; #xD; /*#xD; @description: Returns any modifier extensions defined on the given element with the specified url.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the CQL model info.#xD; */#xD; define function ModifierExtensions(element BackboneElement, url String):#xD; element.modifierExtension E#xD; where E.url = url#xD; return E#xD; #xD; /*#xD; @description: Returns the single modifier extension (if present) on the given element with the specified url.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.#xD; */#xD; define function ModifierExtension(element BackboneElement, url String):#xD; singleton from ModifierExtensions(element, url)#xD; #xD; /*#xD; @description: Returns any base-FHIR extensions defined on the given resource with the specified id.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the CQL model info.#xD; */#xD; define function BaseExtensions(domainResource DomainResource, id String):#xD; domainResource.extension E#xD; where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id)#xD; return E#xD; #xD; /*#xD; @description: Returns the single base-FHIR extension (if present) on the given resource with the specified id.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.#xD; */#xD; define function BaseExtension(domainResource DomainResource, id String):#xD; singleton from BaseExtensions(domainResource, id)#xD; #xD; /*#xD; @description: Returns any base-FHIR extensions defined on the given element with the specified id.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the CQL model info.#xD; */#xD; define function BaseExtensions(element Element, id String):#xD; element.extension E#xD; where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id)#xD; return E#xD; #xD; /*#xD; @description: Returns the single base-FHIR extension (if present) on the given element with the specified id.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.#xD; */#xD; define function BaseExtension(element Element, id String):#xD; singleton from BaseExtensions(element, id)#xD; #xD; /*#xD; @description: Returns any base-FHIR modifier extensions defined on the given resource with the specified id.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the CQL model info.#xD; */#xD; define function BaseModifierExtensions(domainResource DomainResource, id String):#xD; domainResource.modifierExtension E#xD; where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id)#xD; return E#xD; #xD; /*#xD; @description: Returns the single base-FHIR modifier extension (if present) on the given resource with the specified id.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.#xD; */#xD; define function BaseModifierExtension(domainResource DomainResource, id String):#xD; singleton from BaseModifierExtensions(domainResource, id)#xD; #xD; /*#xD; @description: Returns any base-FHIR modifier extensions defined on the given element with the specified id.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the CQL model info.#xD; */#xD; define function BaseModifierExtensions(element BackboneElement, id String):#xD; element.modifierExtension E#xD; where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id)#xD; return E#xD; #xD; /*#xD; @description: Returns the single base-FHIR extension (if present) on the given element with the specified id.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.#xD; */#xD; define function BaseModifierExtension(element BackboneElement, id String):#xD; singleton from BaseModifierExtensions(element, id)#xD;
Code system ConditionClinicalStatusCodes
Code system ConditionVerificationStatusCodes
Code system AllergyIntoleranceClinicalStatusCodes
Code system AllergyIntoleranceVerificationStatusCodes
Title: MAT Global Common Functions FHIRR4 Id: MATGlobalCommonFunctionsFHIR4 Version: 6.1.000 Url: MAT Global Common Functions FHIRR4 Status: draft Experimental: true Type: system: http://terminology.hl7.org/CodeSystem/library-type code: logic-library display: Logic Library Related Artifacts: Dependencies http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1 FHIR Helpersversion: null4.0.1) Condition Clinical Status Codes AllergyIntolerance Clinical Status Codes AllergyIntolerance Verification Status Diagnosis Role Logical Observation Identifiers, Names and Codes (LOINC) MedicationRequest Category Codes ConditionVerificationStatus SNOMED CT (all versions) RoleCode Emergency Department Visit Encounter Inpatient Observation Services Parameters: Name Type Min Max In/Out Measurement Period Period 0 1 In Patient Patient 0 1 Out Inpatient Encounter Encounter 0 * Out Data Requirements: Type Profile MS Code Filter Patient http://hl7.org/fhir/StructureDefinition/Patient Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307 Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143 Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292 Condition http://hl7.org/fhir/StructureDefinition/Condition ; Location http://hl7.org/fhir/StructureDefinition/Location ; Provenance http://hl7.org/fhir/StructureDefinition/Provenance ; code filter: path: target Content: text/cql library MATGlobalCommonFunctionsFHIR4 version '6.1.000'#xD; #xD; /*@update: BTR 2020-03-31 ->#xD; Incremented version to 5.0.000#xD; Updated FHIR version to 4.0.1#xD; Changed timezone keyword to timezoneoffset for use with CQL 1.4#xD; Removed Normalize Onset in favor of more general Normalize Interval#xD; Updated CodeSystems for ConditionVerificationStatusCodes and RoleCodes#xD; #xD; @update: BTR 2021-05-13 ->#xD; Added ActiveCondition Codes and Inactive Condition Codes value sets#xD; Added function documentation throughout#xD; Fixed EDVisit not using Last#xD; Updated prevalence period to use an inclusive boundary if the condition is active#xD; Added HasStart, HasEnd, Earliest, and Latest functions#xD; Removed ToDate and Age calculation functions#xD; #xD; @update: BTR 2021-06-25 ->#xD; Added GetBaseExtension overloads for Element*/#xD; #xD; using FHIR version '4.0.1'#xD; #xD; include FHIRHelpers version '4.0.1' called FHIRHelpers#xD; #xD; codesystem "ConditionClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-clinical' #xD; codesystem "AllergyIntoleranceClinicalStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical' #xD; codesystem "AllergyIntoleranceVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-verification' #xD; codesystem "Diagnosis Role": 'http://terminology.hl7.org/CodeSystem/diagnosis-role' #xD; codesystem "LOINC": 'http://loinc.org' #xD; codesystem "MedicationRequestCategory": 'http://terminology.hl7.org/CodeSystem/medicationrequest-category' #xD; codesystem "ConditionVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status' #xD; codesystem "SNOMEDCT": 'http://snomed.info/sct' #xD; codesystem "RoleCode": 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' #xD; #xD; valueset "Emergency Department Visit": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292' #xD; valueset "Encounter Inpatient": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307' #xD; valueset "Observation Services": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143' #xD; #xD; code "active": 'active' from "ConditionClinicalStatusCodes" display 'active'#xD; code "allergy-active": 'active' from "AllergyIntoleranceClinicalStatusCodes" display 'allergy-active'#xD; code "allergy-confirmed": 'confirmed' from "AllergyIntoleranceVerificationStatusCodes" display 'allergy-confirmed'#xD; code "allergy-inactive": 'inactive' from "AllergyIntoleranceClinicalStatusCodes" display 'allergy-inactive'#xD; code "allergy-refuted": 'refuted' from "AllergyIntoleranceVerificationStatusCodes" display 'allergy-refuted'#xD; code "allergy-resolved": 'resolved' from "AllergyIntoleranceClinicalStatusCodes" display 'allergy-resolved'#xD; code "allergy-unconfirmed": 'unconfirmed' from "AllergyIntoleranceVerificationStatusCodes" display 'allergy-unconfirmed'#xD; code "Billing": 'billing' from "Diagnosis Role" display 'Billing'#xD; code "Birthdate": '21112-8' from "LOINC" display 'Birth date'#xD; code "Community": 'community' from "MedicationRequestCategory" display 'Community'#xD; code "confirmed": 'confirmed' from "ConditionVerificationStatusCodes" display 'confirmed'#xD; code "Dead": '419099009' from "SNOMEDCT" display 'Dead'#xD; code "differential": 'differential' from "ConditionVerificationStatusCodes" display 'differential'#xD; code "Discharge": 'discharge' from "MedicationRequestCategory" display 'Discharge'#xD; code "entered-in-error": 'entered-in-error' from "ConditionVerificationStatusCodes" display 'entered-in-error'#xD; code "ER": 'ER' from "RoleCode" display 'Emergency room'#xD; code "ICU": 'ICU' from "RoleCode" display 'Intensive care unit'#xD; code "inactive": 'inactive' from "ConditionClinicalStatusCodes" display 'inactive'#xD; code "provisional": 'provisional' from "ConditionVerificationStatusCodes" display 'provisional'#xD; code "recurrence": 'recurrence' from "ConditionClinicalStatusCodes" display 'recurrence'#xD; code "refuted": 'refuted' from "ConditionVerificationStatusCodes" display 'refuted'#xD; code "relapse": 'relapse' from "ConditionClinicalStatusCodes" display 'relapse'#xD; code "remission": 'remission' from "ConditionClinicalStatusCodes" display 'remission'#xD; code "resolved": 'resolved' from "ConditionClinicalStatusCodes" display 'resolved'#xD; code "unconfirmed": 'unconfirmed' from "ConditionVerificationStatusCodes" display 'unconfirmed'#xD; #xD; parameter "Measurement Period" Interval<DateTime>#xD; default Interval[@2019-01-01T00:00:00.0, @2020-01-01T00:00:00.0)#xD; #xD; context Patient#xD; #xD; define "Inpatient Encounter":#xD; [Encounter: "Encounter Inpatient"] EncounterInpatient#xD; where EncounterInpatient.status = 'finished'#xD; and "LengthInDays"(EncounterInpatient.period) <= 120#xD; and EncounterInpatient.period ends during "Measurement Period"#xD; #xD; /*Calculates the difference in calendar days between the start and end of the given interval.*/#xD; define function "LengthInDays"(Value Interval<DateTime> ):#xD; difference in days between start of Value and end of Value#xD; #xD; /*Returns the most recent emergency department visit, if any, that occurs 1 hour or less prior to the given encounter.*/#xD; define function "ED Visit"(TheEncounter FHIR.Encounter ):#xD; Last(#xD; [Encounter: "Emergency Department Visit"] EDVisit#xD; where EDVisit.status = 'finished'#xD; and EDVisit.period ends 1 hour or less on or before start of FHIRHelpers.ToInterval(TheEncounter.period)#xD; sort by end of period#xD; )#xD; #xD; /*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.*/#xD; define function "Hospitalization"(TheEncounter FHIR.Encounter ):#xD; ( "ED Visit"(TheEncounter) ) X#xD; return#xD; if X is null then TheEncounter.period#xD; else Interval[start of FHIRHelpers.ToInterval(X.period), end of FHIRHelpers.ToInterval(TheEncounter.period)]#xD; #xD; /*Returns list of all locations within an encounter, including locations for immediately prior ED visit.*/#xD; define function "Hospitalization Locations"(TheEncounter FHIR.Encounter ):#xD; ( "ED Visit"(TheEncounter) ) EDEncounter#xD; return#xD; if EDEncounter is null then TheEncounter.location#xD; else flatten { EDEncounter.location, TheEncounter.location }#xD; #xD; /*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*/#xD; define function "Hospitalization Length of Stay"(TheEncounter FHIR.Encounter ):#xD; LengthInDays("Hospitalization"(TheEncounter))#xD; #xD; /*Returns admission time for an encounter or for immediately prior emergency department visit.*/#xD; define function "Hospital Admission Time"(TheEncounter FHIR.Encounter ):#xD; start of "Hospitalization"(TheEncounter)#xD; #xD; /*Hospital Discharge Time returns the discharge time for an encounter*/#xD; define function "Hospital Discharge Time"(TheEncounter FHIR.Encounter ):#xD; end of FHIRHelpers.ToInterval(TheEncounter.period)#xD; #xD; /*Returns earliest arrival time for an encounter including any prior ED visit.*/#xD; define function "Hospital Arrival Time"(TheEncounter FHIR.Encounter ):#xD; start of FHIRHelpers.ToInterval(First(#xD; ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation#xD; sort by start of FHIRHelpers.ToInterval(period)#xD; ).period)#xD; #xD; // TODO - fix these (must fetch Location resources and compare id to reference)#xD; /*Returns the latest departure time for encounter including any prior ED visit. */#xD; /*#xD; define function "Hospital Departure Time"(TheEncounter FHIR.Encounter):#xD; end of FHIRHelpers.ToInterval(Last(#xD; ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation#xD; sort by start of FHIRHelpers.ToInterval(period)#xD; ).period)#xD; #xD; define function "Emergency Department Arrival Time"(TheEncounter FHIR.Encounter):#xD; start of FHIRHelpers.ToInterval((#xD; singleton from (#xD; ( "Hospitalization Locations"(TheEncounter) ) HospitalLocation#xD; where HospitalLocation.type ~ "ER"#xD; )#xD; ).period)#xD; #xD; define function "First Inpatient Intensive Care Unit"(TheEncounter FHIR.Encounter):#xD; First(#xD; ( TheEncounter.location ) HospitalLocation#xD; where HospitalLocation.type ~ "ICU"#xD; and HospitalLocation.period during TheEncounter.period#xD; sort by start of FHIRHelpers.ToInterval(period)#xD; )#xD; */#xD; #xD; /*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.*/#xD; /* TODO:#xD; define function "HospitalizationWithObservationAndOutpatientSurgeryService"(Encounter "Encounter, Performed" ):#xD; Encounter Visit#xD; let ObsVisit: Last(["Encounter, Performed": "Observation Services"] LastObs#xD; where LastObs.relevantPeriod ends 1 hour or less on or before start of Visit.relevantPeriod#xD; sort by#xD; end of relevantPeriod#xD; ),#xD; VisitStart: Coalesce(start of ObsVisit.relevantPeriod, start of Visit.relevantPeriod),#xD; EDVisit: Last(["Encounter, Performed": "Emergency Department Visit"] LastED#xD; where LastED.relevantPeriod ends 1 hour or less on or before VisitStart#xD; sort by#xD; end of relevantPeriod#xD; ),#xD; VisitStartWithED: Coalesce(start of EDVisit.relevantPeriod, VisitStart),#xD; OutpatientSurgeryVisit: Last(["Encounter, Performed": "Outpatient Surgery Service"] LastSurgeryOP#xD; where LastSurgeryOP.relevantPeriod ends 1 hour or less on or before VisitStartWithED#xD; sort by#xD; end of relevantPeriod#xD; )#xD; return Interval[Coalesce(start of OutpatientSurgeryVisit.relevantPeriod, VisitStartWithED),#xD; end of Visit.relevantPeriod]#xD; */#xD; #xD; /*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*/#xD; define function "HospitalizationWithObservation"(TheEncounter FHIR.Encounter ):#xD; TheEncounter Visit#xD; let ObsVisit: Last([Encounter: "Observation Services"] LastObs#xD; where LastObs.period ends 1 hour or less on or before start of Visit.period#xD; sort by end of period#xD; ),#xD; VisitStart: Coalesce(start of ObsVisit.period, start of Visit.period),#xD; EDVisit: Last([Encounter: "Emergency Department Visit"] LastED#xD; where LastED.period ends 1 hour or less on or before VisitStart#xD; sort by end of period#xD; )#xD; return Interval[Coalesce(start of EDVisit.period, VisitStart), end of Visit.period]#xD; #xD; /**#xD; * Normalizes the input argument to an interval representation.#xD; * The input can be provided as a dateTime, Period, Timing, instant, string, Age, or Range.#xD; * The intent of this function is to provide a clear and concise mechanism to treat single#xD; * elements that have multiple possible representations as intervals so that logic doesn't have to account#xD; * for the variability. More complex calculations (such as medication request period or dispense period#xD; * calculation) need specific guidance and consideration. That guidance may make use of this function, but#xD; * the focus of this function is on single element calculations where the semantics are unambiguous.#xD; * If the input is a dateTime, the result a DateTime Interval beginning and ending on that dateTime.#xD; * If the input is a Period, the result is a DateTime Interval.#xD; * If the input is a Timing, an error is raised indicating a single interval cannot be computed from a Timing.#xD; * If the input is an instant, the result is a DateTime Interval beginning and ending on that instant.#xD; * If the input is a string, an error is raised indicating a single interval cannot be computed from a string.#xD; * If the input is an Age, the result is a DateTime Interval beginning when the patient was the given Age,#xD; and ending immediately prior to when the patient was the given Age plus one year.#xD; * If the input is a Range, the result is a DateTime Interval beginning when the patient was the Age given#xD; by the low end of the Range, and ending immediately prior to when the patient was the Age given by the#xD; high end of the Range plus one year.*/#xD; define function "Normalize Interval"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range> ):#xD; case#xD; when choice is FHIR.dateTime then#xD; Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]#xD; when choice is FHIR.Period then#xD; FHIRHelpers.ToInterval(choice as FHIR.Period)#xD; when choice is FHIR.instant then#xD; Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]#xD; when choice is FHIR.Age then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)#xD; when choice is FHIR.Range then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)#xD; when choice is FHIR.Timing then#xD; Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute a single interval from a Timing type')#xD; when choice is FHIR.string then#xD; Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value')#xD; else#xD; null as Interval<DateTime>#xD; end#xD; #xD; /**#xD; * Returns an interval representing the abatement of the given condition, if an#xD; abatement element is present, null otherwise.#xD; This function uses the semantics of Normalize Interval to interpret the abatement#xD; element.*/#xD; define function "Normalize Abatement"(condition Condition ):#xD; if condition.abatement is FHIR.dateTime then#xD; Interval[FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime), FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime)]#xD; else if condition.abatement is FHIR.Period then#xD; FHIRHelpers.ToInterval(condition.abatement as FHIR.Period)#xD; else if condition.abatement is FHIR.string then#xD; Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value')#xD; else if condition.abatement is FHIR.Age then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age) + 1 year)#xD; else if condition.abatement is FHIR.Range then#xD; Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).low),#xD; FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).high) + 1 year)#xD; else if condition.abatement is FHIR.boolean then#xD; Interval[end of "Normalize Interval"(condition.onset), condition.recordedDate)#xD; else null#xD; #xD; /*Returns an interval representing the period during which the condition was prevalent (i.e. onset to abatement)#xD; If the condition is "active", then abatement being unknown#xD; would indicate the condition is ongoing, and the ending boundary of the prevalence#xD; period is inclusive, otherwise, the abatement is considered unknown and the ending boundary#xD; of the prevalence period is exclusive.#xD; Note that when using this function it should be noted that many clinical systems#xD; do not actually capture abatement, so care should be taken when using this function#xD; to meet clinical intent.*/#xD; define function "Prevalence Period"(condition Condition ):#xD; if condition.clinicalStatus ~ "active"#xD; or condition.clinicalStatus ~ "recurrence"#xD; or condition.clinicalStatus ~ "relapse" then#xD; Interval[start of "Normalize Interval"(condition.onset), end of "Normalize Abatement"(condition)]#xD; else#xD; Interval[start of "Normalize Interval"(condition.onset), end of "Normalize Abatement"(condition))#xD; #xD; /*Returns the tail of the given uri (i.e. everything after the last slash in the URI).*/#xD; define function "GetId"(uri String ):#xD; Last(Split(uri, '/'))#xD; #xD; /*Returns the Condition resources referenced by the diagnosis element of the Encounter*/#xD; define function "EncounterDiagnosis"(Encounter Encounter ):#xD; Encounter.diagnosis D#xD; return singleton from ([Condition] C where C.id = "GetId"(D.condition.reference))#xD; #xD; // Returns the condition that is specified as the principal diagnosis for the encounter#xD; // TODO: BTR 2019-07-30: Shouldn't need the FHIRHelpers reference here, investigate#xD; #xD; define function "PrincipalDiagnosis"(Encounter Encounter ):#xD; (singleton from (Encounter.diagnosis D where FHIRHelpers.ToInteger(D.rank) = 1)) PD#xD; return singleton from ([Condition] C where C.id = "GetId"(PD.condition.reference))#xD; // Returns the location for the given location reference#xD; #xD; /*Returns the Location resource specified by the given reference*/#xD; define function "GetLocation"(reference Reference ):#xD; singleton from (#xD; [Location] L where L.id = GetId(reference.reference)#xD; )#xD; #xD; /*NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the#xD; CQL model info.*/#xD; define function "GetExtensions"(domainResource DomainResource, url String ):#xD; domainResource.extension E#xD; where E.url = ('http://hl7.org/fhir/us/qicore/StructureDefinition/' + url)#xD; return E#xD; #xD; define function "GetExtension"(domainResource DomainResource, url String ):#xD; singleton from "GetExtensions"(domainResource, url)#xD; #xD; /*NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the#xD; CQL model info.*/#xD; define function "GetExtensions"(element Element, url String ):#xD; element.extension E#xD; where E.url = (url)#xD; return E#xD; #xD; define function "GetExtension"(element Element, url String ):#xD; singleton from "GetExtensions"(element, url)#xD; #xD; /*NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the#xD; CQL model info.*/#xD; define function "GetBaseExtensions"(domainResource DomainResource, url String ):#xD; domainResource.extension E#xD; where E.url = ('http://hl7.org/fhir/StructureDefinition/' + url)#xD; return E#xD; #xD; define function "GetBaseExtension"(domainResource DomainResource, url String ):#xD; singleton from "GetBaseExtensions"(domainResource, url)#xD; #xD; /*@description: Returns any base-FHIR extensions defined on the given element with the specified id.#xD; @comment: NOTE: Extensions are not the preferred approach, but are used as a way to access#xD; content that is defined by extensions but not yet surfaced in the CQL model info.*/#xD; define function "BaseExtensions"(element Element, id String ):#xD; element.extension E#xD; where E.url = ('http://hl7.org/fhir/StructureDefinition/' + id)#xD; return E#xD; #xD; /*@description: Returns the single base-FHIR extension (if present) on the given element with the specified id.#xD; @comment: This function uses singleton from to ensure that a run-time exception is thrown if there#xD; is more than one extension on the given resource with the specified url.*/#xD; define function "BaseExtension"(element Element, id String ):#xD; singleton from BaseExtensions(element, id)#xD; #xD; /*NOTE: Provenance is not the preferred approach, this is provided only as an illustration#xD; for what using Provenance could look like, and is not a tested pattern*/#xD; define function "GetProvenance"(resource Resource ):#xD; singleton from ([Provenance: target in resource.id])#xD; #xD; define function "GetMedicationCode"(request MedicationRequest ):#xD; if request.medication is CodeableConcept then#xD; request.medication as CodeableConcept#xD; else#xD; (singleton from ([Medication] M where M.id = GetId((request.medication as Reference).reference))).code#xD; #xD; /*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)*/#xD; define function "HasStart"(period Interval<DateTime> ):#xD; not ( start of period is null#xD; or start of period = minimum DateTime#xD; )#xD; #xD; /*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)*/#xD; define function "HasEnd"(period Interval<DateTime> ):#xD; not (#xD; end of period is null#xD; or#xD; end of period = maximum DateTime#xD; )#xD; #xD; /*Given an interval, return the ending point if the interval has an ending boundary specified, otherwise, return the starting point*/#xD; define function "Latest"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range> ):#xD; ("Normalize Interval"(choice)) period#xD; return#xD; if ( HasEnd(period)) then end of period#xD; else start of period#xD; #xD; /*Given an interval, return the starting point if the interval has a starting boundary specified, otherwise, return the ending point*/#xD; define function "Earliest"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range> ):#xD; ("Normalize Interval"(choice)) period#xD; return#xD; if (HasStart(period)) then start of period#xD; else end of period#xD; #xD;
Title: SupplementalDataElementsFHIR4 Id: SupplementalDataElementsFHIR4 Version: 2.0.000 Url: SupplementalDataElementsFHIR4 Status: draft Experimental: true Type: system: http://terminology.hl7.org/CodeSystem/library-type code: logic-library display: Logic Library Related Artifacts: Dependencies http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1 FHIR Helpersversion: null4.0.1) Ethnicity ONC Administrative Sex Payer Type Race Parameters: Name Type Min Max In/Out Patient Patient 0 1 Out SDE Ethnicity Coding 0 * Out SDE Payer Any 0 * Out SDE Race Coding 0 * Out SDE Sex Coding 0 1 Out Data Requirements: Type Profile MS Code Filter Patient http://hl7.org/fhir/StructureDefinition/Patient ;;; Coverage http://hl7.org/fhir/StructureDefinition/Coverage ;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591 Content: text/cql library SupplementalDataElementsFHIR4 version '2.0.000'#xD; #xD; /*@update: @@BTR 2020-03-31 ->#xD; Incremented version to 2.0.0#xD; Updated FHIR version to 4.0.1#xD; @@@*/#xD; #xD; using FHIR version '4.0.1'#xD; #xD; include FHIRHelpers version '4.0.1' called FHIRHelpers#xD; #xD; valueset "Ethnicity": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.837' #xD; valueset "ONC Administrative Sex": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1' #xD; valueset "Payer": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591' #xD; valueset "Race": 'http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.836' #xD; #xD; context Patient#xD; #xD; define "SDE Ethnicity":#xD; (flatten (#xD; Patient.extension Extension#xD; where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity'#xD; return Extension.extension#xD; )) E#xD; where E.url = 'ombCategory'#xD; or E.url = 'detailed'#xD; return E.value as Coding#xD; #xD; define "SDE Payer":#xD; [Coverage: type in "Payer"] Payer#xD; return {#xD; code: Payer.type,#xD; period: Payer.period#xD; }#xD; #xD; define "SDE Race":#xD; (flatten (#xD; Patient.extension Extension#xD; where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race'#xD; return Extension.extension#xD; )) E#xD; where E.url = 'ombCategory'#xD; or E.url = 'detailed'#xD; return E.value as Coding#xD; #xD; define "SDE Sex":#xD; case#xD; when Patient.gender = 'male' then Code { code: 'M', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Male' }#xD; when Patient.gender = 'female' then Code { code: 'F', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Female' }#xD; else null#xD; end#xD; #xD;
Title: NHSN Glycemic Control Hypoglycemic Initial Population Id: NHSNGlycemicControlHypoglycemicInitialPopulation Version: 0.0.002 Url: NHSN Glycemic Control Hypoglycemic Initial Population Status: draft Experimental: true Type: system: http://terminology.hl7.org/CodeSystem/library-type code: logic-library display: Logic Library Related Artifacts: Dependencies http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1 FHIR Helpersversion: null4.0.1) SupplementalDataElementsFHIR4version: null2.0.000) MAT Global Common Functions FHIRR4version: null6.1.000) ActCode Diagnosis Role specimenType Observation Category Codes Condition Category Codes Blood Glucose Laboratory and Point of Care Tests Inpatient, Emergency, and Observation Locations Discharge disposition Diabetes Medications Emergency Department Visit Encounter Inpatient Observation Services Payer Type Parameters: Name Type Min Max In/Out Measurement Period Period 0 1 In Patient Patient 0 1 Out Inpatient Encounter Encounter 0 * Out Patient Hospital Locations Encounter 0 * Out Antidiabetic Drugs Administered or Ordered Any 0 * Out Initial Population Encounter 0 * Out SDE Chief Complaint Encounter 0 * Out SDE Condition Condition 0 * Out SDE Condition during Encounter Condition 0 * Out SDE Encounter Discharge Dispositions Encounter 0 * Out SDE Encounter Locations Encounter 0 * Out SDE Medication Administration MedicationAdministration 0 * Out SDE Medication Request MedicationRequest 0 * Out SDE Blood Glucose Observation Observation 0 * Out SDE Payer Any 0 * Out SDE Specimen Specimen 0 * Out SDE Minimal Patient Patient 0 1 Out SDE Minimal Medication Requests MedicationRequest 0 * Out Data Requirements: Type Profile MS Code Filter Patient http://hl7.org/fhir/StructureDefinition/Patient Encounter http://hl7.org/fhir/StructureDefinition/Encounter ; code filter: path: class system: http://terminology.hl7.org/CodeSystem/v3-ActCode code: IMP display: inpatient encounter system: http://terminology.hl7.org/CodeSystem/v3-ActCode code: ACUTE display: inpatient acute system: http://terminology.hl7.org/CodeSystem/v3-ActCode code: NONAC display: inpatient non-acute system: http://terminology.hl7.org/CodeSystem/v3-ActCode code: SS display: short stay Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.666.5.307 Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;; Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1111.143 Encounter http://hl7.org/fhir/StructureDefinition/Encounter ;;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292 Location http://hl7.org/fhir/StructureDefinition/Location ; Medication http://hl7.org/fhir/StructureDefinition/Medication ; MedicationAdministration http://hl7.org/fhir/StructureDefinition/MedicationAdministration ;;; MedicationRequest http://hl7.org/fhir/StructureDefinition/MedicationRequest ;; Specimen http://hl7.org/fhir/StructureDefinition/Specimen ;;; Condition http://hl7.org/fhir/StructureDefinition/Condition ;; Observation http://hl7.org/fhir/StructureDefinition/Observation ;;;;;; code filter: path: code value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.38 Coverage http://hl7.org/fhir/StructureDefinition/Coverage ;; code filter: path: type value set: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591 Content: text/cql 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"
NHSN Glycemic Control Hypoglycemic Initial Population
Value set Blood Glucose Laboratory and Point of Care Tests
Value set Inpatient, Emergency, and Observation Locations
Antidiabetic Drugs Administered or Ordered
Knowledge Artifact Metadata Name (machine-readable) NHSNGlycemicControlHypoglycemicInitialPopulation Title (human-readable) NHSN Glycemic Control, Hypoglycemia Initial Population Status Draft Experimental true 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 The primary purpose of this site is to provide CDC’s NHSN with access to view measure specification content in the dQMs under development by Lantana Consulting Group. Please note, this site is draft and undergoes constant revision and is not intended to serve as an implementation guide. Measure Steward NHSN 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 Metadata Version Number 0.000.01 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. Definition Antidiabetic Drug Days (ADD): Aggregate number of inpatient encounter days within the facility in which at least one injectable or oral ADD was received. All patients who received ADDs during the hospitalization contribute to the initial population regardless of whether the patient experienced a hypoglycemic event. , Emergency Department (ED) or Observation (OBS) encounters: ED or observation encounters that ended within an hour of the inpatient admission are included when calculating the start and stop times of the hospitalization. Only Metric 1 includes ED and OBS encounters. , Hypoglycemia Day: An inpatient day with at least one documented hypoglycemia event. , Hypoglycemia Event includes the following during an inpatient hospitalization: A hypoglycemic blood glucose (BG) result during the encounter and ADD administered within 24 hours prior to the start of the hypoglycemic BG result and no subsequent test for blood glucose with a result ≥80 mg/dL within five minutes of the start of the initial low blood glucose test. , Inpatient Encounter: A hospitalization in any inpatient facility that meets the criteria for reporting to the NHSN Glycemic Control Hypoglycemia Module (refer to CDC Locations and Descriptions manual). , Measurement Period: From the first day of each calendar month through the last day of that calendar month. Mild hypoglycemia: Blood glucose 54 mg/dL to 69 mg/dL as identified on central laboratory device (CLD) or prescription point-of-care (POC) device. , Moderate hypoglycemia: Blood glucose 40 mg/dL to 53 mg/dL as identified on CLD or prescription POC device. , Severe hypoglycemia Blood glucose < 40 mg/dL as identified on CLD or prescription POC device. Measure Population Criteria Initial Population ID: initial-population-01 Description: All 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. Logic Definition: Initial Population Supplemental Data Elements Supplemental Data Element ID: sde-chief-complaint Description: No description provided Logic Definition: SDE Chief Complaint Supplemental Data Element ID: sde-condition Description: No description provided Logic Definition: SDE Condition Supplemental Data Element ID: sde-condition-during-encounter Description: No description provided Logic Definition: SDE Condition during Encounter Supplemental Data Element ID: sde-encounter-discharge-dispositions Description: No description provided Logic Definition: SDE Encounter Discharge Dispositions Supplemental Data Element ID: sde-encounter-locations Description: No description provided Logic Definition: SDE Encounter Locations Supplemental Data Element ID: sde-medication-administration Description: No description provided Logic Definition: SDE Medication Administration Supplemental Data Element ID: sde-medication-request Description: No description provided Logic Definition: SDE Medication Request Supplemental Data Element ID: sde-blood-glucose-observation Description: No description provided Logic Definition: SDE Blood Glucose Observation Supplemental Data Element ID: sde-payer Description: No description provided Logic Definition: SDE Payer Supplemental Data Element ID: sde-specimen Description: No description provided Logic Definition: SDE Specimen Supplemental Data Element ID: sde-minimal-patient Description: No description provided Logic Definition: SDE Minimal Patient Supplemental Data Element ID: sde-minimal-medication-requests Description: No description provided Logic Definition: SDE Minimal Medication Requests Measure Logic Primary Library NHSN Glycemic Control Hypoglycemic Initial Population Dependency Description: Library FHIRHelpers Resource: FHIR Helpersversion: null4.0.1) Canonical URL: http://fhir.org/guides/cqf/common/Library/FHIRHelpers|4.0.1 Dependency Description: Library Global Resource: MAT Global Common Functions FHIRR4version: null6.1.000) Canonical URL: http://fhir.org/guides/cqf/Library/MATGlobalCommonFunctionsFHIR4|6.1.000 Dependency Description: Library SDE Resource: SupplementalDataElementsFHIR4version: null2.0.000) Canonical URL: http://fhir.org/guides/cqf/Library/SupplementalDataElementsFHIR4|2.0.000 Dependency Description: Code system ActCode Resource: ActCode Canonical URL: http://terminology.hl7.org/CodeSystem/v3-ActCode Dependency Description: Code system Condition Category Resource: Condition Category Codes Canonical URL: http://terminology.hl7.org/CodeSystem/condition-category Dependency Description: Code system Observation Category Resource: Observation Category Codes Canonical URL: http://terminology.hl7.org/CodeSystem/observation-category Dependency Description: Code system Diagnosis Role Resource: Diagnosis Role Canonical URL: http://terminology.hl7.org/CodeSystem/diagnosis-role Dependency Description: Value set Antidiabetic Medications Resource: Diabetes Medications Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113762.1.4.1190.58 Dependency 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.265 Dependency 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.38 Dependency Description: Value set Payer Resource: Payer Type Canonical URL: http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591 Dependency Description: Value set Discharge Disposition Resource: Discharge disposition Canonical URL: http://terminology.hl7.org/ValueSet/encounter-discharge-disposition Direct Reference Code Display: inpatient encounter Code: IMP System: http://terminology.hl7.org/CodeSystem/v3-ActCode Direct Reference Code Display: inpatient acute Code: ACUTE System: http://terminology.hl7.org/CodeSystem/v3-ActCode Direct Reference Code Display: inpatient non-acute Code: NONAC System: http://terminology.hl7.org/CodeSystem/v3-ActCode Direct Reference Code Display: short stay Code: SS System: http://terminology.hl7.org/CodeSystem/v3-ActCode Direct Reference Code Display: observation encounter Code: OBSENC System: http://terminology.hl7.org/CodeSystem/v3-ActCode Direct Reference Code Display: emergency Code: EMER System: http://terminology.hl7.org/CodeSystem/v3-ActCode Direct Reference Code Display: Encounter Diagnosis Code: encounter-diagnosis System: http://terminology.hl7.org/CodeSystem/condition-category Direct Reference Code Display: Laboratory Code: laboratory System: http://terminology.hl7.org/CodeSystem/observation-category Direct Reference Code Display: Chief complaint Code: CC System: http://terminology.hl7.org/CodeSystem/diagnosis-role Parameter Name: Measurement Period Use: In Min Cardinality: 0 Max Cardinality: 1 Type: Period Parameter Name: SDE Medication Request Use: Out Min Cardinality: 0 Max Cardinality: * Type: MedicationRequest Parameter Name: SDE Encounter Locations Use: Out Min Cardinality: 0 Max Cardinality: * Type: Encounter Parameter Name: SDE Minimal Medication Requests Use: Out Min Cardinality: 0 Max Cardinality: * Type: MedicationRequest Parameter Name: SDE Condition during Encounter Use: Out Min Cardinality: 0 Max Cardinality: * Type: Condition Parameter Name: SDE Medication Administration Use: Out Min Cardinality: 0 Max Cardinality: * Type: MedicationAdministration Parameter Name: SDE Blood Glucose Observation Use: Out Min Cardinality: 0 Max Cardinality: * Type: Observation Parameter Name: SDE Condition Use: Out Min Cardinality: 0 Max Cardinality: * Type: Condition Parameter Name: SDE Payer Use: Out Min Cardinality: 0 Max Cardinality: * Type: Any Parameter Name: Initial Population Use: Out Min Cardinality: 0 Max Cardinality: * Type: Encounter Parameter Name: SDE Encounter Discharge Dispositions Use: Out Min Cardinality: 0 Max Cardinality: * Type: Encounter Parameter Name: SDE Minimal Patient Use: Out Min Cardinality: 0 Max Cardinality: 1 Type: Patient Parameter Name: SDE Specimen Use: Out Min Cardinality: 0 Max Cardinality: * Type: Specimen Parameter Name: SDE Chief Complaint Use: Out Min Cardinality: 0 Max Cardinality: * Type: Encounter Measure Logic Data 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: 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 Measure Logic Definitions 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: SupplementalDataElementsFHIR4 define "SDE Payer": [Coverage: type in "Payer"] Payer return { code: Payer.type, period: Payer.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" Generated using version 0.4.6 of the sample-content-ig Liquid templates
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"
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 "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"
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 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 )
define "SDE Minimal Medication Requests": [MedicationRequest] MedicationRequests return MedicationRequest{ id: MedicationRequests.id, medication: GetMedicationCode(MedicationRequests.medication), dosageInstruction: MedicationRequests.dosageInstruction }
define "SDE Condition during Encounter": [Condition] ConditionEncounterDiagnosis with ConditionEncounterDiagnosis.category Category such that Category ~ "encounter-diagnosis" and exists("Initial Population")
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 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 Condition": [Condition] Conditions with "Initial Population" InitialPopulation such that Global."Normalize Interval"(Conditions.onset) overlaps InitialPopulation.period
define "SDE Payer": [Coverage: type in "Payer"] Payer return { code: Payer.type, period: Payer.period }
define "SDE Payer": SDE."SDE Payer" Payer with "Initial Population" InitialPopulation such that start of Payer.period before end of InitialPopulation.period
define "SDE Encounter Discharge Dispositions": "Initial Population" DischargeDispositions where DischargeDispositions.hospitalization.dischargeDisposition in "Discharge Disposition"
//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 }
define "SDE Specimen": [Specimen] Specimen with "Initial Population" InitialPopulation such that Global."Normalize Interval"(Specimen.collection.collected) during InitialPopulation.period
//Supplement Data Elements define "SDE Chief Complaint": "Initial Population" InitialPopulation with InitialPopulation.diagnosis InitialPopulationDiagnosis such that InitialPopulationDiagnosis.use ~ "Chief Complaint"
NHSN Glycemic Control, Hypoglycemia Initial Population
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.
The primary purpose of this site is to provide CDC’s NHSN with access to view measure specification content in the dQMs under development by Lantana Consulting Group. Please note, this site is draft and undergoes constant revision and is not intended to serve as an implementation guide.
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.
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.
Antidiabetic Drug Days (ADD): Aggregate number of inpatient encounter days within the facility in which at least one injectable or oral ADD was received. All patients who received ADDs during the hospitalization contribute to the initial population regardless of whether the patient experienced a hypoglycemic event.
Emergency Department (ED) or Observation (OBS) encounters: ED or observation encounters that ended within an hour of the inpatient admission are included when calculating the start and stop times of the hospitalization. Only Metric 1 includes ED and OBS encounters.
Hypoglycemia Day: An inpatient day with at least one documented hypoglycemia event.
Hypoglycemia Event includes the following during an inpatient hospitalization: A hypoglycemic blood glucose (BG) result during the encounter and ADD administered within 24 hours prior to the start of the hypoglycemic BG result and no subsequent test for blood glucose with a result ≥80 mg/dL within five minutes of the start of the initial low blood glucose test.
Inpatient Encounter: A hospitalization in any inpatient facility that meets the criteria for reporting to the NHSN Glycemic Control Hypoglycemia Module (refer to CDC Locations and Descriptions manual).
Measurement Period: From the first day of each calendar month through the last day of that calendar month. Mild hypoglycemia: Blood glucose 54 mg/dL to 69 mg/dL as identified on central laboratory device (CLD) or prescription point-of-care (POC) device.
Moderate hypoglycemia: Blood glucose 40 mg/dL to 53 mg/dL as identified on CLD or prescription POC device.
Severe hypoglycemia Blood glucose < 40 mg/dL as identified on CLD or prescription POC device.
All 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.