L_DicomInsertKey

#include "ltdic.h"

L_LTDIC_API pDICOMELEMENT L_DicomInsertKey(hDS, pParent, pszKey, bOptional)

Inserts a new key element in the Dicom Dir Data Set.

Parameters

HDICOMDS hDS

A DICOM handle.

pDICOMELEMENT pParent

Pointer to a DICOMELEMENT structure that contains a key element in the Data Set. The new key element will be inserted as a child of this key element.

L_TCHAR * pszKey

Character string that contains the type of key element to insert. Possible values are:

Value Meaning
"PATIENT" Patient key element
"STUDY" Study key element
"SERIES" Series key element
"IMAGE" Image key element
"OVERLAY" Overlay key element
"MODALITY LUT" Modality-LUT key element
"VOI LUT" VOI-LUT key element
"CURVE" Curve key element
"STORED PRINT" Stored print key element
"RT DOSE" RT dose key element
"RT STRUCTURE SET" RT structure set key element
"RT PLAN" RT plan key element
"RT TREAT RECORD" RT treatment record key element
"TOPIC" Topic key element
"VISIT" Visit key element
"RESULTS" Results key element
"INTERPRETATION" Interpretation key element
"STUDY COMPONENT" Study Component key element
"PRESENTATION" Presentation key element
"WAVEFORM" Waveform key element
"SR DOCUMENT" Structured Reporting Document key element
"PRIVATE" Private key element
"KEY OBJECT DOC" Key Object Document key element
"SPECTROSCOPY" Spectroscopy key element
"RAW DATA" Raw Data key element
"REGISTRATION" Registration key element
"FIDUCIAL" Fiducial key element
"HANGING PROTOCOL" Hanging key element
"ENCAP DOC" Encapsulated Document key element
"HL7 STRUC DOC" HL7 Structured Document key element
"VALUE MAP" Real World Value Mapping key element
"STEREOMETRIC" Stereometric Relationship key element

L_BOOL bOptional

Flag that indicates which parts of the key element to insert. Possible values are:

Value Meaning
TRUE Insert all parts of the specified key element.
FALSE Insert only the mandatory parts of the specified key element.

Returns

Value Meaning
!NULL A pointer to a DICOMELEMENT structure containing the newly inserted item.
NULL Not enough memory to insert the item.

Comments

The newly inserted key element is inserted as a child of pParent.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

