comparison OrthancServer/QueryRetrieveHandler.cpp @ 2218:3eefb84ac0bd

dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 13 Dec 2016 10:27:20 +0100
parents e3fd5bc429a2
children e7beca979562
comparison
equal deleted inserted replaced
2217:4f39ab2cb453 2218:3eefb84ac0bd
32 32
33 #include "PrecompiledHeadersServer.h" 33 #include "PrecompiledHeadersServer.h"
34 #include "QueryRetrieveHandler.h" 34 #include "QueryRetrieveHandler.h"
35 35
36 #include "OrthancInitialization.h" 36 #include "OrthancInitialization.h"
37 #include "FromDcmtkBridge.h"
37 38
38 39
39 namespace Orthanc 40 namespace Orthanc
40 { 41 {
42 static void FixQuery(DicomMap& query,
43 ServerContext& context,
44 const std::string& modality)
45 {
46 LuaScripting::Locker locker(context.GetLua());
47 static const char* CALLBACK = "OutgoingFindRequestFilter";
48
49 if (locker.GetLua().IsExistingFunction(CALLBACK))
50 {
51 LuaFunctionCall call(locker.GetLua(), CALLBACK);
52 call.PushDicom(query);
53 call.PushJson(modality);
54 FromDcmtkBridge::ExecuteToDicom(query, call);
55 }
56 }
57
58
59 static void FixQuery(DicomMap& query,
60 ModalityManufacturer manufacturer)
61 {
62 /**
63 * Introduce patches for specific manufacturers below.
64 **/
65
66 switch (manufacturer)
67 {
68 default:
69 break;
70 }
71 }
72
73
41 void QueryRetrieveHandler::Invalidate() 74 void QueryRetrieveHandler::Invalidate()
42 { 75 {
43 done_ = false; 76 done_ = false;
44 answers_.Clear(); 77 answers_.Clear();
45 } 78 }
47 80
48 void QueryRetrieveHandler::Run() 81 void QueryRetrieveHandler::Run()
49 { 82 {
50 if (!done_) 83 if (!done_)
51 { 84 {
52 ReusableDicomUserConnection::Locker locker(context_.GetReusableDicomUserConnection(), localAet_, modality_); 85 // Firstly, fix the content of the query for specific manufacturers
53 locker.GetConnection().Find(answers_, level_, query_); 86 DicomMap fixed;
87 fixed.Assign(query_);
88 FixQuery(fixed, modality_.GetManufacturer());
89
90 // Secondly, possibly fix the query with the user-provider Lua callback
91 FixQuery(fixed, context_, modality_.GetApplicationEntityTitle());
92
93 {
94 // Finally, run the C-FIND SCU against the fixed query
95 ReusableDicomUserConnection::Locker locker(context_.GetReusableDicomUserConnection(), localAet_, modality_);
96 locker.GetConnection().Find(answers_, level_, fixed);
97 }
98
54 done_ = true; 99 done_ = true;
55 } 100 }
56 } 101 }
57 102
58 103