FHIRHelpers
type: Library
node role: treeRoot
id:
  v: FHIRHelpers
text:
  status:
    v: generated
  div: Related Artifacts depends-on FHIR model information http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1 Contents text/cql /* @author: Bryn Rhodes @description: This library defines functions to convert between FHIR data types and CQL system-defined types, as well as functions to support FHIRPath implementation. For more information, see the FHIRHelpers wiki page: https://github.com/cqframework/clinical_quality_language/wiki/FHIRHelpers @allowFluent: true */ library FHIRHelpers version '4.0.1' using FHIR version '4.0.1' define function ToInterval(period FHIR.Period): if period is null then null else if period."start" is null then Interval(period."start".value, period."end".value] else Interval[period."start".value, period."end".value] define function ToCalendarUnit(unit System.String): case unit when 'ms' then 'millisecond' when 's' then 'second' when 'min' then 'minute' when 'h' then 'hour' when 'd' then 'day' when 'wk' then 'week' when 'mo' then 'month' when 'a' then 'year' else unit end define function ToQuantity(quantity FHIR.Quantity): case when quantity is null then null when quantity.value is null then null when quantity.comparator is not null then Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.') when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org' or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) } else Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')') end define function ToQuantityIgnoringComparator(quantity FHIR.Quantity): case when quantity is null then null when quantity.value is null then …
extension:
  url:
    v: http://hl7.org/fhir/us/cqfmeasures/StructureDefinition/cqfm-softwaresystem
  value: Reference
    link: http://smart.who.int/ig/smart-immunizations/Device/cqf-tooling
    reference:
      v: Device/cqf-tooling
url:
  v: http://hl7.org/fhir/Library/FHIRHelpers
version:
  v: 0.1.0
name:
  v: FHIRHelpers
status:
  v: draft
date:
  v: 2024-03-15T12:36:35+00:00
publisher:
  v: World Health Organization (WHO)
contact:
  name:
    v: World Health Organization (WHO)
  telecom:
    system:
      v: url
    value:
      v: https://www.who.int
jurisdiction:
  coding:
    system:
      v: http://unstats.un.org/unsd/methods/m49/m49.htm
    code:
      v: 001
related artifact:
  type:
    v: depends-on
  display:
    v: FHIR model information
  resource:
    v: http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1
    link: 4.0
    link: .1
content:
  content type:
    v: text/cql
content:
  content type:
    v: application/elm+xml
content:
  content type:
    v: application/elm+json