#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 | |
| "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 | |
| 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. | |
!NULL |
A pointer to a DICOMELEMENT structure containing the newly inserted item. |
NULL |
Not enough memory to insert the item. |
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 |
Win32, x64
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileNamevoid 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 keypDICOMELEMENT 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 keypElement = 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 keypElement = 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 keypElement = 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 waypRootKey = 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 keypDICOMELEMENT 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 keypElement = 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 keypElement = 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 keypElement = 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 waypRootKey = 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 keyspKey = DicomDS.InsertKey(NULL, TEXT("PATIENT"), TRUE); //insert PATIENT level keypKey = DicomDS.InsertKey(pKey, TEXT("STUDY"), TRUE); //insert STUDY level key//insert 5 SERIES level keys and some datafor (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 treeDisplayKeyInfo1(&DicomDS);nRet = DicomDS.SaveDS(MAKE_IMAGE_PATH(TEXT("one.dcm")), 0);if(nRet != DICOM_SUCCESS)return nRet;//find last SERIES and delete itpElement = 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 functionsDisplayKeyInfo2(&DicomDS);nRet = DicomDS.SaveDS(MAKE_IMAGE_PATH(TEXT("two.dcm")), 0);if(nRet != DICOM_SUCCESS)return nRet;return DICOM_SUCCESS;}