NetReceiveNGetRequest Example for Delphi
procedure TForm1.LEADDicomNet1NetReceiveNGetRequest(ASender: TObject;
hNet: Integer; nPresentationID, nMessageID: Smallint; const pszClass,
pszInstance: WideString);
var
nRet: Integer;
NewNode: TTreeNode;
strName: String;
begin
NewNode:= TreeView1.Items.Add(TreeView1.Selected, 'Command Set - ' + 'N-GET-REQUEST');
NewNode.MakeVisible();
TreeView1.Items.Add(NewNode, 'Presentation ID: ' + IntToStr(nPresentationID));
TreeView1.Items.Add(NewNode, 'Message ID: ' + IntToStr(nMessageID));
nRet:= LEADDicomDS1.FindUID (pszClass);
if(nRet = 0)then
begin
strName:= LEADDicomDS1.DefaultInterface.Get_CurrentUID().Name;
TreeView1.Items.Add(NewNode, 'Affected SOP Class: ' + strName + ' - ' + pszClass)
end
else
TreeView1.Items.Add(NewNode, 'Affected SOP Class: ' + pszClass);
TreeView1.Items.Add(NewNode, 'Affected SOP Instance: ' + pszInstance);
//this function will fill the values the data set elements in LEADDICOM2.hDicomDS
nRet:= PerformNGETCommand(pszClass, pszInstance);
if(nRet <> DICOM_SUCCESS)then
nRet:= COMMAND_STATUS_NO_SUCH_OBJECT_INSTANCE;
//send a response
LEADDICOMNet1.SendNGetResponse(hNet, nPresentationID, nMessageID, pszClass, pszInstance, nRet, LEADDicomDS2.hDicomDS);
end;
Function TForm1.PerformNGETCommand(strClass: String; strInstance: String): Integer;
var
nRet: Integer;
nTag: Integer;
x: Integer;
nVR: Integer;
begin
//this sample simply loads a fixed data set
//here, a server should check the class and instance against
//all SOP classes it manages, and then fill out hDS from the
//correctly matching instance, if one is found
nRet:= LEADDicomDS1.LoadDS ('e:\images\dicom16.dic', 0);
LEADDicomDS2.InitDS(DICOM_CLASS_UNKNOWN, 0);
LEADDicomDS2.ResetDS();
if(nRet = 0)then
LEADDicomDS1.MoveFirstElement (False)
else
begin
Result:= nRet;
Exit;
end;
for x:= 0 to LEADDICOMNet1.RequestAttributeCount - 1 do
begin
//get each element
nTag:= LEADDICOMNet1.RequestAttributes[x];
LEADDicomDS1.FindTag (nTag);
nVR:= LEADDicomDS1.DefaultInterface.Get_CurrentTag().VR;
nRet:= LEADDicomDS1.FindFirstElement (nTag, False);
//in this sample, if we don//t find the requested tag, we
//do not return an empty element!
if(nRet = 0)then
begin
//copy the element value
LEADDicomDS1.GetConvertValue ();
LEADDicomDS2.InsertElement (False, nTag, nVR, False, 0);
LEADDicomDS2.StringValueCount:= 1;
LEADDicomDS2.StringValues [0]:= LEADDicomDS1.StringValues[0];
LEADDicomDS2.SetConvertValue();
end;
end;
Result:= DICOM_SUCCESS;
end;