CDC National Healthcare Safety Network (NHSN) Digital Quality Measures (dQM) Content Package IG
1.0.0 - Release 1 United States of America flag

CDC National Healthcare Safety Network (NHSN) Digital Quality Measures (dQM) Content Package IG - Local Development build (v1.0.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

Library: NHSN Helpers

Official URL: http://www.cdc.gov/nhsn/fhirportal/dqm/ig/Library/NHSNHelpers Version: 1.0.0
Standards status: Trial-use Maturity Level: 1 Computable Name: NHSNHelpers
Id: NHSNHelpers
Version: 1.0.0
Url: NHSNHelpers
Status: draft
Type:

system: http://terminology.hl7.org/CodeSystem/library-type

code: logic-library

Date: 2025-09-28 15:20:22+0000
Publisher: CDC National Healthcare Safety Network (NHSN)
Jurisdiction: US
Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
PatientPatient01Out
Data Requirements:
TypeProfileMSCode Filter
Patient http://hl7.org/fhir/StructureDefinition/Patient
Location http://hl7.org/fhir/StructureDefinition/Location ;
Content: text/cql
library NHSNHelpers version '0.0.002'

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.2'

context Patient

define function "Normalize Interval"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>):
  case
	  when choice is FHIR.dateTime then
    	Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]
		when choice is FHIR.Period then
  		FHIRHelpers.ToInterval(choice as FHIR.Period)
		when choice is FHIR.instant then
			Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]
		when choice is FHIR.Age then
		  Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),
			  FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)
		when choice is FHIR.Range then
		  Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),
			  FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)
		when choice is FHIR.Timing then
		  Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute a single interval from a Timing type')
    when choice is FHIR.string then
      Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value')
		else
			null as Interval<DateTime>
	end

define function "ToDateInterval"(period FHIR.Period):
  Interval[date from period.start, date from period.end]

define function "GetLocation"(reference Reference ):
  singleton from (
	[Location] Locations
		where Locations.id = GetId(reference.reference)
  )

define function "GetId"(uri String ):
  Last(Split(uri, '/'))