comparison OrthancServer/Internals/FindScp.cpp @ 1786:164d78911382 worklists

primitives to handle dicom worklists
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Nov 2015 12:00:14 +0100
parents 3309878b3e16
children 1b1d5470233f
comparison
equal deleted inserted replaced
1784:2dbf25006f88 1786:164d78911382
93 { 93 {
94 namespace 94 namespace
95 { 95 {
96 struct FindScpData 96 struct FindScpData
97 { 97 {
98 IFindRequestHandler* handler_; 98 IFindRequestHandler* findHandler_;
99 DicomMap input_; 99 IWorklistRequestHandler* worklistHandler_;
100 DicomFindAnswers answers_; 100 DicomFindAnswers answers_;
101 DcmDataset* lastRequest_; 101 DcmDataset* lastRequest_;
102 const std::string* remoteIp_; 102 const std::string* remoteIp_;
103 const std::string* remoteAet_; 103 const std::string* remoteAet_;
104 bool noCroppingOfResults_; 104 bool noCroppingOfResults_;
118 DcmDataset **statusDetail) 118 DcmDataset **statusDetail)
119 { 119 {
120 bzero(response, sizeof(T_DIMSE_C_FindRSP)); 120 bzero(response, sizeof(T_DIMSE_C_FindRSP));
121 *statusDetail = NULL; 121 *statusDetail = NULL;
122 122
123 std::string sopClassUid(request->AffectedSOPClassUID);
124
123 FindScpData& data = *reinterpret_cast<FindScpData*>(callbackData); 125 FindScpData& data = *reinterpret_cast<FindScpData*>(callbackData);
124 if (data.lastRequest_ == NULL) 126 if (data.lastRequest_ == NULL)
125 { 127 {
126 FromDcmtkBridge::Convert(data.input_, *requestIdentifiers); 128 bool ok = false;
127 129
128 try 130 try
129 { 131 {
130 data.noCroppingOfResults_ = data.handler_->Handle(data.answers_, data.input_, 132 if (sopClassUid == UID_FINDModalityWorklistInformationModel)
131 *data.remoteIp_, *data.remoteAet_); 133 {
134 if (data.worklistHandler_ != NULL)
135 {
136 // TODO
137 std::auto_ptr<ParsedDicomFile> query(ParsedDicomFile::CreateFromDcmtkDataset(requestIdentifiers));
138 DicomWorklistAnswers a;
139 data.worklistHandler_->Handle(a, *query, *data.remoteIp_, *data.remoteAet_);
140 ok = true;
141 }
142 else
143 {
144 LOG(ERROR) << "No worklist handler is installed, cannot handle this C-FIND request";
145 }
146 }
147 else
148 {
149 if (data.findHandler_ != NULL)
150 {
151 DicomMap input;
152 FromDcmtkBridge::Convert(input, *requestIdentifiers);
153 data.noCroppingOfResults_ = data.findHandler_->Handle(data.answers_, input,
154 *data.remoteIp_, *data.remoteAet_);
155 ok = true;
156 }
157 else
158 {
159 LOG(ERROR) << "No C-Find handler is installed, cannot handle this request";
160 }
161 }
132 } 162 }
133 catch (OrthancException& e) 163 catch (OrthancException& e)
134 { 164 {
135 // Internal error! 165 // Internal error!
136 LOG(ERROR) << "C-FIND request handler has failed: " << e.What(); 166 LOG(ERROR) << "C-FIND request handler has failed: " << e.What();
167 }
168
169 if (!ok)
170 {
137 response->DimseStatus = STATUS_FIND_Failed_UnableToProcess; 171 response->DimseStatus = STATUS_FIND_Failed_UnableToProcess;
138 *responseIdentifiers = NULL; 172 *responseIdentifiers = NULL;
139 return; 173 return;
140 } 174 }
141 175
173 207
174 208
175 OFCondition Internals::findScp(T_ASC_Association * assoc, 209 OFCondition Internals::findScp(T_ASC_Association * assoc,
176 T_DIMSE_Message * msg, 210 T_DIMSE_Message * msg,
177 T_ASC_PresentationContextID presID, 211 T_ASC_PresentationContextID presID,
178 IFindRequestHandler& handler, 212 IFindRequestHandler* findHandler,
213 IWorklistRequestHandler* worklistHandler,
179 const std::string& remoteIp, 214 const std::string& remoteIp,
180 const std::string& remoteAet) 215 const std::string& remoteAet)
181 { 216 {
182 FindScpData data; 217 FindScpData data;
183 data.lastRequest_ = NULL; 218 data.lastRequest_ = NULL;
184 data.handler_ = &handler; 219 data.findHandler_ = findHandler;
220 data.worklistHandler_ = worklistHandler;
185 data.remoteIp_ = &remoteIp; 221 data.remoteIp_ = &remoteIp;
186 data.remoteAet_ = &remoteAet; 222 data.remoteAet_ = &remoteAet;
187 data.noCroppingOfResults_ = true; 223 data.noCroppingOfResults_ = true;
188 224
189 OFCondition cond = DIMSE_findProvider(assoc, presID, &msg->msg.CFindRQ, 225 OFCondition cond = DIMSE_findProvider(assoc, presID, &msg->msg.CFindRQ,