LDicomDS::InsertKey
#include "ltdic.h"
pDICOMELEMENT LDicomDS::InsertKey(pParent, pszKey, bOptional)
|
pDICOMELEMENT pParent; |
/* pointer to a DICOMELEMENT structure */ |
|
L_TCHAR * pszKey; |
/* type of key element to insert */ |
|
L_BOOL bOptional; |
/* flag that indicates which elements to insert */ |
Inserts a new key element in the Dicom Dir Data Set.
|
Parameter |
Description |
|
|
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. |
|
|
pszKey |
Character string that contains the type of key element to find. 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 |
|
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
|
!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
|
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
Example
void DisplayKeyInfo1(LDicomDS *pDicomDS)
{
CString strMsg;
CString strTmp;
LDicomDS DicomDS;
//move to root KEY (PATIENT)
pDICOMELEMENT pRootKey = pDicomDS->GetFirstKey(NULL, FALSE);
CString strRootKey = pDicomDS->GetValueKey(pRootKey);
strMsg.Format(TEXT("Root Key[%s]\n"), strRootKey);
//move to child KEY (STUDY)
pDICOMELEMENT pStudyKey = pDicomDS->GetChildKey(pRootKey);
CString strStudyKey = pDicomDS->GetValueKey(pStudyKey);
strTmp.Format(TEXT("Root Key[%s]\n"), strStudyKey);
strMsg = strMsg + strTmp;
//move to child KEY (SERIES)
pDICOMELEMENT pSeriesKey = pDicomDS->GetChildKey(pStudyKey);
//find first SERIES key
pDICOMELEMENT pElement = pDicomDS->FindFirstKey(pSeriesKey, TEXT("SERIES"), TRUE);
pElement = pDicomDS->GetChildElement(pElement, TRUE);
pElement = pDicomDS->FindFirstElement(pElement, TAG_REFERENCED_FILE_ID, TRUE);
strTmp.Format(TEXT("First Series[%s]\n"), pDicomDS->GetStringValue(pElement, 0, 1) );
strMsg = strMsg + strTmp;
//find next series key
pElement = pDicomDS->FindNextKey(pElement, TRUE);
pElement = pDicomDS->GetChildElement(pElement, TRUE);
pElement = pDicomDS->FindFirstElement(pElement, TAG_REFERENCED_FILE_ID, TRUE);
strTmp.Format(TEXT("Next Series[%s]\n"), pDicomDS->GetStringValue(pElement, 0, 1) );
strMsg = strMsg + strTmp;
//find last SERIES key
pElement = pDicomDS->FindLastKey(pElement, TEXT("SERIES"), TRUE);
pElement = pDicomDS->GetChildElement(pElement, TRUE);
pElement = pDicomDS->FindFirstElement(pElement, TAG_REFERENCED_FILE_ID, TRUE);
strTmp.Format(TEXT("Last Series[%s]\n"), pDicomDS->GetStringValue(pElement, 0, 1) );
strMsg = strMsg + strTmp;
//find previous SERIES key
pElement = pDicomDS->FindPrevKey(pElement, TRUE);
pElement = pDicomDS->GetChildElement(pElement, TRUE);
pElement = pDicomDS->FindFirstElement(pElement, TAG_REFERENCED_FILE_ID, TRUE);
strTmp.Format(TEXT("Previous Series[%s]\n"), pDicomDS->GetStringValue(pElement, 0, 1) );
strMsg = strMsg + strTmp;
//Find root KEY another way
pRootKey = pDicomDS->GetRootKey(pElement);
strRootKey = pDicomDS->GetValueKey(pRootKey);
strTmp.Format(TEXT("Root Key[%s]\n"), strRootKey);
strMsg = strMsg + strTmp;
AfxMessageBox(strMsg);
}
void DisplayKeyInfo2(LDicomDS *pDicomDS)
{
CString strMsg;
CString strTmp;
LDicomDS DicomDS;
//move to root KEY (PATIENT)
pDICOMELEMENT pRootKey = pDicomDS->GetFirstKey(NULL, FALSE);
CString strRootKey = pDicomDS->GetValueKey(pRootKey);
strMsg.Format(TEXT("Root Key[%s]\n"), strRootKey);
//move to child KEY (STUDY)
pDICOMELEMENT pStudyKey = pDicomDS->GetChildKey(pRootKey);
CString strStudyKey = pDicomDS->GetValueKey(pStudyKey);
strTmp.Format(TEXT("Root Key[%s]\n"), strStudyKey);
strMsg = strMsg + strTmp;
//move to child KEY (SERIES)
pDICOMELEMENT pSeriesKey = pDicomDS->GetChildKey(pStudyKey);
//find first SERIES key
pDICOMELEMENT pElement = pDicomDS->GetFirstKey(pSeriesKey, TRUE);
pElement = pDicomDS->GetChildElement(pElement, TRUE);
pElement = pDicomDS->FindFirstElement(pElement, TAG_REFERENCED_FILE_ID, TRUE);
strTmp.Format(TEXT("First Series[%s]\n"), pDicomDS->GetStringValue(pElement, 0, 1) );
strMsg = strMsg + strTmp;
//find next series key
pElement = pDicomDS->GetNextKey(pElement, TRUE);
pElement = pDicomDS->GetChildElement(pElement, TRUE);
pElement = pDicomDS->FindFirstElement(pElement, TAG_REFERENCED_FILE_ID, TRUE);
strTmp.Format(TEXT("Next Series[%s]\n"), pDicomDS->GetStringValue(pElement, 0, 1) );
strMsg = strMsg + strTmp;
//find last SERIES key
pElement = pDicomDS->GetLastKey(pElement, TRUE);
pElement = pDicomDS->GetChildElement(pElement, TRUE);
pElement = pDicomDS->FindFirstElement(pElement, TAG_REFERENCED_FILE_ID, TRUE);
strTmp.Format(TEXT("Last Series[%s]\n"), pDicomDS->GetStringValue(pElement, 0, 1) );
strMsg = strMsg + strTmp;
//find previous SERIES key
pElement = pDicomDS->GetPrevKey(pElement, TRUE);
pElement = pDicomDS->GetChildElement(pElement, TRUE);
pElement = pDicomDS->FindFirstElement(pElement, TAG_REFERENCED_FILE_ID, TRUE);
strTmp.Format(TEXT("Previous Series[%s]\n"), pDicomDS->GetStringValue(pElement, 0, 1) );
strMsg = strMsg + strTmp;
//Find root KEY another way
pRootKey = pDicomDS->GetRootKey(pElement);
strRootKey = pDicomDS->GetValueKey(pRootKey);
strTmp.Format(TEXT("Root Key[%s]\n"), strRootKey);
strMsg = strMsg + strTmp;
AfxMessageBox(strMsg);
}
L_INT LDicomDS_InsertKeyExample()
{
L_INT nRet;
CString strMsg;
CString strTmp;
LDicomDS DicomDS;
pDICOMELEMENT pElement, pKey;
DicomDS.InitDS(CLASS_BASIC_DIRECTORY, 0);
//insert some keys
pKey = DicomDS.InsertKey(NULL, TEXT("PATIENT"), TRUE); //insert PATIENT level key
pKey = DicomDS.InsertKey(pKey, TEXT("STUDY"), TRUE); //insert STUDY level key
//insert 5 SERIES level keys and some data
for (int i = 0 ; i < 5 ; i++)
{
pKey = DicomDS.InsertKey(pKey, TEXT("SERIES"), TRUE);
pElement = DicomDS.GetChildElement(pKey, FALSE);
pElement = DicomDS.FindFirstElement(pElement, TAG_REFERENCED_FILE_ID, TRUE);
strTmp.Format(TEXT("%d"), i);
DicomDS.SetStringValue(pElement, (L_TCHAR*) (LPCTSTR)strTmp, 1, DICOM_CHARACTER_SET_DEFAULT);
pKey = DicomDS.GetParentKey(pKey);
}
//DisplayKeyInfo1 displays the information in the tree
DisplayKeyInfo1(&DicomDS);
nRet = DicomDS.SaveDS(TEXT("C:\\Program Files\\LEAD Technologies, Inc\\LEADTOOLS 15.0\\Images\\one.dic"), 0);
if(nRet != DICOM_SUCCESS)
return nRet;
//find last SERIES and delete it
pElement = DicomDS.GetChildKey(pKey);
pKey = DicomDS.FindLastKey(pElement, TEXT("SERIES"), TRUE);
DicomDS.DeleteKey(pKey);
AfxMessageBox(TEXT("Deleting Last Series Key..."));
//DisplayKeyInfo2 displays the same information as DisplayKeyInfo1 using different functions
DisplayKeyInfo2(&DicomDS);
nRet = DicomDS.SaveDS(TEXT("C:\\Program Files\\LEAD Technologies, Inc\\LEADTOOLS 15.0\\Images\\two.dic"), 0);
if(nRet != DICOM_SUCCESS)
return nRet;
return DICOM_SUCCESS;
}