CDA API Guide

cda.time

These functions add time values to your CDA document:

Note: These functions use the dateparse() function to create the resulting value.


add() [top]

Usage: cda.time.add{target=<{PARENT}>, element=<ELEMENT>, time=<DATETIME>}

Add a time value to your CDA document. There is no validity check, it is your responsibility to use the correct time format.

Note: The time zone defaults to UTC (GMT), to change zone you just add an increment/decrement, e.g., +500 for EST.

Returns: A parsed tree representing the populated XML element

Required parameters:

  • target:The parent tag under which you wish to add the new element
  • element: The specific name of the tag you are creating

Optional parameters:

  • time: A valid date-time string

Example:

Note: In this example we are using EST (+500)

cda.time.add{target={PARENT}, element='effectiveTime', time='20000323000000+500'}

Example Result:

<effectiveTime value='20000323000000+0500'></value>

set() [top]

Usage: cda.time.set{target=<{ELEMENT}>, time=<DATETIME>}

Update a time value to your CDA document.There is no validity check, it is your responsibility to use the correct time format.

Note: The time zone defaults to UTC (GMT), to change zone you just add an increment/decrement, e.g., +500 for EST.

Returns: A parsed tree representing the populated XML element

Required parameters:

  • target:The XML element that you wish to update

Optional parameters:

  • time: A valid date-time string

Example:

Note: In this example we are using EST (+500).

cda.time.set{target=ET, time='20000323000000+500'}

Example Result:

<effectiveTime value='20000323000000+0500'></value>

timerange.add() [top]

Usage:
local TimeRange = cda.timerange.add{target=<{PARENT}>, element=<ELEMENT>}
— use cda.time.add{} to add the dates for the Time Range
cda.time.add{target=TimeRange, element=<LOW>, time=<DATETIME>}
cda.time.add{target=TimeRange, element=<HIGH>, time=<DATETIME>}

To create a time interval, you must first create the interval root element. Then you can add the sub-elements defining the interval range. There is no validity check, it is your responsibility to use the correct time format.

Note: The time zone defaults to UTC (GMT), to change zone you just add an increment/decrement, e.g., +500 for EST.

Returns: A parsed tree representing the populated XML element

Required parameters:

  • target:The parent tag under which you wish to add the new element
  • element: The specific name of the tag you are creating

Example:

Note: In this example we are using EST (+500).

local ET = cda.timerange.add{target={PARENT}, element='effectiveTime'}
-- use cda.time.add{} to add the dates for the Time Range
cda.time.add{target=ET, element='low', time='20080501000000+500'}
cda.time.add{target=ET, element='high', time='2009022700000+500'}

Example Result:

<effectiveTime xsi:type="IVL_TS">
    <low value="20080501000000+0500"></low>
    <high value="20090227000000+0500"></high>
</effectiveTime>

timeperiod.add() [top]

Usage: cda.timeperiod.add(target=<{PARENT}>, element=<ELEMENT>, period=<PERIOD>, unit=<UNIT>}
Add a specific time period to your CDA document.

Returns: A parsed tree representing the populated XML element

Required parameters:

  • target:The parent tag under which you wish to add the new element
  • element: The specific name of the tag you are creating
  • period: The period of time you wish to add
  • unit: The time period unit

Example:
cda.timeperiod.add{target={PARENT}, element='effectiveTime', period='6', unit='h'}

Example Result:

<effectiveTime xsi:type="PIVL_TS" institutionSpecified="true" operator="A">
    <period value="6" unit="h"></period>
</effectiveTime>