CDA API Guide

cda.value

Clinical documents often describe some measured value. CDA supports the following value types:

  • INT (integer)
  • REAL (number with a fractional component)
  • ST (string)
  • PQ (measure value)

Note: To add a code value (CD), we recommend using the cda.code module instead.

The functions add values to your CDA document:


add(): adding INT and REAL values [top]

Usage: cda.value.add{target=<{PARENT}>, element=<ELEMENT>, datatype=<[INT | REAL]>, value=<VALUE>}

Add integers or fractions 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 element with the value attribute
  • datatype: Type of data stored in element (in this case, INT or REAL)

Optional parameters:

  • value: The actual value
  • unit: The unit of measurement

Example:

cda.value.add{target={PARENT}, element='value', datatype='INT', value='7'}

Example Result:

<value xsi:type="INT" value="7"></value>

add(): adding PQ values [top]

Usage: cda.value.add{target=<{PARENT}>, element=<ELEMENT>, datatype=’PQ’, value=<VALUE>, unit=<UNIT>}

Add a measurement to your CDA document. Notice that, to create a PQ value, you must add a unit argument and specify “PQ” as the datatype.

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 element with the value attribute
  • datatype: Type of data stored in element (in this case, INT or REAL)

Optional parameters:

  • value: The actual value
  • unit: The unit of measurement

Example:

cda.value.add{target={PARENT}, element='value', datatype='PQ', value='57', unit='a'}

Example Result:

<value xsi:type="PQ" value="57" unit="a"></value>

valuerange.add() [top]

Usage:

local Range = cda.valuerange.add{target=<{PARENT}>, element=<ELEMENT>, datatype=’IVL_*’}

— use cda.value.add{} to add the values for the Range

cda.value.add{target=Range, element=<LOW>, datatype=<DATATYPE>, value=<VALUE>, unit=<UNIT>}

cda.value.add{target=Range, element=<HIGH>, datatype=<DATATYPE>, value=<VALUE>, unit=<UNIT>}

INT, REAL and PQ values can also appears as intervals. To create an interval in your clinical document, you must first create the interval root element, then add the sub-elements defining the interval range. Essentially, you are adding a value XML element that encapsulates a value range.

Note: Intervals have a datatype of “IVL_*” (where * is replaced by the subtype that makes up the interval). For example, if an interval is made of PQ subtypes, then the type of the interval is ‘IVL_PQ’.

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 element with the value attribute
  • datatype: Type of data stored in element (in this case, IVL_*)

Example:

local Range = cda.valuerange.add{target={PARENT}, element='value', datatype='IVL_PQ'}
cda.value.add{target=Range, element='low', datatype='PQ', value='4.3', unit='10+3/ul'}
cda.value.add{target=Range, element='high', datatype='PQ', value='10.8', unit='10+3/ul'}

Example Result:

<value xsi:type="IVL_PQ">
   <low value="4.3" unit="10+3/ul"></low>
   <high value="10.8" unit="10+3/ul"></high>
</value>

valuestring.add()

Usage: cda.util.valuestring.add{target={PARENT}, string=<VALUE>}

Add a value XML element with inner content represented by text.

Note: A “value” element is added by default and its type is set to “ST”.

Returns: A parsed tree representing the populated XML element

Required parameters:

  • target: The parent tag under which you wish to add the new element
  • string: The inner content of the value

Example:

cda.util.valuestring.add{target={PARENT}, value='1 pack per day'}

Example Result:

<value xsi:type="ST">1 pack per day</value>

Leave A Comment?