SendCFindRequest Example for Delphi
var
hPDU: LongInt;
nID: Integer;
nRet: Integer;
nVR: Integer;
strUID: String;
begin
//this example sends a command that will find all STUDIES on a called AE that
//supports the Study Root Query/Retrieve Information Model - FIND SOP Class
//send a Find request to the server
hPDU:= LEADDICOMNet1.GetAssociate (LEADDICOMNet1.hNet);
strUID:= UID_STUDY_ROOT_QUERY_FIND;
nID:= LEADDICOMNet1.FindPresentationAbstract (hPDU, strUID);
if(nID = 0)then
begin
nRet:= LEADDicomDS1.FindUID (strUID);
if(nRet = 0)then
ShowMessage('Abstract Syntax, ' + LEADDicomDS1.DefaultInterface.Get_CurrentUID().Name + ', Not Supported by Association!')
else
ShowMessage('Abstract Syntax, ' + strUID + ', Not Supported by Association!');
Exit;
end;
//create a find attribute data set
LEADDicomDS2.InitDS(DICOM_CLASS_UNKNOWN, 0);
LEADDicomDS2.ResetDS();
//add the required fields for this seach
LEADDicomDS2.FindTag (TAG_QUERY_RETRIEVE_LEVEL);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_QUERY_RETRIEVE_LEVEL, nVR, False, 0);
LEADDicomDS2.StringValueCount:= 1;
LEADDicomDS2.StringValues [0]:= 'STUDY'; //we are searching at the study level
LEADDicomDS2.SetStringValue(1);
LEADDicomDS2.FindTag (TAG_STUDY_DATE);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_STUDY_DATE, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_STUDY_TIME);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_STUDY_TIME, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_ACCESSION_NUMBER);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_ACCESSION_NUMBER, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_PATIENT_NAME);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_PATIENT_NAME, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_PATIENT_ID);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_PATIENT_ID, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_STUDY_ID);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_STUDY_ID, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_STUDY_INSTANCE_UID);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_STUDY_INSTANCE_UID, nVR, False, 0);
//optional tags
LEADDicomDS2.FindTag (TAG_STUDY_DESCRIPTION);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_STUDY_DESCRIPTION, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_PATIENT_BIRTH_DATE);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_PATIENT_BIRTH_DATE, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_PATIENT_SEX);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_PATIENT_SEX, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_OTHER_PATIENT_IDS);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag.VR;
LEADDicomDS2.InsertElement (False, TAG_OTHER_PATIENT_IDS, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_PATIENT_BIRTH_DATE);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag.VR;
LEADDicomDS2.InsertElement (False, TAG_PATIENT_BIRTH_DATE, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_ADDITIONAL_PATIENT_HISTORY);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag.VR;
LEADDicomDS2.InsertElement (False, TAG_ADDITIONAL_PATIENT_HISTORY, nVR, False, 0);
LEADDicomDS2.FindTag (TAG_NUMBER_OF_STUDY_RELATED_INSTANCES);
nVR:= LEADDicomDS2.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS2.InsertElement (False, TAG_NUMBER_OF_STUDY_RELATED_INSTANCES, nVR, False, 0);
//now, send the command set and data set
LEADDICOMNet1.SendCFindRequest(LEADDICOMNet1.hNet, nID, 1, strUID, COMMAND_PRIORITY_MEDIUM, LEADDicomDS2.hDicomDS);
end;