comparison OrthancServer/main.cpp @ 565:c931ac02db82 find-move-scp

refactoring of find class
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Sep 2013 16:58:27 +0200
parents e0cfb413c86b
children 60d90e48e809
comparison
equal deleted inserted replaced
562:f64e3838d6e1 565:c931ac02db82
41 #include "../Core/Lua/LuaFunctionCall.h" 41 #include "../Core/Lua/LuaFunctionCall.h"
42 #include "../Core/DicomFormat/DicomArray.h" 42 #include "../Core/DicomFormat/DicomArray.h"
43 #include "DicomProtocol/DicomServer.h" 43 #include "DicomProtocol/DicomServer.h"
44 #include "OrthancInitialization.h" 44 #include "OrthancInitialization.h"
45 #include "ServerContext.h" 45 #include "ServerContext.h"
46 #include "OrthancFindRequestHandler.h"
46 47
47 using namespace Orthanc; 48 using namespace Orthanc;
48 49
49 50
50 51
70 } 71 }
71 } 72 }
72 }; 73 };
73 74
74 75
75 class MyFindRequestHandler : public IFindRequestHandler
76 {
77 private:
78 ServerContext& context_;
79
80 public:
81 MyFindRequestHandler(ServerContext& context) :
82 context_(context)
83 {
84 }
85
86 virtual void Handle(const DicomMap& input,
87 DicomFindAnswers& answers)
88 {
89 LOG(WARNING) << "Find-SCU request received";
90
91 /**
92 * Retrieve the query level.
93 **/
94
95 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL);
96 if (levelTmp == NULL)
97 {
98 throw OrthancException(ErrorCode_BadRequest);
99 }
100
101 ResourceType level = StringToResourceType(levelTmp->AsString().c_str());
102
103 if (level != ResourceType_Patient &&
104 level != ResourceType_Study &&
105 level != ResourceType_Series)
106 {
107 throw OrthancException(ErrorCode_NotImplemented);
108 }
109
110
111 /**
112 * Retrieve the constraints of the query.
113 **/
114
115 DicomArray query(input);
116
117 DicomMap constraintsTmp;
118 DicomMap wildcardConstraintsTmp;
119
120 for (size_t i = 0; i < query.GetSize(); i++)
121 {
122 if (!query.GetElement(i).GetValue().IsNull() &&
123 query.GetElement(i).GetTag() != DICOM_TAG_QUERY_RETRIEVE_LEVEL &&
124 query.GetElement(i).GetTag() != DICOM_TAG_SPECIFIC_CHARACTER_SET)
125 {
126 DicomTag tag = query.GetElement(i).GetTag();
127 std::string value = query.GetElement(i).GetValue().AsString();
128
129 if (value.find('*') != std::string::npos ||
130 value.find('?') != std::string::npos ||
131 value.find('\\') != std::string::npos ||
132 value.find('-') != std::string::npos)
133 {
134 wildcardConstraintsTmp.SetValue(tag, value);
135 }
136 else
137 {
138 constraintsTmp.SetValue(tag, value);
139 }
140 }
141 }
142
143 DicomArray constraints(constraintsTmp);
144 DicomArray wildcardConstraints(wildcardConstraintsTmp);
145
146 // http://www.itk.org/Wiki/DICOM_QueryRetrieve_Explained
147 // http://dicomiseasy.blogspot.be/2012/01/dicom-queryretrieve-part-i.html
148
149 constraints.Print(stdout);
150 printf("\n"); fflush(stdout);
151 wildcardConstraints.Print(stdout);
152 printf("\n"); fflush(stdout);
153 }
154 };
155
156
157 class MyMoveRequestHandler : public IMoveRequestHandler 76 class MyMoveRequestHandler : public IMoveRequestHandler
158 { 77 {
159 private: 78 private:
160 ServerContext& context_; 79 ServerContext& context_;
161 80
193 return new MyStoreRequestHandler(context_); 112 return new MyStoreRequestHandler(context_);
194 } 113 }
195 114
196 virtual IFindRequestHandler* ConstructFindRequestHandler() 115 virtual IFindRequestHandler* ConstructFindRequestHandler()
197 { 116 {
198 return new MyFindRequestHandler(context_); 117 return new OrthancFindRequestHandler(context_);
199 } 118 }
200 119
201 virtual IMoveRequestHandler* ConstructMoveRequestHandler() 120 virtual IMoveRequestHandler* ConstructMoveRequestHandler()
202 { 121 {
203 return new MyMoveRequestHandler(context_); 122 return new MyMoveRequestHandler(context_);