eCQM Content CMS Implementation Guide
2025.7.1 - CI Build

eCQM Content CMS Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2025.7.1 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/ecqm-content-cms-2025/ and changes regularly. See the Directory of published versions

Library: NHSNHelpers

Official URL: https://madie.cms.gov/Library/NHSNHelpers Version: 0.1.000
Active as of 2025-06-30 Responsible: Lantana Consulting Group Computable Name: NHSNHelpers
Other Identifiers: https://madie.cms.gov/login#682dc9ae83d89c53880d2fc5 (use: official, )

NHSNHelpers

Knowledge Artifact Metadata
Name (machine-readable) NHSNHelpers
Title (human-readable) NHSNHelpers
Status active
Experimental false
Description NHSNHelpers
Library Steward Lantana Consulting Group
Library Metadata
Identifier org.hl7.fhir.r5.model.Identifier@381e973f
Version Number 0.1.000
Library Type [http://terminology.hl7.org/CodeSystem/library-type#logic-library]
Library Content
CQL Content
library NHSNHelpers version '0.1.000'

using FHIR version '4.0.1'

include FHIRHelpers version '4.4.000' called FHIRHelpers

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, '/'))
Generated using version 0.4.7 of the sample-content-ig Liquid templates