LDicomDir::InsertDicomDS

#include "Ltdic.h"

L_UINT16 LDicomDir::InsertDicomDS(DataSet, pszFileName)

LDicomDS& DataSet;

/* LDicomDS object */

L_TCHAR* pszFileName;

/* DICOM file name */

Adds a DICOM Data Set to the Dicom Directory.

Parameter

Description

DataSet

The LDicomDS object that holds the Data Set to be added to the Dicom Directory.

pszFileName

Character string that contains the name of the DICOM file referenced by the object "DataSet".

Returns

0

The function was successful.

> 0

An error occurred. Refer to Return Codes.

Comments

If the name of a DICOM file is to be specified, then before using this function, a destination folder must have been specified, either at the construction time or by the function LDicomDir::ResetDicomDir. Otherwise, the function will fail.

The DICOM filename must refer to an existing file that resides in the destination folder or in a subfolder of the destination folder. Otherwise, the function will fail and the Data Set will not be added to the Dicom Directory. Please notice that the filename passed to the function must specify the absolute path of the file, not the relative one.

If the parameter pszFileName is set to NULL, a Data Set can still be added, even if no destination folder is specified. (That is, if pszFileName is set to NULL and the destination folder has not been set, a Data Set can still be added.) In this case, no DICOM file will be referenced for this Data Set (i.e., the corresponding Referenced File ID (0004,1500) will have an empty value).

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:

LDicomDir::InsertDicomFile, LDicomDir::LDicomDir, LDicomDir::ResetDicomDir, Class Members

Topics:

Creating DICOM Directories

 

Dicom Directories

Example

L_INT LDicomDir_InsertDicomDSExample()
{
   L_INT nRet;
   LDicomDir DicomDir;
   // Set the destination folder
   nRet = DicomDir.ResetDicomDir(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Medical Images\\Patient 1"));
   if(nRet != DICOM_SUCCESS)
      return nRet;
   // Set the File-set Identifier
   nRet = DicomDir.SetFileSetID(TEXT("SOME ID"));
   if(nRet != DICOM_SUCCESS)
      return nRet;
   // Don't allow invalid File IDs
   DICOMDIROPTIONS Options;
   nRet = DicomDir.GetOptions(&Options, sizeof(DICOMDIROPTIONS));
   if(nRet != DICOM_SUCCESS)
      return nRet;
   Options.uFlags |= DICOMDIR_REJECT_INVALID_FILEID;
   nRet = DicomDir.SetOptions(&Options);
   if(nRet != DICOM_SUCCESS)
      return nRet;
   // Set the File-set descriptor file
   nRet = DicomDir.SetDescriptorFile(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Medical Images\\Patient 1\\ReadMe"), NULL);
   if(nRet != DICOM_SUCCESS)
      return nRet;
   // Load a Data Set and add it to the Directory
   LDicomDS DicomDS;
   nRet = DicomDS.LoadDS(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Medical Images\\Patient 1\\Image1"), DS_LOAD_CLOSE);
   if(nRet != DICOM_SUCCESS)
      return nRet;
   nRet = DicomDir.InsertDicomDS(DicomDS, TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Medical Images\\Patient 1\\Image1"));
   if(nRet != DICOM_SUCCESS)
      return nRet;
   // Add some DICOM files to the Directory
   nRet = DicomDir.InsertDicomFile(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Medical Images\\Patient 1\\Image2"));
   if(nRet != DICOM_SUCCESS)
      return nRet;
   nRet = DicomDir.InsertDicomFile(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Medical Images\\Patient 1\\Image3"));
   if(nRet != DICOM_SUCCESS)
      return nRet;
   nRet = DicomDir.InsertDicomFile(TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\Medical Images\\Patient 1\\Image4"));
   if(nRet != DICOM_SUCCESS)
      return nRet;
   // Save the DICOMDIR File
   nRet = DicomDir.SaveDicomDir();
   if(nRet != DICOM_SUCCESS)
      return nRet;
   return DICOM_SUCCESS;
}