WHO Antenatal Care Guideline Implementation Guide
0.3.0 - CI Build International flag

WHO Antenatal Care Guideline Implementation Guide, published by World Health Organization (WHO). This guide is not an authorized publication; it is the continuous build for version 0.3.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/WorldHealthOrganization/smart-anc/ and changes regularly. See the Directory of published versions

Library: WHO Common

Official URL: http://fhir.org/guides/who/anc-cds/Library/WHOCommon Version: 0.3.0
Active as of 2024-04-09 Computable Name: WHOCommon

Defines common logic and functions usable across all WHO SMART Guideline content

Id: WHOCommon
Url: WHO Common
Version: 0.3.0
Name: WHOCommon
Title: WHO Common
Status: active
Experimental: false
Type:

system: LibraryType

code: logic-library

Date: 2024-04-09 18:08:09+0000
Publisher: World Health Organization (WHO)
Description: Defines common logic and functions usable across all WHO SMART Guideline content
Jurisdiction: 001
Related Artifacts:

Dependencies

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

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(addresses List<Address>):
  singleton from (addresses A where A.use = 'official')

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

define function Mobile(contactPoints List<ContactPoint>):
  singleton from (contactPoints P where P.use = 'mobile')

define function Only(allergies List<AllergyIntolerance>):
  singleton from allergies

define function Only(appointments List<Appointment>):
  singleton from appointments

define function Only(careplans List<CarePlan>):
  singleton from careplans

define function Only(conditions List<Condition>):
  singleton from conditions

define function Only(encounters List<Encounter>):
  singleton from encounters

define function Only(immunizations List<Immunization>):
  singleton from immunizations

define function Only(medicationrequests List<MedicationRequest>):
  singleton from medicationrequests

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

define function Only(procedures List<Procedure>):
  singleton from procedures

define function Only(serviceRequests List<ServiceRequest>):
  singleton from serviceRequests

define function Only(dosages List<Dosage>):
  singleton from dosages

define function Only(doses List<FHIR.Dosage.DoseAndRate>):
  singleton from doses

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(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 WHO 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/who/core/StructureDefinition/' + id)
		return E

/*
@description: Returns the single WHO 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 WHO 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/who/core/StructureDefinition/' + id)
		return E

/*
@description: Returns the single WHO 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 WHO 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/who/core/StructureDefinition/' + id)
		return E

/*
@description: Returns the single WHO 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 WHO 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/who/core/StructureDefinition/' + id)
		return E

/*
@description: Returns the single WHO 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 (104080 characters)
Content: application/elm+json
Encoded data (184496 characters)