CDA API Guide

cda.code

CDA documents rely on codes that the health system uses to express medical concepts. These codes can represent actions, roles, gender, etc.

These functions add/update the codes used in your CDA document:

  • code.add : Add a new code element to your CDA document
  • code.set : Update an existing code element in your CDA document
  • code.originalText.add : Add a new text element to an existing code element

add() [top]

Usage: cda.code.add{target=<{PARENT}>, element=<ELEMENT>, system=<CODESYSTEM>, value=<DISPLAYNAME>, lookup=<{LOOKUPTABLE}>, datatype=<CODETYPE>}

Add a code and its associated code system to identify a specific concept (such as a medication or a family of disorders). Includes a lookup feature that searches tables to set the values of the other arguments. These tables are defined in the cda.codeset module.

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:

  • system: The OID of the code system. These can be found in the cda.codeset.cat table (defined in the cda.codeset module).
  • value: The coded value usually obtained from the relevant codeset table
  • lookup: A table to give the display string of the coded value
  • datatype: The type of the data stored in the resulting XML element, typically CD

Example:
cda.code.add{target=P, element='administrativeGenderCode', system=cda.codeset.cat["HL7 AdministrativeGender"], value=cda.code.sex.Female, lookup=cda.code.sexTable}

Example Result:

<administrativeGenderCode code="F" codeSystem="2.16.840.1.113883.5.1" codeSystemName="HL7 AdministrativeGender" displayName="Female"></administrativeGenderCode>

set() [top]

Usage: cda.code.set{target=<{ELEMENT}>, system=<CODESYSTEM>, value=<DISPLAYNAME>, lookup=<{LOOKUPTABLE}>}

Updates an existing code XML element with new values.

Returns:

  • A parsed tree representing the populated XML element

Required parameters:

  • target: The XML element that you wish to update

Optional parameters:

  • system: The OID of the code system
  • value: The coded value usually obtained from the relevant codeset table
  • lookup: A table to give the display string of the coded value

Example:
Note: In this example, we are updating an XML element named ‘CodeElement’.

cda.code.set{target=CodeElement, system=cda.codeset.cat["LOINC"], value=cda.codeset.loinc['Consultative note'], lookup=cda.codeset.loincTable}

Example Result:

<code code="11488-4" codesystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Consultative note"></code>

originalText.add() [top]

Usage: cda.code.originalText.add{target=<{CODEPARENT}>, reference=<text>}

Code elements can have also originalText XML elements embedded within them. This functions adds a text reference to a code element.

Returns:

  • A parsed tree representing the populated XML element

Required parameters:

  • target: The parent code tag under which you wish to add the new element
  • reference: The ID associated with the human readable element that this element refers to

Example:
Note: In this example, we are adding text to an XML element named ‘CodeElement’.

cda.code.originalText.add{target=CodeElement, reference='ID'}

Example Result:

<code ...>
    <originalText reference="ID"></originalText>
</code>

Leave A Comment?