Question about OrthancPluginRegisterFindCallback callback

Hi Author,

I am writing a plugin that intercepts the C-FIND request from client (In this case Orthanc as SCP and client as SCU). I want to know what is the structure OrthancPluginFindAnswers and OrthancPluginFindQuery in signature of the callback

typedef OrthancPluginErrorCode (OrthancPluginFindCallback) (
OrthancPluginFindAnswers
answers,
const OrthancPluginFindQuery* query,
const char* issuerAet,
const char* calledAet);

I did search orthanc code but did not find one. Can you please help to share the detailed definition of those classes ? Is there any example that uses the callback ? How can I put the answer to the OrthancPluginFindAnswers ?

Thanks,

Hello,

I search the OrthancPlugins.cpp and those params are comming from the below method in the cpp file

virtual void Handle(DicomFindAnswers& answers,
const DicomMap& input,
const std::list& sequencesToReturn,
const std::string& remoteIp,
const std::string& remoteAet,
const std::string& calledAet,
ModalityManufacturer manufacturer)
{
DicomMap tmp;
tmp.Assign(input);

for (std::list::const_iterator it = sequencesToReturn.begin();
it != sequencesToReturn.end(); ++it)
{
if (!input.HasTag(*it))
{
tmp.SetValue(*it, “”, false);
}
}

{
boost::mutex::scoped_lock lock(that_.pimpl_->findCallbackMutex_);
currentQuery_.reset(new DicomArray(tmp));

if (that_.pimpl_->findCallback_)
{
OrthancPluginErrorCode error = that_.pimpl_->findCallback_
(reinterpret_cast<OrthancPluginFindAnswers*>(&answers),
reinterpret_cast<const OrthancPluginFindQuery*>(this),
remoteAet.c_str(),
calledAet.c_str());

So my next question is how a developer can fill in values for OrthancPluginFindAnswers (and also parse attribute/ value from OrthancPluginFindQuery) in his plugin ? Or does developer need to include DicomFindAnswers and OrthancPlugins::FindHandler class and cast back to the original class (DicomFindAnswers and OrthancPlugins::FindHandler) in his plugin code ?

Thanks,

Vào lúc 16:52:54 UTC+7 ngày Thứ Năm, 10 tháng 12, 2020, Christopher đã viết:

I saw in the SDK has this method that could help to fill in value for answer object : OrthancPluginFindAddAnswer, what I did as below to fill in the value for answer in my plugin code

OrthancPlugins::MemoryBuffer memoryBuffer;
memoryBuffer.ReadFile(“/home/chris/tmp/dicom_data/tmp/16.dcm”);
memoryBuffer.GetData();

OrthancPluginFindAddAnswer(OrthancPlugins::GetGlobalContext(), answers, memoryBuffer.GetData(), memoryBuffer.GetSize());

But the client get nothing response from the client. Here is the log from the orthanc with verbose. The bold one is the debug line in my plugin code, it already run inside the plugin.

I1211 15:39:13.822363 CommandDispatcher.cpp:337] Association Received from AET RADIANT on IP 192.168.1.74
I1211 15:39:13.822600 main.cpp:278] Incoming connection from AET RADIANT on IP 192.168.1.74, calling AET ORTHANC
I1211 15:39:13.822640 CommandDispatcher.cpp:632] Association Acknowledged (Max Send PDV: 16372)
I1211 15:39:13.823334 main.cpp:298] Incoming Find request from AET RADIANT on IP 192.168.1.74, calling AET ORTHANC
E1211 15:39:13.823550 PluginsManager.cpp:164] registering OnFindCallback
I1211 15:39:13.859511 CommandDispatcher.cpp:853] DUL Peer Requested Release
I1211 15:39:13.859583 CommandDispatcher.cpp:860] Association Release

Can you please help to tell me how to construct object to pass to the function OrthancPluginFindAddAnswer

ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginFindAddAnswer(
OrthancPluginContext* context,
OrthancPluginFindAnswers* answers,
const void* dicom,
uint32_t size)

dicom parameter is opaque so I do not know what the exact type of this param.

Vào lúc 17:56:25 UTC+7 ngày Thứ Năm, 10 tháng 12, 2020, Christopher đã viết:

16.dcm (389 KB)

I tried to modified the dicom file (16.dcm) with keeping only few fields (patientName and studyInstanceUID) and it works
I dont know why, although the previous dcm file is able to pass the class OrthancPluginFindAddAnswer

Vào lúc 15:42:49 UTC+7 ngày Thứ Sáu, 11 tháng 12, 2020, Christopher đã viết:

16.dcm (474 Bytes)

So my another question is

If I have json (which call rest api to another Orthanc/ DicomWeb Server), how can I build the dicom format and pass to the OrthancPluginFindAddAnswer like I did before (hard code to read file from local dir and cast it to string and pass to OrthancPluginFindAddAnswer) ?

Thanks,

Vào lúc 16:36:00 UTC+7 ngày Thứ Sáu, 11 tháng 12, 2020, Christopher đã viết:

After deeper search on SDK, I finally can answer my question, below is code snippet I used to fill in data for OrthancPluginFindAddAnswer

OrthancPlugins::MemoryBuffer memoryBuffer;
const char* json = R"({“0010,0010”: “This is PatientName”, “0020,000d”: “1.2.3.4.5.6”})";

OrthancPluginCreateDicom(OrthancPlugins::GetGlobalContext(), *memoryBuffer, json, nullptr, OrthancPluginCreateDicomFlags_None);
OrthancPluginFindAddAnswer(OrthancPlugins::GetGlobalContext(), answers, memoryBuffer.GetData(), memoryBuffer.GetSize());

Vào lúc 17:18:39 UTC+7 ngày Thứ Sáu, 11 tháng 12, 2020, Christopher đã viết: