How to read findResponses ?

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
ali.m.habib
Posts: 85
Joined: Sun, 2010-12-26, 17:34

How to read findResponses ?

#1 Post by ali.m.habib »

Hi,

I am implementing a CFind Request using DCMScu class

FINDResponses responses;
FindSCU.sendFINDRequest(cxID, &findParams, &responses);

but i cann't figure out how to use the responses to Read the Find Responses
any sample code will be appreciated.


Thanks in Advance

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#2 Post by Michael Onken »

Here is a short (pseudo code) example, which I did not test but generally shows what to do:

Code: Select all

FINDResponses responses;
FindSCU.sendFINDRequest(cxID, &findParams, &responses); 
DcmDataset *dset;
OFListIterator(FINDResponse*) it = responses.begin();
while (it != responses.end())
{
  FindResponse* rsp = *it;
  dset =  rsp->getDataset();
  // print dataset or whatever you want to do with it
  it++;
}
Best regards,
Michael

nibor
Posts: 8
Joined: Mon, 2011-04-18, 14:36

#3 Post by nibor »

Thank you for your quick answer, I had the same problem and I used your code, modified to compile:

Code: Select all

FINDResponses responses;
OFCondition bRet=poScu->sendFINDRequest(cxID, &findParams, &responses);
if(bRet.bad())
{
	cout << "Error sendFindRequest: "<< bRet.text() << endl;
}
cout<<responses.numResults()<<" responses found."<<endl;
DcmDataset *dset;
OFListIterator(FINDResponse*) it = responses.begin();
while (it != responses.end())
{
	FINDResponse* rsp = *it;
	dset =  rsp->m_dataset;
	if(dset!=NULL)
	{
	oStatus=dset->findAndGetOFString(DCM_PatientName, oOfStringItem);
	if (oStatus.bad())
	{
		cout<<"ERROR: Failed to find patient name"<<endl;
	}else{
		cout<<"Patient Name: "<<oOfStringItem.data()<<endl;
	}

	it++;
}
But I still have a problem: the last response in the iterator is always null (I should have 3 responses and I got 4, so I had to test if the dataset is null) is it normal?

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#4 Post by Michael Onken »

Hi,

yes, the last C-FIND response you get from the server should (by definition in DICOM itself) not contain any dataset but just returns the status SUCCESS (=0) in case everything goes fine.

Thus, you have to test each response indeed for a dataset. From the standard's point of view, only the last one will not contain any but I would never rely on that...

Best regards,
Michael

Forward
Posts: 17
Joined: Mon, 2011-05-02, 11:54

#5 Post by Forward »

What's better,
performQuery or sendFINDRequest?

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#6 Post by Michael Onken »

Hi,

sendFINDRequest() is the newer approach since it belongs to the C++ DcmSCU class which hides most of the dirty network C API.

performQuery is from the findscu code which was originally done in C but after some time was quickly "hacked" into a class for a project. performQuery() should work fine (many people use findscu) but the code is not elegant and well re-usable. Therefore I recommend you to build your application based on DcmSCU instead (and therefore, sendFINDRequest()).

Michael

Forward
Posts: 17
Joined: Mon, 2011-05-02, 11:54

#7 Post by Forward »

Thanks a lot ;)

Btw, i have other question
what's equivalent to movescu? i get the values but how can i get the image from server? DIMSERetreiveDataSet?

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#8 Post by Michael Onken »

Hi,

so far we do not have an equivalent for MOVESCU. However, you can expect that within the next days. The changes will then be available from ourgit repository and probably in a new DCMTK snapshot version.

Best regards,
Michael

Forward
Posts: 17
Joined: Mon, 2011-05-02, 11:54

#9 Post by Forward »

Thanks
While i wait for it, i will use the same way as movescu.exe get the image files

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest