InsertIOD Example for C++ 6.0 and later
BOOL bInsert;
long lCode;
short nType;
long hIOD;
long hTemp;
short nRet;
IDicomIODItemPtr pCurrentIOD=NULL;
bInsert = FALSE;
m_pLEADDicomDS->EnableMethodErrors = FALSE;
lCode = 1048593;
nType = DICOM_IOD_TYPE_CLASS;
//store current IOD
m_pLEADDicomDS->MoveFirstIOD (FALSE);
pCurrentIOD = m_pLEADDicomDS->GetCurrentIOD();
hIOD = pCurrentIOD->GethIOD();
//does an IOD already exist on the target level?
if(bChild)
{
//if the current IOD has a child, move to that child's level
nRet = m_pLEADDicomDS->MoveChildIOD();
if(nRet != 0) //no children, so insert is OK
{
bInsert = TRUE;
m_pLEADDicomDS->SetCurrentIOD (hIOD);
}
else //check the child's level to see if target IOD already exists
{
pCurrentIOD = m_pLEADDicomDS->GetCurrentIOD();
hTemp = pCurrentIOD->GethIOD();
m_pLEADDicomDS->MoveFirstIOD (TRUE);
nRet = m_pLEADDicomDS->FindIOD (lCode, nType, TRUE);
if(nRet != 0)
bInsert = TRUE;
//move back to parent level
m_pLEADDicomDS->SetCurrentIOD (hTemp);
m_pLEADDicomDS->MoveParentIOD ();
}
}
else
{
//check the current IOD's level
m_pLEADDicomDS->MoveFirstIOD (TRUE);
nRet = m_pLEADDicomDS->FindIOD (lCode, nType, TRUE);
if(nRet != 0)
bInsert = TRUE;
m_pLEADDicomDS->SetCurrentIOD (hIOD);
}
//allow user to insert item at the same level as the current or as child
if(bInsert)
{
nRet = m_pLEADDicomDS->InsertIOD(bChild, nType, lCode, "My Test IOD", 5, "Test Description");
if(nRet != 0)
AfxMessageBox("Error");
}
else
AfxMessageBox("Already exists");