dQM QICore Content Implementation Guide
2025.0.0 - CI Build

dQM QICore Content Implementation Guide, published by cqframework. This guide is not an authorized publication; it is the continuous build for version 2025.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/dqm-content-qicore-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-08-21 Responsible: Lantana Consulting Group Computable Name: NHSNHelpers
Other Identifiers: https://madie.cms.gov/login#682dc9ae83d89c53880d2fc5 (use: official, )

NHSNHelpers

Metadata
Title NHSNHelpers
Version 0.1.000
Identifier 682dc9ae83d89c53880d2fc5
Steward (Publisher) Lantana Consulting Group
Description

NHSNHelpers

Type http://terminology.hl7.org/CodeSystem/library-type#logic-library
Data Requirement Type: Patient
Profile(s): Patient
Data Requirement Type: Patient
Profile(s): Patient
Must Support Elements: birthDate
Data Requirement Type: Location
Profile(s): Location
Must Support Elements: id
Parameters
Name Use Card. Type Documentation
Patient Out 0..1 Patient
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, '/'))
ELM XML Content
Encoded data 
ELM JSON Content
Encoded data 
Citations and References
Dependency Description: Library FHIRHelpers
Resource: FHIRHelpers version: 4.4.000
Canonical URL: https://madie.cms.gov/Library/FHIRHelpers|4.4.000
Generated using version 0.5.6 of the sample-content-ig Liquid templates