CDA API Guide

cda.null

Sometimes data is not available for a required element; however, CDA requires that we provide a reason for this absence of data. As such, a “nullFlavor” must be applied to the XML element. The table below shows the ‘nullFlavor’ options that we’ve included the CDA API:

cda.null.flavor = {
   NoInformation='NI',
   Other='OTH',
   Invalid='INV',
   NegativeInfinity='NINF',
   PositiveInfinity='PINF',
   Unencoded='UNC',
   Derived='DER',
   Unknown='UNK',
   AskedButUnknown='ASKU',
   NotAvailable='NAV',
   SufficientQuantity='QS',
   NotAsked='NASK',
   Trace='TRC',
   Masked='MSK',
   NotApplicable='NA'
}

This function sets the ‘nullFlavour’ value:


set() [top]

Usage: cda.null.set(<{ELEMENT}>, <NULLFLAVOR>)

Set the ‘nullFlavour’ for a missing required element. Notice that we use rounded brackets instead of curly braces.

Note: This function removes all children, including attributes and sub-elements, and replaces them with the ‘nullFlavor’ attribute. The only exception is the “xsi:type” attribute found in ‘value‘ elements. Those must remain to ensure NIST validation.

Returns:

  • A parsed tree representing the populated XML element

Required parameters:

  • element: The element to which null will be applied.
  • nullFlavor: The type of null. The module’s table provides the possible values.

Example:

As an example, suppose we had the following XML element:

<id root="" extension=""></id>

Imagine that we simply don’t know the ID. Also suppose that variable Id represents the XML element above. To rectify this in our CDA document, we need to add the following line of code:

cda.null.set(Id, cda.null.flavor.Unknown)

Example Result:

<id nullFlavor="UNK"></id>

Leave A Comment?