annotate OrthancServer/OrthancFindRequestHandler.cpp @ 1648:a0a4fa28624c

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Sep 2015 11:33:55 +0200
parents bd1889029cbb
children ec66a16aa398
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
4 * Department, University Hospital of Liege, Belgium
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
32
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
33 #include "PrecompiledHeadersServer.h"
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "OrthancFindRequestHandler.h"
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
36 #include "../Core/Logging.h"
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../Core/DicomFormat/DicomArray.h"
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
38 #include "ServerToolbox.h"
618
5ab377df6d8b filtering on aet
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 615
diff changeset
39 #include "OrthancInitialization.h"
795
d466b3606aca refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
40 #include "FromDcmtkBridge.h"
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
42 #include "ResourceFinder.h"
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
43 #include "DicomFindQuery.h"
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
44
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
45 #include <boost/regex.hpp>
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
46
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
47
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
48 namespace Orthanc
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
49 {
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
50 static void AddAnswer(DicomFindAnswers& answers,
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
51 const Json::Value& resource,
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
52 const DicomArray& query)
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
53 {
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
54 DicomMap result;
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
55
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
56 for (size_t i = 0; i < query.GetSize(); i++)
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
57 {
1332
f2033e228864 fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1331
diff changeset
58 // Fix issue 30 (QR response missing "Query/Retrieve Level" (008,0052))
1346
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
59 if (query.GetElement(i).GetTag() == DICOM_TAG_QUERY_RETRIEVE_LEVEL)
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
60 {
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
61 result.SetValue(query.GetElement(i).GetTag(), query.GetElement(i).GetValue());
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
62 }
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
63 else if (query.GetElement(i).GetTag() == DICOM_TAG_SPECIFIC_CHARACTER_SET)
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
64 {
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
65 }
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
66 else
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
67 {
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
68 std::string tag = query.GetElement(i).GetTag().Format();
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
69 std::string value;
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
70 if (resource.isMember(tag))
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
71 {
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
72 value = resource.get(tag, Json::arrayValue).get("Value", "").asString();
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
73 result.SetValue(query.GetElement(i).GetTag(), value);
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
74 }
722
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
75 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
76 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
77 result.SetValue(query.GetElement(i).GetTag(), "");
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
78 }
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
79 }
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
80 }
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
81
1331
77e129ba64e4 Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
82 if (result.GetSize() == 0)
77e129ba64e4 Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
83 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
84 LOG(WARNING) << "The C-FIND request does not return any DICOM tag";
1331
77e129ba64e4 Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
85 }
77e129ba64e4 Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
86 else
77e129ba64e4 Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
87 {
77e129ba64e4 Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
88 answers.Add(result);
77e129ba64e4 Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
89 }
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
90 }
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
91
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
92
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
93 namespace
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
94 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
95 class CFindQuery : public DicomFindQuery
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
96 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
97 private:
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
98 DicomFindAnswers& answers_;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
99 ServerIndex& index_;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
100 const DicomArray& query_;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
101 bool hasModalitiesInStudy_;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
102 std::set<std::string> modalitiesInStudy_;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
103
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
104 public:
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
105 CFindQuery(DicomFindAnswers& answers,
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
106 ServerIndex& index,
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
107 const DicomArray& query) :
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
108 answers_(answers),
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
109 index_(index),
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
110 query_(query),
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
111 hasModalitiesInStudy_(false)
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
112 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
113 }
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
114
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
115 void SetModalitiesInStudy(const std::string& value)
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
116 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
117 hasModalitiesInStudy_ = true;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
118
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
119 std::vector<std::string> tmp;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
120 Toolbox::TokenizeString(tmp, value, '\\');
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
121
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
122 for (size_t i = 0; i < tmp.size(); i++)
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
123 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
124 modalitiesInStudy_.insert(tmp[i]);
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
125 }
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
126 }
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
127
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
128 virtual bool HasMainDicomTagsFilter(ResourceType level) const
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
129 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
130 if (DicomFindQuery::HasMainDicomTagsFilter(level))
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
131 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
132 return true;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
133 }
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
134
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
135 return (level == ResourceType_Study &&
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
136 hasModalitiesInStudy_);
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
137 }
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
138
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
139 virtual bool FilterMainDicomTags(const std::string& resourceId,
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
140 ResourceType level,
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
141 const DicomMap& mainTags) const
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
142 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
143 if (!DicomFindQuery::FilterMainDicomTags(resourceId, level, mainTags))
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
144 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
145 return false;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
146 }
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
147
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
148 if (level != ResourceType_Study ||
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
149 !hasModalitiesInStudy_)
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
150 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
151 return true;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
152 }
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
153
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
154 try
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
155 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
156 // We are considering a single study, and the
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
157 // "MODALITIES_IN_STUDY" tag is set in the C-Find. Check
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
158 // whether one of its child series matches one of the
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
159 // modalities.
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
160
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
161 Json::Value study;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
162 if (index_.LookupResource(study, resourceId, ResourceType_Study))
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
163 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
164 // Loop over the series of the considered study.
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
165 for (Json::Value::ArrayIndex j = 0; j < study["Series"].size(); j++)
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
166 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
167 Json::Value series;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
168 if (index_.LookupResource(series, study["Series"][j].asString(), ResourceType_Series))
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
169 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
170 // Get the modality of this series
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
171 if (series["MainDicomTags"].isMember("Modality"))
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
172 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
173 std::string modality = series["MainDicomTags"]["Modality"].asString();
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
174 if (modalitiesInStudy_.find(modality) != modalitiesInStudy_.end())
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
175 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
176 // This series of the considered study matches one
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
177 // of the required modalities. Take the study into
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
178 // consideration for future filtering.
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
179 return true;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
180 }
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
181 }
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
182 }
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
183 }
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
184 }
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
185 }
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
186 catch (OrthancException&)
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
187 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
188 // This resource has probably been deleted during the find request
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
189 }
612
fdd5f7f9c4d7 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 611
diff changeset
190
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
191 return false;
615
ec0b7a51d7bd speed up find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 612
diff changeset
192 }
ec0b7a51d7bd speed up find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 612
diff changeset
193
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
194 virtual bool HasInstanceFilter() const
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
195 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
196 return true;
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
197 }
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
198
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
199 virtual bool FilterInstance(const std::string& instanceId,
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
200 const Json::Value& content) const
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
201 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
202 bool ok = DicomFindQuery::FilterInstance(instanceId, content);
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
203
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
204 if (ok)
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
205 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
206 // Add this resource to the answers
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
207 AddAnswer(answers_, content, query_);
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
208 }
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
209
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
210 return ok;
615
ec0b7a51d7bd speed up find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 612
diff changeset
211 }
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
212 };
615
ec0b7a51d7bd speed up find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 612
diff changeset
213 }
ec0b7a51d7bd speed up find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 612
diff changeset
214
ec0b7a51d7bd speed up find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 612
diff changeset
215
941
83489fddd8c5 Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
216
83489fddd8c5 Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
217 bool OrthancFindRequestHandler::Handle(DicomFindAnswers& answers,
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
218 const DicomMap& input,
1573
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
219 const std::string& remoteIp,
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
220 const std::string& remoteAet)
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 {
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 /**
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
223 * Ensure that the calling modality is known to Orthanc.
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
224 **/
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
225
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
226 RemoteModalityParameters modality;
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
227
1573
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
228 if (!Configuration::LookupDicomModalityUsingAETitle(modality, remoteAet))
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
229 {
1582
bd1889029cbb encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
230 throw OrthancException(ErrorCode_UnknownModality);
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
231 }
806
557575fd93e9 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 795
diff changeset
232
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
233 // ModalityManufacturer manufacturer = modality.GetManufacturer();
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
234
1382
1cd2e09cb0e5 case insensitive search by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1374
diff changeset
235 bool caseSensitivePN = Configuration::GetGlobalBoolParameter("CaseSensitivePN", false);
1374
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
236
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
237
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
238 /**
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 * Retrieve the query level.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 **/
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL);
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 if (levelTmp == NULL)
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 {
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 throw OrthancException(ErrorCode_BadRequest);
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 }
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 ResourceType level = StringToResourceType(levelTmp->AsString().c_str());
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
250 if (level != ResourceType_Patient &&
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
251 level != ResourceType_Study &&
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
252 level != ResourceType_Series &&
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
253 level != ResourceType_Instance)
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 {
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
255 throw OrthancException(ErrorCode_NotImplemented);
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
256 }
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
257
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
258
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
259 DicomArray query(input);
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
260 LOG(INFO) << "DICOM C-Find request at level: " << EnumerationToString(level);
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
261
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
262 for (size_t i = 0; i < query.GetSize(); i++)
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
263 {
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
264 if (!query.GetElement(i).GetValue().IsNull())
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
265 {
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
266 LOG(INFO) << " " << query.GetElement(i).GetTag()
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
267 << " " << FromDcmtkBridge::GetName(query.GetElement(i).GetTag())
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
268 << " = " << query.GetElement(i).GetValue().AsString();
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
269 }
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 }
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 /**
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
274 * Build up the query object.
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
275 **/
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
276
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
277 CFindQuery findQuery(answers, context_.GetIndex(), query);
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
278 findQuery.SetLevel(level);
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
279
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
280 for (size_t i = 0; i < query.GetSize(); i++)
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
281 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
282 const DicomTag tag = query.GetElement(i).GetTag();
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
283
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
284 if (query.GetElement(i).GetValue().IsNull() ||
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
285 tag == DICOM_TAG_QUERY_RETRIEVE_LEVEL ||
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
286 tag == DICOM_TAG_SPECIFIC_CHARACTER_SET)
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
287 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
288 continue;
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
289 }
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
290
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
291 std::string value = query.GetElement(i).GetValue().AsString();
1429
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
292 if (value.size() == 0)
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
293 {
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
294 // An empty string corresponds to a "*" wildcard constraint, so we ignore it
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
295 continue;
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
296 }
611
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
297
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
298 if (tag == DICOM_TAG_MODALITIES_IN_STUDY)
611
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
299 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
300 findQuery.SetModalitiesInStudy(value);
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
301 }
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
302 else
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
303 {
1374
a1745d9be6e9 CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1361
diff changeset
304 findQuery.SetConstraint(tag, value, caseSensitivePN);
611
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
305 }
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
306 }
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
307
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
308
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
309 /**
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
310 * Run the query.
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 **/
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
313 ResourceFinder finder(context_);
1331
77e129ba64e4 Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
314
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
315 switch (level)
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
316 {
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
317 case ResourceType_Patient:
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
318 case ResourceType_Study:
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
319 case ResourceType_Series:
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
320 finder.SetMaxResults(maxResults_);
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
321 break;
941
83489fddd8c5 Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
322
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
323 case ResourceType_Instance:
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
324 finder.SetMaxResults(maxInstances_);
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
325 break;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
326
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
327 default:
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
328 throw OrthancException(ErrorCode_InternalError);
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 }
941
83489fddd8c5 Options to limit the number of results for an incoming C-FIND query
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
330
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
331 std::list<std::string> tmp;
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
332 bool finished = finder.Apply(tmp, findQuery);
1331
77e129ba64e4 Prevent freeze on C-FIND if no DICOM tag is to be returned
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
333
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
334 LOG(INFO) << "Number of matching resources: " << tmp.size();
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
335
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
336 return finished;
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 }
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 }