L_DicomInsertElement

#include "Ltdic.h"

L_LTDIC_API pDICOMELEMENT L_DicomInsertElement(hDS, pNeighbor, bChild, nTag, nVR, bSequence, nIndex)

HDICOMDS hDS;

/* a DICOM handle */

pDICOMELEMENT pNeighbor;

/* pointer to a DICOMELEMENT structure */

L_BOOL bChild;

/* flag that indicates where to insert the item */

L_UINT32 nTag;

/* tag value */

L_UINT16 nVR;

/* value representation */

L_BOOL bSequence;

/* flag that indicates whether the inserted item is a sequence */

L_UINT32 nIndex;

/* index value */

Inserts a new element in the Data Set.

Parameter

Description

hDS

A DICOM handle.

pNeighbor

Pointer to a DICOMELEMENT structure that contains an item in the Data Set. The inserted item will be inserted as a neighbor to this item, or as a child, depending on the value of bChild.

bChild

Flag that indicates where to insert the item. Possible values are:

 

Value

Meaning

 

TRUE

The new item will be inserted as the last child of pNeighbor.

 

FALSE

The new item will be inserted as the last sibling of pNeighbor.

nTag

Tag value for the inserted element. For a list of default values, refer to Data Element Tag Constants.

nVR

Value representation code that indicates the type of value stored in the data element. For a list of default values supported by DICOM, refer to Value Representation Constants.

bSequence

Flag that indicates whether the new item is a sequence. Possible values are:

 

Value

Meaning

 

TRUE

The new item is a sequence.

 

FALSE

The new item is not a sequence.

nIndex

Index value that indicates where to insert a TAG_ITEM data element in a sequence. This parameter is valid only if the data element being inserted has a tag of value TAG_ITEM. If the data element being inserted has any other tag value, this parameter is ignored. The index is zero based, so if you want to insert a TAG_ITEM data element as the first item in the sequence, set this to 0. The value ELEMENT_INDEX_MAX indicates to add the TAG_ITEM data element to the end of the sequence.

 

A sequence may consist of one or more items. This parameter lets you insert a TAG_ITEM data element as any item within the sequence, not just at the end. In addition, it lets you insert multiple TAG_ITEM data elements within a sequence.

 

If pNeighbor points to the parent of a sequence and bChild is true, the index will pertain to the children of pNeighbor. If pNeighbor points to a member of a sequence and bChild is false, the index pertains to the siblings of pNeighbor.

Returns

!NULL

A pointer to a DICOMELEMENT structure containing the newly inserted item.

NULL

Not enough memory to insert the item.

Comments

The illustrations below show how items are added to the Data Set (internally maintained as a tree), based on the value of bChild.

For the sake of these illustrations, the order of siblings is top to bottom. Therefore, since added items become the last sibling or the last child, these are drawn at the bottom of the appropriate group of items.

In this illustration, pNeighbor points to Item 1 and bChild is False. The new item is added as the last sibling of Item 1.

image\IODIsSib.gif

In this illustration, pNeighbor points to Item 1 and bChild is True. The new item is added as the last child of Item 1.

image\IODIsChd.gif

Required DLLs and Libraries

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_DicomInsertModule, L_DicomDeleteElement, L_DicomDeleteModule, L_DicomResetDS

Topics:

Working with Data Sets

Example

This example inserts 2 elements in Data Set

L_INT DicomInsertElementExample(L_VOID)
{
   HDICOMDS      hDS;
   pDICOMELEMENT pElement;

   hDS = L_DicomCreateDS(NULL);
   L_DicomInitDS(hDS, CLASS_CT_IMAGE_STORAGE, 0); 

   pElement = L_DicomInsertElement(hDS, NULL, FALSE, TAG_INSTITUTION_CODE_SEQUENCE, 
                                   VR_SQ, TRUE, ELEMENT_INDEX_MAX);
   if (pElement == NULL)
   {
      L_DicomFreeDS(hDS);
      return DICOM_ERROR_MEMORY;
   }

   pElement = L_DicomInsertElement(hDS, pElement, TRUE, TAG_CODE_VALUE, VR_SH, FALSE, 0);
   if (pElement == NULL)
   {
      L_DicomFreeDS(hDS);
      return DICOM_ERROR_MEMORY;
   }

   L_DicomFreeDS(hDS);
   return DICOM_SUCCESS;
}