annotate OrthancServer/OrthancFindRequestHandler.cpp @ 2998:0a52af0c66e7

sharing strings
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Dec 2018 13:21:34 +0100
parents bbfd95a0c429
children 7695a9c81099
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
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1898
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
4 * Department, University Hospital of Liege, Belgium
2447
878b59270859 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2434
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * 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
8 * 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
9 * 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
10 * License, or (at your option) any later version.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * 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
13 * 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
14 * 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
15 * 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
16 * 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
17 * 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
18 * 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
19 * 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
20 * 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
21 * 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
22 * in the program, then also delete it here.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * 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
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * 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
30 * 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
31 **/
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
33
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
34 #include "PrecompiledHeadersServer.h"
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "OrthancFindRequestHandler.h"
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
1759
e268412adcf1 removal of old implementation of search
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1758
diff changeset
37 #include "../Core/DicomFormat/DicomArray.h"
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
38 #include "../Core/Lua/LuaFunctionCall.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
39 #include "../Core/Logging.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2335
diff changeset
40 #include "../Core/DicomParsing/FromDcmtkBridge.h"
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
41 #include "OrthancConfiguration.h"
1751
fb569ee09a69 LookupResource complete
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
42 #include "Search/LookupResource.h"
1759
e268412adcf1 removal of old implementation of search
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1758
diff changeset
43 #include "ServerToolbox.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 {
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
50 static void GetChildren(std::list<std::string>& target,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
51 ServerIndex& index,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
52 const std::list<std::string>& source)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
53 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
54 target.clear();
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
55
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
56 for (std::list<std::string>::const_iterator
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
57 it = source.begin(); it != source.end(); ++it)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
58 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
59 std::list<std::string> tmp;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
60 index.GetChildren(tmp, *it);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
61 target.splice(target.end(), tmp);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
62 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
63 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
64
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
65
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
66 static void StoreSetOfStrings(DicomMap& result,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
67 const DicomTag& tag,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
68 const std::set<std::string>& values)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
69 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
70 bool isFirst = true;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
71
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
72 std::string s;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
73 for (std::set<std::string>::const_iterator
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
74 it = values.begin(); it != values.end(); ++it)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
75 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
76 if (isFirst)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
77 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
78 isFirst = false;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
79 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
80 else
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
81 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
82 s += "\\";
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
83 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
84
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
85 s += *it;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
86 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
87
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
88 result.SetValue(tag, s, false);
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
89 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
90
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
91
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
92 static void ExtractTagFromMainDicomTags(std::set<std::string>& target,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
93 ServerIndex& index,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
94 const DicomTag& tag,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
95 const std::list<std::string>& resources,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
96 ResourceType level)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
97 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
98 for (std::list<std::string>::const_iterator
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
99 it = resources.begin(); it != resources.end(); ++it)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
100 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
101 DicomMap tags;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
102 if (index.GetMainDicomTags(tags, *it, level, level) &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
103 tags.HasTag(tag))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
104 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
105 target.insert(tags.GetValue(tag).GetContent());
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
106 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
107 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
108 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
109
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
110
2208
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
111 static bool ExtractMetadata(std::set<std::string>& target,
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
112 ServerIndex& index,
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
113 MetadataType metadata,
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
114 const std::list<std::string>& resources)
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
115 {
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
116 for (std::list<std::string>::const_iterator
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
117 it = resources.begin(); it != resources.end(); ++it)
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
118 {
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
119 std::string value;
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
120 if (index.LookupMetadata(value, *it, metadata))
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
121 {
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
122 target.insert(value);
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
123 }
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
124 else
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
125 {
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
126 // This metadata is unavailable for some resource, give up
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
127 return false;
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
128 }
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
129 }
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
130
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
131 return true;
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
132 }
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
133
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
134
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
135 static void ExtractTagFromInstancesOnDisk(std::set<std::string>& target,
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
136 ServerContext& context,
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
137 const DicomTag& tag,
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
138 const std::list<std::string>& instances)
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
139 {
2039
e33e0ae51d7b new configuration option AllowFindSopClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
140 // WARNING: This function is slow, as it reads the JSON file
e33e0ae51d7b new configuration option AllowFindSopClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
141 // summarizing each instance of interest from the hard drive.
e33e0ae51d7b new configuration option AllowFindSopClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
142
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
143 std::string formatted = tag.Format();
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
144
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
145 for (std::list<std::string>::const_iterator
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
146 it = instances.begin(); it != instances.end(); ++it)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
147 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
148 Json::Value dicom;
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
149 context.ReadDicomAsJson(dicom, *it);
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
150
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
151 if (dicom.isMember(formatted))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
152 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
153 const Json::Value& source = dicom[formatted];
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
154
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
155 if (source.type() == Json::objectValue &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
156 source.isMember("Type") &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
157 source.isMember("Value") &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
158 source["Type"].asString() == "String" &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
159 source["Value"].type() == Json::stringValue)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
160 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
161 target.insert(source["Value"].asString());
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
162 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
163 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
164 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
165 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
166
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
167
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
168 static void ComputePatientCounters(DicomMap& result,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
169 ServerIndex& index,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
170 const std::string& patient,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
171 const DicomMap& query)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
172 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
173 std::list<std::string> studies;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
174 index.GetChildren(studies, patient);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
175
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
176 if (query.HasTag(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
177 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
178 result.SetValue(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
179 boost::lexical_cast<std::string>(studies.size()), false);
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
180 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
181
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
182 if (!query.HasTag(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES) &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
183 !query.HasTag(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
184 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
185 return;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
186 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
187
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
188 std::list<std::string> series;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
189 GetChildren(series, index, studies);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
190 studies.clear(); // This information is useless below
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
191
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
192 if (query.HasTag(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
193 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
194 result.SetValue(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
195 boost::lexical_cast<std::string>(series.size()), false);
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
196 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
197
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
198 if (!query.HasTag(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
199 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
200 return;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
201 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
202
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
203 std::list<std::string> instances;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
204 GetChildren(instances, index, series);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
205
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
206 if (query.HasTag(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
207 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
208 result.SetValue(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
209 boost::lexical_cast<std::string>(instances.size()), false);
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
210 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
211 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
212
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
213
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
214 static void ComputeStudyCounters(DicomMap& result,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
215 ServerContext& context,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
216 const std::string& study,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
217 const DicomMap& query)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
218 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
219 ServerIndex& index = context.GetIndex();
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
220
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
221 std::list<std::string> series;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
222 index.GetChildren(series, study);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
223
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
224 if (query.HasTag(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
225 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
226 result.SetValue(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
227 boost::lexical_cast<std::string>(series.size()), false);
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
228 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
229
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
230 if (query.HasTag(DICOM_TAG_MODALITIES_IN_STUDY))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
231 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
232 std::set<std::string> values;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
233 ExtractTagFromMainDicomTags(values, index, DICOM_TAG_MODALITY, series, ResourceType_Series);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
234 StoreSetOfStrings(result, DICOM_TAG_MODALITIES_IN_STUDY, values);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
235 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
236
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
237 if (!query.HasTag(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES) &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
238 !query.HasTag(DICOM_TAG_SOP_CLASSES_IN_STUDY))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
239 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
240 return;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
241 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
242
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
243 std::list<std::string> instances;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
244 GetChildren(instances, index, series);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
245
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
246 if (query.HasTag(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
247 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
248 result.SetValue(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
249 boost::lexical_cast<std::string>(instances.size()), false);
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
250 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
251
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
252 if (query.HasTag(DICOM_TAG_SOP_CLASSES_IN_STUDY))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
253 {
2208
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
254 std::set<std::string> values;
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
255
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
256 if (ExtractMetadata(values, index, MetadataType_Instance_SopClassUid, instances))
2039
e33e0ae51d7b new configuration option AllowFindSopClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
257 {
2208
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
258 // The metadata "SopClassUid" is available for each of these instances
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
259 StoreSetOfStrings(result, DICOM_TAG_SOP_CLASSES_IN_STUDY, values);
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
260 }
2039
e33e0ae51d7b new configuration option AllowFindSopClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
261 else
e33e0ae51d7b new configuration option AllowFindSopClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
262 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
263 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
264
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
265 if (lock.GetConfiguration().GetBooleanParameter("AllowFindSopClassesInStudy", false))
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
266 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
267 ExtractTagFromInstancesOnDisk(values, context, DICOM_TAG_SOP_CLASS_UID, instances);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
268 StoreSetOfStrings(result, DICOM_TAG_SOP_CLASSES_IN_STUDY, values);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
269 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
270 else
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
271 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
272 result.SetValue(DICOM_TAG_SOP_CLASSES_IN_STUDY, "", false);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
273 LOG(WARNING) << "The handling of \"SOP Classes in Study\" (0008,0062) "
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
274 << "in C-FIND requests is disabled";
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
275 }
2039
e33e0ae51d7b new configuration option AllowFindSopClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
276 }
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
277 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
278 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
279
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
280
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
281 static void ComputeSeriesCounters(DicomMap& result,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
282 ServerIndex& index,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
283 const std::string& series,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
284 const DicomMap& query)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
285 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
286 std::list<std::string> instances;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
287 index.GetChildren(instances, series);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
288
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
289 if (query.HasTag(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
290 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
291 result.SetValue(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
292 boost::lexical_cast<std::string>(instances.size()), false);
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
293 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
294 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
295
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
296
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
297 static DicomMap* ComputeCounters(ServerContext& context,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
298 const std::string& instanceId,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
299 ResourceType level,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
300 const DicomMap& query)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
301 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
302 switch (level)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
303 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
304 case ResourceType_Patient:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
305 if (!query.HasTag(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES) &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
306 !query.HasTag(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES) &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
307 !query.HasTag(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
308 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
309 return NULL;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
310 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
311
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
312 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
313
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
314 case ResourceType_Study:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
315 if (!query.HasTag(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES) &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
316 !query.HasTag(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES) &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
317 !query.HasTag(DICOM_TAG_SOP_CLASSES_IN_STUDY) &&
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
318 !query.HasTag(DICOM_TAG_MODALITIES_IN_STUDY))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
319 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
320 return NULL;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
321 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
322
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
323 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
324
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
325 case ResourceType_Series:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
326 if (!query.HasTag(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
327 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
328 return NULL;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
329 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
330
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
331 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
332
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
333 default:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
334 return NULL;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
335 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
336
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
337 std::string parent;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
338 if (!context.GetIndex().LookupParent(parent, instanceId, level))
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
339 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
340 throw OrthancException(ErrorCode_UnknownResource); // The resource was deleted in between
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
341 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
342
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
343 std::auto_ptr<DicomMap> result(new DicomMap);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
344
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
345 switch (level)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
346 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
347 case ResourceType_Patient:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
348 ComputePatientCounters(*result, context.GetIndex(), parent, query);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
349 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
350
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
351 case ResourceType_Study:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
352 ComputeStudyCounters(*result, context, parent, query);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
353 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
354
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
355 case ResourceType_Series:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
356 ComputeSeriesCounters(*result, context.GetIndex(), parent, query);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
357 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
358
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
359 default:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
360 throw OrthancException(ErrorCode_InternalError);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
361 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
362
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
363 return result.release();
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
364 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
365
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
366
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
367 static void AddAnswer(DicomFindAnswers& answers,
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
368 const Json::Value& resource,
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
369 const DicomArray& query,
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
370 const std::list<DicomTag>& sequencesToReturn,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
371 const DicomMap* counters)
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
372 {
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
373 DicomMap result;
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
374
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
375 for (size_t i = 0; i < query.GetSize(); i++)
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
376 {
1346
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
377 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
378 {
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
379 // Fix issue 30 on Google Code (QR response missing "Query/Retrieve Level" (008,0052))
1346
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
380 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
381 }
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
382 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
383 {
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
384 // Do not include the encoding, this is handled by class ParsedDicomFile
1346
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
385 }
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
386 else
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
387 {
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
388 std::string tag = query.GetElement(i).GetTag().Format();
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
389 std::string value;
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
390 if (resource.isMember(tag))
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
391 {
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
392 value = resource.get(tag, Json::arrayValue).get("Value", "").asString();
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
393 result.SetValue(query.GetElement(i).GetTag(), value, false);
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
394 }
722
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
395 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
396 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
397 result.SetValue(query.GetElement(i).GetTag(), "", false);
722
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
398 }
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
399 }
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
400 }
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
401
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
402 if (counters != NULL)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
403 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
404 DicomArray tmp(*counters);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
405 for (size_t i = 0; i < tmp.GetSize(); i++)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
406 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
407 result.SetValue(tmp.GetElement(i).GetTag(), tmp.GetElement(i).GetValue().GetContent(), false);
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
408 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
409 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
410
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
411 if (result.GetSize() == 0 &&
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
412 sequencesToReturn.empty())
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
413 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
414 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
415 }
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
416 else if (sequencesToReturn.empty())
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
417 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
418 answers.Add(result);
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
419 }
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
420 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
421 {
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
422 ParsedDicomFile dicom(result);
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
423
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
424 for (std::list<DicomTag>::const_iterator tag = sequencesToReturn.begin();
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
425 tag != sequencesToReturn.end(); ++tag)
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
426 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
427 const Json::Value& source = resource[tag->Format()];
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
428
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
429 if (source.type() == Json::objectValue &&
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
430 source.isMember("Type") &&
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
431 source.isMember("Value") &&
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
432 source["Type"].asString() == "Sequence" &&
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
433 source["Value"].type() == Json::arrayValue)
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
434 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
435 Json::Value content = Json::arrayValue;
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
436
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
437 for (Json::Value::ArrayIndex i = 0; i < source["Value"].size(); i++)
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
438 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
439 Json::Value item;
2120
4b02ec79728a refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2115
diff changeset
440 ServerToolbox::SimplifyTags(item, source["Value"][i], DicomToJsonFormat_Short);
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
441 content.append(item);
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
442 }
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
443
1982
b5d4f9c156ad Modification of instances can now replace PixelData
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
444 dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent);
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
445 }
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
446 }
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
447
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
448 answers.Add(dicom);
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
449 }
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
450 }
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
451
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
452
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
453
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
454 bool OrthancFindRequestHandler::FilterQueryTag(std::string& value /* can be modified */,
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
455 ResourceType level,
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
456 const DicomTag& tag,
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
457 ModalityManufacturer manufacturer)
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
458 {
2335
174c3616ab6d code review
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2317
diff changeset
459 // Whatever the manufacturer, remove the GenericGroupLength tags
174c3616ab6d code review
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2317
diff changeset
460 // http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_7.2.html
174c3616ab6d code review
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2317
diff changeset
461 // https://bitbucket.org/sjodogne/orthanc/issues/31/
2434
63194107e61b fix issue 31 for good: removing group length correctly
amazy
parents: 2382
diff changeset
462 if (tag.GetElement() == 0x0000)
2317
5b7556568fa4 Incoming C-Find request: removing group-length for all manufacturer -> removed EFilm2 manufacturer that is now useless
amazy
parents: 2256
diff changeset
463 {
5b7556568fa4 Incoming C-Find request: removing group-length for all manufacturer -> removed EFilm2 manufacturer that is now useless
amazy
parents: 2256
diff changeset
464 return false;
5b7556568fa4 Incoming C-Find request: removing group-length for all manufacturer -> removed EFilm2 manufacturer that is now useless
amazy
parents: 2256
diff changeset
465 }
5b7556568fa4 Incoming C-Find request: removing group-length for all manufacturer -> removed EFilm2 manufacturer that is now useless
amazy
parents: 2256
diff changeset
466
1853
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
467 switch (manufacturer)
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
468 {
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
469 case ModalityManufacturer_Vitrea:
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
470 // Following Denis Nesterov's mail on 2015-11-30
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
471 if (tag == DicomTag(0x5653, 0x0010)) // "PrivateCreator = Vital Images SW 3.4"
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
472 {
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
473 return false;
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
474 }
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
475
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
476 break;
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
477
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
478 default:
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
479 break;
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
480 }
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
481
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
482 return true;
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
483 }
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
484
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
485
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
486 bool OrthancFindRequestHandler::ApplyLuaFilter(DicomMap& target,
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
487 const DicomMap& source,
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
488 const std::string& remoteIp,
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
489 const std::string& remoteAet,
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
490 const std::string& calledAet,
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
491 ModalityManufacturer manufacturer)
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
492 {
2221
e7beca979562 fix Windows build due to overwriting a macro
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2218
diff changeset
493 static const char* LUA_CALLBACK = "IncomingFindRequestFilter";
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
494
2617
912a767911b0 back to a single Lua context
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
495 LuaScripting::Lock lock(context_.GetLuaScripting());
912a767911b0 back to a single Lua context
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
496
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
497 if (!lock.GetLua().IsExistingFunction(LUA_CALLBACK))
2218
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
498 {
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
499 return false;
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
500 }
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
501 else
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
502 {
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
503 Json::Value origin;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
504 FormatOrigin(origin, remoteIp, remoteAet, calledAet, manufacturer);
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
505
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
506 LuaFunctionCall call(lock.GetLua(), LUA_CALLBACK);
2218
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
507 call.PushDicom(source);
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
508 call.PushJson(origin);
2218
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
509 FromDcmtkBridge::ExecuteToDicom(target, call);
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
510
2218
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
511 return true;
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
512 }
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
513 }
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
514
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
515
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
516 OrthancFindRequestHandler::OrthancFindRequestHandler(ServerContext& context) :
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
517 context_(context),
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
518 maxResults_(0),
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
519 maxInstances_(0)
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
520 {
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
521 }
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
522
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
523
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
524 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers,
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
525 const DicomMap& input,
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
526 const std::list<DicomTag>& sequencesToReturn,
1573
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
527 const std::string& remoteIp,
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1759
diff changeset
528 const std::string& remoteAet,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
529 const std::string& calledAet,
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
530 ModalityManufacturer manufacturer)
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 {
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 /**
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
533 * Possibly apply the user-supplied Lua filter.
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
534 **/
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
535
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
536 DicomMap lua;
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
537 const DicomMap* filteredInput = &input;
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
538
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
539 if (ApplyLuaFilter(lua, input, remoteIp, remoteAet, calledAet, manufacturer))
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
540 {
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
541 filteredInput = &lua;
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
542 }
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
543
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
544
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
545 /**
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 * Retrieve the query level.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 **/
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
549 assert(filteredInput != NULL);
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
550 const DicomValue* levelTmp = filteredInput->TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL);
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
551 if (levelTmp == NULL ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
552 levelTmp->IsNull() ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
553 levelTmp->IsBinary())
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
555 throw OrthancException(ErrorCode_BadRequest,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
556 "C-FIND request without the tag 0008,0052 (QueryRetrieveLevel)");
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 }
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
559 ResourceType level = StringToResourceType(levelTmp->GetContent().c_str());
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
561 if (level != ResourceType_Patient &&
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
562 level != ResourceType_Study &&
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
563 level != ResourceType_Series &&
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
564 level != ResourceType_Instance)
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 {
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
566 throw OrthancException(ErrorCode_NotImplemented);
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
567 }
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
568
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
569
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
570 DicomArray query(*filteredInput);
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
571 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
572
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
573 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
574 {
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
575 if (!query.GetElement(i).GetValue().IsNull())
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
576 {
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
577 LOG(INFO) << " " << query.GetElement(i).GetTag()
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
578 << " " << FromDcmtkBridge::GetTagName(query.GetElement(i))
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
579 << " = " << query.GetElement(i).GetValue().GetContent();
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
580 }
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 }
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
583 for (std::list<DicomTag>::const_iterator it = sequencesToReturn.begin();
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
584 it != sequencesToReturn.end(); ++it)
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
585 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
586 LOG(INFO) << " (" << it->Format()
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
587 << ") " << FromDcmtkBridge::GetTagName(*it, "")
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
588 << " : sequence tag whose content will be copied";
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
589 }
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
590
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 /**
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
593 * Build up the query object.
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
594 **/
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
595
2876
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
596 LookupResource lookup(level);
1759
e268412adcf1 removal of old implementation of search
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1758
diff changeset
597
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
598 bool caseSensitivePN;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
599
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
600 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
601 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
602 caseSensitivePN = lock.GetConfiguration().GetBooleanParameter("CaseSensitivePN", false);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
603 }
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
604
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
605 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
606 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
607 const DicomElement& element = query.GetElement(i);
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
608 const DicomTag tag = element.GetTag();
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
609
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
610 if (element.GetValue().IsNull() ||
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
611 tag == DICOM_TAG_QUERY_RETRIEVE_LEVEL ||
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
612 tag == DICOM_TAG_SPECIFIC_CHARACTER_SET)
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
613 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
614 continue;
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
615 }
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
616
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
617 std::string value = element.GetValue().GetContent();
1429
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
618 if (value.size() == 0)
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
619 {
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
620 // 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
621 continue;
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
622 }
611
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
623
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
624 if (FilterQueryTag(value, level, tag, manufacturer))
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
625 {
2892
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2876
diff changeset
626 // TODO - Move this to "ResourceLookup::AddDicomConstraint()"
ce310baccda6 DicomTagConstraint and DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2876
diff changeset
627
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
628 ValueRepresentation vr = FromDcmtkBridge::LookupValueRepresentation(tag);
1758
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1757
diff changeset
629
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
630 // DICOM specifies that searches must be case sensitive, except
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
631 // for tags with a PN value representation
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
632 bool sensitive = true;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
633 if (vr == ValueRepresentation_PersonName)
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
634 {
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
635 sensitive = caseSensitivePN;
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
636 }
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
637
2876
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
638 lookup.AddDicomConstraint(tag, value, sensitive);
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
639 }
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
640 else
1758
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1757
diff changeset
641 {
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
642 LOG(INFO) << "Because of a patch for the manufacturer of the remote modality, "
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
643 << "ignoring constraint on tag (" << tag.Format() << ") " << FromDcmtkBridge::GetTagName(element);
1759
e268412adcf1 removal of old implementation of search
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1758
diff changeset
644 }
611
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
645 }
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
646
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
647
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
648 /**
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
649 * Run the query.
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 **/
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651
2876
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
652 size_t limit = (level == ResourceType_Instance) ? maxInstances_ : maxResults_;
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
653
2876
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
654 // TODO - Use ServerContext::Apply() at this point, in order to
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
655 // share the code with the "/tools/find" REST URI
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
656 std::vector<std::string> resources, instances;
2876
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
657 context_.GetIndex().FindCandidates(resources, instances, lookup);
1752
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
658
2088
b9428d5f7eaf Fix serious performance issue with C-FIND
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2039
diff changeset
659 LOG(INFO) << "Number of candidate resources after fast DB filtering: " << resources.size();
b9428d5f7eaf Fix serious performance issue with C-FIND
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2039
diff changeset
660
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
661 assert(resources.size() == instances.size());
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
662 bool complete = true;
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
663
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
664 for (size_t i = 0; i < instances.size(); i++)
1752
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
665 {
2494
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
666 // TODO - Don't read the full JSON from the disk if only "main
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
667 // DICOM tags" are to be returned
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
668 Json::Value dicom;
2124
2b1520efa282 cleaning up
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2120
diff changeset
669 context_.ReadDicomAsJson(dicom, instances[i]);
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
670
2876
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
671 if (lookup.IsMatch(dicom))
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
672 {
2876
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
673 if (limit != 0 &&
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
674 answers.GetSize() >= limit)
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
675 {
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
676 complete = false;
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
677 break;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
678 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
679 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
680 {
2218
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
681 std::auto_ptr<DicomMap> counters(ComputeCounters(context_, instances[i], level, *filteredInput));
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
682 AddAnswer(answers, dicom, query, sequencesToReturn, counters.get());
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
683 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
684 }
1752
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
685 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1751
diff changeset
686
1753
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1752
diff changeset
687 LOG(INFO) << "Number of matching resources: " << answers.GetSize();
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
688
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
689 answers.SetComplete(complete);
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
690 }
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
691
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
692
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
693 void OrthancFindRequestHandler::FormatOrigin(Json::Value& origin,
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
694 const std::string& remoteIp,
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
695 const std::string& remoteAet,
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
696 const std::string& calledAet,
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
697 ModalityManufacturer manufacturer)
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
698 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
699 origin = Json::objectValue;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
700 origin["RemoteIp"] = remoteIp;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
701 origin["RemoteAet"] = remoteAet;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
702 origin["CalledAet"] = calledAet;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
703 origin["Manufacturer"] = EnumerationToString(manufacturer);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
704 }
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705 }