L_INT DicomInsertKeyExample(L_VOID) 
{ 
   L_INT x; 
   L_TCHAR szOut[200]; 
   L_TCHAR * pVal=NULL; 
   HDICOMDS hDS=NULL; 
   pDICOMELEMENT pKey=NULL; 
   pDICOMELEMENT pElement=NULL; 
    
   hDS = L_DicomCreateDS(NULL); 
   L_DicomInitDS(hDS, CLASS_UNKNOWN, 0); 
 
   /* insert some keys */ 
   pKey = L_DicomInsertKey(hDS, NULL, TEXT("PATIENT"), TRUE); /* insert PATIENT level key */ 
   if (pKey == NULL) 
   { 
      L_DicomFreeDS(hDS); 
      return DICOM_ERROR_MEMORY; 
   } 
 
   pKey = L_DicomInsertKey(hDS, pKey, TEXT("STUDY"), TRUE); /* insert STUDY level key */ 
   if (pKey == NULL) 
   { 
      L_DicomFreeDS(hDS); 
      return DICOM_ERROR_MEMORY; 
   } 
    
   /* insert 5 SERIES level keys and some data */ 
   for(x=1; x<=5; x++) 
   { 
      wsprintf(szOut, TEXT("%d"), x); 
      pKey = L_DicomInsertKey(hDS, pKey, TEXT("SERIES"), TRUE); 
      if (pKey == NULL) 
      { 
         L_DicomFreeDS(hDS); 
         return DICOM_ERROR_MEMORY; 
      } 
 
      pElement = L_DicomGetChildElement(hDS, pKey, FALSE); 
      pElement = L_DicomFindFirstElement(hDS, pElement, TAG_REFERENCED_FILE_ID, TRUE); 
      if (!L_DicomSetStringValue(hDS, pElement, szOut, 1, DICOM_CHARACTER_SET_DEFAULT)) 
      { 
         L_DicomFreeDS(hDS); 
         return FAILURE - 1; 
      } 
 
      pKey = L_DicomGetParentKey(hDS, pKey); /*move back up one level */ 
   } 
    
   /* move to root key */ 
   pKey = L_DicomGetRootKey(hDS, pKey); /* PATIENT level */ 
   MessageBox(NULL, L_DicomGetValueKey(hDS, pKey), TEXT("Test"), MB_OK); 
       
   /* move to SERIES level */ 
   pKey = L_DicomGetChildKey(hDS, pKey); /*STUDY*/ 
   pKey = L_DicomGetChildKey(hDS, pKey); /*SERIES*/ 
    
   /* find first SERIES */ 
   pKey = L_DicomFindFirstKey(hDS, pKey, TEXT("SERIES"), TRUE); 
   pElement = L_DicomGetChildElement(hDS, pKey, TRUE); 
   pElement = L_DicomFindFirstElement(hDS, pElement, TAG_REFERENCED_FILE_ID, TRUE); 
   pVal = L_DicomGetStringValue(hDS, pElement, 0, 1); 
   MessageBox(NULL, pVal, TEXT("Test"), MB_OK); 
    
   /* find next series */ 
   pKey = L_DicomFindNextKey(hDS, pKey, TRUE); 
   pElement = L_DicomGetChildElement(hDS, pKey, TRUE); 
   pElement = L_DicomFindFirstElement(hDS, pElement, TAG_REFERENCED_FILE_ID, TRUE); 
   pVal = L_DicomGetStringValue(hDS, pElement, 0, 1); 
   MessageBox(NULL, pVal, TEXT("Test"), MB_OK); 
    
   /* find last SERIES */ 
   pKey = L_DicomFindLastKey(hDS, pKey, TEXT("SERIES"), TRUE); 
   pElement = L_DicomGetChildElement(hDS, pKey, TRUE); 
   pElement = L_DicomFindFirstElement(hDS, pElement, TAG_REFERENCED_FILE_ID, TRUE); 
   pVal = L_DicomGetStringValue(hDS, pElement, 0, 1); 
   MessageBox(NULL, pVal, TEXT("Test"), MB_OK); 
    
   /* find previous SERIES */ 
   pKey = L_DicomFindPrevKey(hDS, pKey, TRUE); 
   pElement = L_DicomGetChildElement(hDS, pKey, TRUE); 
   pElement = L_DicomFindFirstElement(hDS, pElement, TAG_REFERENCED_FILE_ID, TRUE); 
   pVal = L_DicomGetStringValue(hDS, pElement, 0, 1); 
   MessageBox(NULL, pVal, TEXT("Test"), MB_OK); 
 
   /* find last SERIES and delete it */ 
   pKey = L_DicomFindLastKey(hDS, pKey, TEXT("SERIES"), TRUE); 
   L_DicomDeleteKey(hDS, pKey); 
    
   /* move to root key */ 
   pKey = L_DicomGetFirstKey(hDS, NULL, FALSE); 
   MessageBox(NULL, L_DicomGetValueKey(hDS, pKey), TEXT("Test"), MB_OK); 
    
   /* move to SERIES level */ 
   pKey = L_DicomGetChildKey(hDS, pKey); /*STUDY*/ 
   pKey = L_DicomGetChildKey(hDS, pKey); /*SERIES*/ 
    
   /* move to first SERIES */ 
   pKey = L_DicomGetFirstKey(hDS, pKey, TRUE); 
   pElement = L_DicomGetChildElement(hDS, pKey, TRUE); 
   pElement = L_DicomFindFirstElement(hDS, pElement, TAG_REFERENCED_FILE_ID, TRUE); 
   pVal = L_DicomGetStringValue(hDS, pElement, 0, 1); 
   MessageBox(NULL, pVal, TEXT("Test"), MB_OK); 
    
   /* move to next series */ 
   pKey = L_DicomGetNextKey(hDS, pKey, TRUE); 
   pElement = L_DicomGetChildElement(hDS, pKey, TRUE); 
   pElement = L_DicomFindFirstElement(hDS, pElement, TAG_REFERENCED_FILE_ID, TRUE); 
   pVal = L_DicomGetStringValue(hDS, pElement, 0, 1); 
   MessageBox(NULL, pVal, TEXT("Test"), MB_OK); 
    
   /* move to last SERIES */ 
   pKey = L_DicomGetLastKey(hDS, pKey, TRUE); 
   pElement = L_DicomGetChildElement(hDS, pKey, TRUE); 
   pElement = L_DicomFindFirstElement(hDS, pElement, TAG_REFERENCED_FILE_ID, TRUE); 
   pVal = L_DicomGetStringValue(hDS, pElement, 0, 1); 
   MessageBox(NULL, pVal, TEXT("Test"), MB_OK); 
    
   /* move to previous SERIES */ 
   pKey = L_DicomGetPrevKey(hDS, pKey, TRUE); 
   pElement = L_DicomGetChildElement(hDS, pKey, TRUE); 
   pElement = L_DicomFindFirstElement(hDS, pElement, TAG_REFERENCED_FILE_ID, TRUE); 
   pVal = L_DicomGetStringValue(hDS, pElement, 0, 1); 
   MessageBox(NULL, pVal, TEXT("Test"), MB_OK); 
 
   L_DicomFreeDS(hDS); 
   return DICOM_SUCCESS; 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C API Help