InsertKey Example for Delphi
var
x: Integer;
begin
LEADDicomDS1.ResetDS();
LEADDicomDS1.InitDS (DICOM_CLASS_UNKNOWN, 0);
//insert some keys
LEADDicomDS1.InsertKey('PATIENT', True); //insert PATIENT level key
LEADDicomDS1.InsertKey('STUDY', True); //insert STUDY level key
//insert 5 SERIES level keys and some data
for x:= 1 to 5 do
begin
LEADDicomDS1.StringValueCount:= 1;
LEADDicomDS1.InsertKey('SERIES', True);
LEADDicomDS1.MoveChildElement ();
LEADDicomDS1.FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicomDS1.StringValues [0]:= IntToStr(x);
LEADDicomDS1.SetStringValue(1);
LEADDicomDS1.MoveParentElement();
LEADDicomDS1.MoveParentKey(); //move back up one level
end;
//move to root key
LEADDicomDS1.MoveRootKey(); //PATIENT level
ShowMessage(LEADDicomDS1.GetKeyValue);
//move to SERIES level
LEADDicomDS1.MoveChildKey(); //STUDY
LEADDicomDS1.MoveChildKey(); //SERIES
//find first SERIES
LEADDicomDS1.FindFirstKey('SERIES', True);
LEADDicomDS1.MoveChildElement ();
LEADDicomDS1.FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicomDS1.GetStringValue (0, 1);
ShowMessage(LEADDicomDS1.StringValues [0]);
//find next series
LEADDicomDS1.FindNextKey(True);
LEADDicomDS1.MoveChildElement ();
LEADDicomDS1.FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicomDS1.GetStringValue (0, 1);
ShowMessage(LEADDicomDS1.StringValues [0]);
//find last SERIES
LEADDicomDS1.FindLastKey('SERIES', True);
LEADDicomDS1.MoveChildElement ();
LEADDicomDS1.FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicomDS1.GetStringValue (0, 1);
ShowMessage(LEADDicomDS1.StringValues [0]);
//find previous SERIES
LEADDicomDS1.FindPrevKey(True);
LEADDicomDS1.MoveChildElement ();
LEADDicomDS1.FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicomDS1.GetStringValue (0, 1);
ShowMessage(LEADDicomDS1.StringValues [0]);
//find last SERIES and delete it
LEADDicomDS1.FindLastKey('SERIES', True);
LEADDicomDS1.DeleteKey();
//move to root key
LEADDicomDS1.MoveFirstKey(False);
ShowMessage(LEADDicomDS1.GetKeyValue);
//move to SERIES level
LEADDicomDS1.MoveChildKey(); //STUDY
LEADDicomDS1.MoveChildKey(); //SERIES
//move to first SERIES
LEADDicomDS1.MoveFirstKey(True);
LEADDicomDS1.MoveChildElement ();
LEADDicomDS1.FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicomDS1.GetStringValue (0, 1);
ShowMessage(LEADDicomDS1.StringValues [0]);
//move to next series
LEADDicomDS1.MoveNextKey(True);
LEADDicomDS1.MoveChildElement ();
LEADDicomDS1.FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicomDS1.GetStringValue (0, 1);
ShowMessage(LEADDicomDS1.StringValues [0]);
//move to last SERIES
LEADDicomDS1.MoveLastKey(True);
LEADDicomDS1.MoveChildElement ();
LEADDicomDS1.FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicomDS1.GetStringValue (0, 1);
ShowMessage(LEADDicomDS1.StringValues [0]);
//move to previous SERIES
LEADDicomDS1.MovePrevKey(True);
LEADDicomDS1.MoveChildElement ();
LEADDicomDS1.FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicomDS1.GetStringValue (0, 1);
ShowMessage(LEADDicomDS1.StringValues [0]);
end;