InsertIOD Example for Delphi
procedure TForm1.TestProc(bChild: Boolean);
var
bInsert: Boolean;
lCode: LongInt;
nType: Integer;
hIOD: LongInt;
hTemp: LongInt;
nRet: Integer;
begin
bInsert:= False;
LEADDicomDS1.EnableMethodErrors:= True;
lCode:= 1048593;
nType:= DICOM_IOD_TYPE_CLASS;
//store current IOD
hIOD:= LEADDicomDS1.DefaultInterface.Get_CurrentIOD().hIOD;
LEADDicomDS1.EnableMethodErrors:= False;
//does an IOD already exist on the target level?
if(bChild = True)then
begin
//if the current IOD has a child, move to that child//s level
nRet:= LEADDicomDS1.MoveChildIOD;
if(nRet <> 0)then //no children, so insert is OK
begin
bInsert:= True;
LEADDicomDS1.SetCurrentIOD(hIOD);
end
else //check the child//s level to see if target IOD already exists
begin
hTemp:= LEADDicomDS1.DefaultInterface.Get_CurrentIOD().hIOD;
LEADDicomDS1.MoveFirstIOD(True);
nRet:= LEADDicomDS1.FindIOD(lCode, nType, True);
if(nRet <> 0)then
bInsert:= True;
//move back to parent level
LEADDicomDS1.SetCurrentIOD(hTemp);
LEADDicomDS1.MoveParentIOD ();
end;
end
else
begin
//check the current IOD//s level
LEADDicomDS1.MoveFirstIOD (True);
nRet:= LEADDicomDS1.FindIOD(lCode, nType, True);
if(nRet <> 0)then
bInsert:= True;
LEADDicomDS1.SetCurrentIOD(hIOD);
end;
LEADDicomDS1.EnableMethodErrors:= True;
//allow user to insert item at the same level as the current or as child
if(bInsert = True)then
begin
LEADDicomDS1.InsertIOD(bChild,
nType,
lCode,
'My Test IOD',
5,
'Test Description');
if(nRet <> 0)then
ShowMessage('Error'); end else
ShowMessage('Already exists');
end;