HIV Screening Clinical Guidelines Implementation Guide
0.1.0 - CI Build Unknown region code '840'

HIV Screening Clinical Guidelines Implementation Guide, published by National Association of Community Health Centers, Inc. (NACHC). This guide is not an authorized publication; it is the continuous build for version 0.1.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/hiv-cds/ and changes regularly. See the Directory of published versions

Library: Library - NACHC Common

Official URL: http://fhir.org/guides/nachc/hiv-cds/Library/NACHCCommon Version: 0.1.0
Draft as of 2024-03-22 Computable Name: NACHCCommon

Copyright/Legal: Copyright National Association of Community Health Centers, Inc. (NACHC)

A Shared library encapsulating valuable common core functions for NACHC content.

Id: NACHCCommon
Url: Library - NACHC Common
Version: 0.1.0
Name: NACHCCommon
Title: Library - NACHC Common
Status: draft
Date: 2024-03-22 12:34:44+0000
Publisher: National Association of Community Health Centers, Inc. (NACHC)
Description:

A Shared library encapsulating valuable common core functions for NACHC content.

Jurisdiction: 840
Copyright:

Copyright National Association of Community Health Centers, Inc. (NACHC)

Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
PatientPatient01out
Data Requirements:
TypeProfileMSCode Filter
Patient http://hl7.org/fhir/StructureDefinition/Patient
Content: text/cql
library NACHCCommon version '4.0.1'

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1'
include FHIRCommon called FC

context Patient

define function Official(identifiers List<Identifier>):
  singleton from (identifiers I where I.use = 'official')

define function Official(names List<HumanName>):
  singleton from (names N where N.use = 'official')

/*
*/
define function Only(observations List<Observation>):
  singleton from observations

define function Earliest(observations List<Observation>):
  First(
    observations O
      sort by issued
  )

define function Latest(observations List<Observation>):
  Last(
    observations O
      sort by issued
  )

define function MostRecent(observations List<Observation>):
  Last(
    observations O
      sort by issued
  )

define function MostRecent(conditions List<Condition>):
  Last(
    conditions C
      sort by start of FC.ToInterval(onset)
  )

define function MostRecent(serviceRequests List<ServiceRequest>):
  Last(
    serviceRequests S
      sort by start of FC.ToInterval(occurrence)
  )

define function MostRecent(procedures List<Procedure>):
  Last(
    procedures P
      sort by start of FC.ToInterval(performed)
  )

define function Lowest(observations List<Observation>):
  First(
    observations O
      sort by (value as FHIR.Quantity)
  )

define function Highest(observations List<Observation>):
  Last(
    observations O
      sort by (value as FHIR.Quantity)
  )

/*
@description: Returns any NACHC core extensions defined on the given resource with the specified id.
@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access
content that is defined by extensions but not yet surfaced in the
CQL model info.
*/
define function Extensions(domainResource DomainResource, id String):
  domainResource.extension E
	  where E.url = ('http://fhir.org/guides/nachc/hiv-cds' + id)
		return E

/*
@description: Returns the single NACHC core extension (if present) on the given resource with the specified id.
@comment: This function uses singleton from to ensure that a run-time exception is thrown if there
is more than one extension on the given resource with the specified id.
*/
define function Extension(domainResource DomainResource, id String):
  singleton from "Extensions"(domainResource, id)

/*
@description: Returns any NACHC core extensions defined on the given element with the specified id.
@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access
content that is defined by extensions but not yet surfaced in the CQL model info.
*/
define function Extensions(element Element, id String):
  element.extension E
	  where E.url = ('http://fhir.org/guides/nachc/hiv-cds' + id)
		return E

/*
@description: Returns the single NACHC core extension (if present) on the given element with the specified id.
@comment: This function uses singleton from to ensure that a run-time exception is thrown if there
is more than one extension on the given resource with the specified url.
*/
define function Extension(element Element, id String):
  singleton from Extensions(element, id)

/*
@description: Returns any NACHC core modifier extensions defined on the given resource with the specified id.
@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access
content that is defined by extensions but not yet surfaced in the
CQL model info.
*/
define function ModifierExtensions(domainResource DomainResource, id String):
  domainResource.modifierExtension E
	  where E.url = ('http://fhir.org/guides/nachc/hiv-cds' + id)
		return E

/*
@description: Returns the single NACHC core modifier extension (if present) on the given resource with the specified id.
@comment: This function uses singleton from to ensure that a run-time exception is thrown if there
is more than one extension on the given resource with the specified url.
*/
define function ModifierExtension(domainResource DomainResource, id String):
  singleton from ModifierExtensions(domainResource, id)

/*
@description: Returns any NACHC core modifier extensions defined on the given element with the specified id.
@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access
content that is defined by extensions but not yet surfaced in the CQL model info.
*/
define function ModifierExtensions(element BackboneElement, id String):
  element.modifierExtension E
	  where E.url = ('http://fhir.org/guides/nachc/hiv-cds' + id)
		return E

/*
@description: Returns the single NACHC core modifier extension (if present) on the given element with the specified id.
@comment: This function uses singleton from to ensure that a run-time exception is thrown if there
is more than one extension on the given resource with the specified url.
*/
define function ModifierExtension(element BackboneElement, id String):
  singleton from ModifierExtensions(element, id)
Content: application/elm+xml
Encoded data (88000 characters)