SendCGetRequest Example for Delphi
var
nRet: Integer;
strClassUID: String;
nVR: Integer;
hPDU: LongInt;
nID: Integer;
begin
//send a get request to the server
//gszGetFile will be used when this AE receives the NetReceiveCStoreRequest
//associated with this CGetRequest to save the data set
gszGetFile:= InputBox('Select filename for retrieved data set', 'Get Request', 'd:\temp\get_request.dic');
if(Length(gszGetFile) < 1)then
Exit;
strClassUID:= InputBox('What class do you wish to get?', 'Get Request', UID_SC_IMAGE_STORAGE);
if(Length(strClassUID) < 1)then
Exit;
//create the data set that encodes the identifier to be matched
LEADDicomDS1.InitDS (DICOM_CLASS_UNKNOWN, 0);
//add the required elements
LEADDicomDS1.FindTag (TAG_QUERY_RETRIEVE_LEVEL);
nVR:= LEADDicomDS1.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS1.InsertElement (False, TAG_QUERY_RETRIEVE_LEVEL, nVR, False, 0);
LEADDicomDS1.StringValueCount:= 1;
LEADDicomDS1.StringValues [0]:= 'PATIENT';
LEADDicomDS1.SetStringValue(1);
LEADDicomDS1.FindTag (TAG_PATIENT_NAME);
LEADDicomDS1.InsertElement (False, TAG_PATIENT_NAME, LEADDicomDS1.DefaultInterface.Get_CurrentTag().VR, False, 0);
LEADDicomDS1.StringValueCount:= 1;
LEADDicomDS1.StringValues [0]:= '*'; //get all patients
LEADDicomDS1.SetStringValue(1);
//add the optional fields that we want returned
LEADDicomDS1.FindTag (TAG_PATIENT_ID);
LEADDicomDS1.InsertElement (False, TAG_PATIENT_ID, LEADDicomDS1.DefaultInterface.Get_CurrentTag().VR, False, 0);
LEADDicomDS1.FindTag (TAG_PATIENT_BIRTH_DATE);
nVR:= LEADDicomDS1.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS1.InsertElement (False, TAG_PATIENT_BIRTH_DATE, nVR, False, 0);
LEADDicomDS1.FindTag (TAG_PATIENT_SEX);
nVR:= LEADDicomDS1.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS1.InsertElement (False, TAG_PATIENT_SEX, nVR, False, 0);
LEADDicomDS1.FindTag (TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES);
nVR:= LEADDicomDS1.DefaultInterface.Get_CurrentTag().VR;
LEADDicomDS1.InsertElement (False, TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES, nVR, False, 0);
hPDU:= LEADDICOMNet1.GetAssociate (LEADDICOMNet1.hNet);
//now, send a request
nID:= LEADDICOMNet1.FindPresentationAbstract (hPDU, strClassUID);
if(nID = 0)then
begin
nRet:= LEADDicomDS1.FindUID (strClassUID);
if(nRet = 0)then
ShowMessage('Abstract Syntax, ' + LEADDicomDS1.DefaultInterface.Get_CurrentUID().Name + ', Not Supported by Association!')
else
ShowMessage('Abstract Syntax, ' + strClassUID + ', Not Supported by Association!');
Exit;
end;
LEADDICOMNet1.SendCGetRequest (LEADDICOMNet1.hNet, nID, 999, strClassUID, COMMAND_PRIORITY_MEDIUM, LEADDicomDS1.hDicomDS);
//we now must wait for the response and for the C-STORE sub-operations
end;