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 » Sun, 2011-04-17, 09:17

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: 1821
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#2 Post by Michael Onken » Mon, 2011-04-18, 11:22

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 » Mon, 2011-04-18, 15:10

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: 1821
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#4 Post by Michael Onken » Mon, 2011-04-18, 16:32

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 » Wed, 2011-05-04, 09:32

What's better,
performQuery or sendFINDRequest?

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

#6 Post by Michael Onken » Wed, 2011-05-11, 10:32

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 » Fri, 2011-05-13, 12:41

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: 1821
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#8 Post by Michael Onken » Mon, 2011-05-16, 12:00

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 » Mon, 2011-05-16, 13:59

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: Bing [Bot], Google [Bot] and 1 guest