annotate OrthancServer/OrthancFindRequestHandler.cpp @ 4095:642b0947af84 zeiss-cirrus-investigations

temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
author Alain Mazy <alain@mazy.be>
date Tue, 30 Jun 2020 17:20:22 +0200
parents c6e82885f570
children
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
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3342
diff changeset
5 * Copyright (C) 2017-2020 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"
3094
61da3c9b4121 cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
38 #include "../Core/DicomParsing/FromDcmtkBridge.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
39 #include "../Core/Logging.h"
3094
61da3c9b4121 cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
40 #include "../Core/Lua/LuaFunctionCall.h"
3174
8ea7c4546c3a primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3163
diff changeset
41 #include "../Core/MetricsRegistry.h"
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
42 #include "OrthancConfiguration.h"
3094
61da3c9b4121 cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
43 #include "Search/DatabaseLookup.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3094
diff changeset
44 #include "ServerContext.h"
1759
e268412adcf1 removal of old implementation of search
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1758
diff changeset
45 #include "ServerToolbox.h"
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
46
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
47 #include <boost/regex.hpp>
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1429
diff changeset
48
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
49
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
50 namespace Orthanc
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
51 {
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
52 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
53 ServerIndex& index,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
54 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
55 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
56 target.clear();
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
57
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
58 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
59 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
60 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
61 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
62 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
63 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
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
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
67
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
68 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
69 const DicomTag& tag,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
70 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
71 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
72 bool isFirst = true;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
73
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
74 std::string s;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
75 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
76 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
77 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
78 if (isFirst)
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 isFirst = false;
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 else
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 s += "\\";
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
85 }
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 s += *it;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
88 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
89
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
90 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
91 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
92
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
93
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
94 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
95 ServerIndex& index,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
96 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
97 const DicomMap& query)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
98 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
99 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
100 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
101
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
102 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
103 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
104 result.SetValue(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
105 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
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 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
109 !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
110 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
111 return;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
112 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
113
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
114 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
115 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
116 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
117
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
118 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
119 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
120 result.SetValue(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
121 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
122 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
123
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
124 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
125 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
126 return;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
127 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
128
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
129 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
130 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
131
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
132 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
133 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
134 result.SetValue(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
135 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
136 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
137 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
138
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
139
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
140 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
141 ServerContext& context,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
142 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
143 const DicomMap& query)
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 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
146
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
147 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
148 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
149
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
150 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
151 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
152 result.SetValue(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
153 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
154 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
155
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
156 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
157 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
158 std::set<std::string> values;
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
159
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
160 for (std::list<std::string>::const_iterator
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
161 it = series.begin(); it != series.end(); ++it)
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
162 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
163 DicomMap tags;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
164 if (index.GetMainDicomTags(tags, *it, ResourceType_Series, ResourceType_Series))
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
165 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
166 const DicomValue* value = tags.TestAndGetValue(DICOM_TAG_MODALITY);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
167
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
168 if (value != NULL &&
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
169 !value->IsNull() &&
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
170 !value->IsBinary())
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
171 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
172 values.insert(value->GetContent());
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
173 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
174 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
175 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
176
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
177 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
178 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
179
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
180 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
181 !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
182 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
183 return;
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
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
186 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
187 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
188
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
189 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
190 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
191 result.SetValue(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
192 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
193 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
194
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
195 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
196 {
2208
90ea60bee5ff New metadata automatically computed at the instance level: "SopClassUid"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2124
diff changeset
197 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
198
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
199 for (std::list<std::string>::const_iterator
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
200 it = instances.begin(); it != instances.end(); ++it)
2039
e33e0ae51d7b new configuration option AllowFindSopClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
201 {
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
202 std::string value;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
203 if (context.LookupOrReconstructMetadata(value, *it, MetadataType_Instance_SopClassUid))
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
204 {
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
205 values.insert(value);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
206 }
2039
e33e0ae51d7b new configuration option AllowFindSopClassesInStudy
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
207 }
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
208
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
209 StoreSetOfStrings(result, DICOM_TAG_SOP_CLASSES_IN_STUDY, values);
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 ComputeSeriesCounters(DicomMap& result,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
215 ServerIndex& index,
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& series,
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 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
220 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
221
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
222 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
223 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
224 result.SetValue(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES,
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
225 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
226 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
227 }
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 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
231 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
232 ResourceType level,
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
233 const DicomMap& query)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
234 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
235 switch (level)
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 case ResourceType_Patient:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
238 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
239 !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
240 !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
241 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
242 return NULL;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
243 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
244
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
245 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
246
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
247 case ResourceType_Study:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
248 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
249 !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
250 !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
251 !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
252 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
253 return NULL;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
254 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
255
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
256 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
257
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
258 case ResourceType_Series:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
259 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
260 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
261 return NULL;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
262 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
263
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
264 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
265
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
266 default:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
267 return NULL;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
268 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
269
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
270 std::string parent;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
271 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
272 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
273 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
274 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
275
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
276 std::unique_ptr<DicomMap> result(new DicomMap);
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 switch (level)
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 case ResourceType_Patient:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
281 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
282 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
283
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
284 case ResourceType_Study:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
285 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
286 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
287
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
288 case ResourceType_Series:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
289 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
290 break;
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
291
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
292 default:
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
293 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
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 return result.release();
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
297 }
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
298
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
299
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
300 static void AddAnswer(DicomFindAnswers& answers,
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
301 const DicomMap& mainDicomTags,
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
302 const Json::Value* dicomAsJson,
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
303 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
304 const std::list<DicomTag>& sequencesToReturn,
4007
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
305 const DicomMap* counters,
4020
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
306 const std::string& defaultPrivateCreator,
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
307 const std::map<uint16_t, std::string>& privateCreators)
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
308 {
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
309 DicomMap match;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
310
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
311 if (dicomAsJson != NULL)
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
312 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
313 match.FromDicomAsJson(*dicomAsJson);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
314 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
315 else
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
316 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
317 match.Assign(mainDicomTags);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
318 }
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
319
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
320 DicomMap result;
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
321
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
322 for (size_t i = 0; i < query.GetSize(); i++)
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
323 {
1346
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
324 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
325 {
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
326 // 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
327 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
328 }
911a1ad5ebe8 re-fix issue 30
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1332
diff changeset
329 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
330 {
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
331 // 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
332 }
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
333 else
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
334 {
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
335 const DicomTag& tag = query.GetElement(i).GetTag();
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
336 const DicomValue* value = match.TestAndGetValue(tag);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
337
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
338 if (value != NULL &&
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
339 !value->IsNull() &&
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
340 !value->IsBinary())
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
341 {
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
342 result.SetValue(tag, value->GetContent(), false);
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
343 }
722
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
344 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
345 {
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
346 result.SetValue(tag, "", false);
722
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 716
diff changeset
347 }
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
348 }
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
349 }
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
350
1898
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
351 if (counters != NULL)
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
352 {
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
353 DicomArray tmp(*counters);
e018037d4d0e Support of optional tags for counting resources in C-Find
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1893
diff changeset
354 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
355 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
356 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
357 }
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
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
360 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
361 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
362 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
363 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
364 }
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
365 else if (sequencesToReturn.empty())
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
366 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
367 answers.Add(result);
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
368 }
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
369 else if (dicomAsJson == NULL)
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
370 {
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
371 LOG(WARNING) << "C-FIND query requesting a sequence, but reading JSON from disk is disabled";
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
372 answers.Add(result);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
373 }
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
374 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
375 {
4007
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
376 ParsedDicomFile dicom(result, GetDefaultDicomEncoding(),
4035
cc6ed76bba27 added contextual privateCreators dico to ParsedDicomFile -> this allows you not to have to define a DefaultPrivateCreator. This was tested only in the scope of C-Find requests but should not have impact on other parts since it is not used out of C-Find right now
Alain Mazy <alain@mazy.be>
parents: 4020
diff changeset
377 true /* be permissive, cf. issue #136 */, defaultPrivateCreator, privateCreators);
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
378
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
379 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
380 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
381 {
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
382 assert(dicomAsJson != NULL);
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
383 const Json::Value& source = (*dicomAsJson) [tag->Format()];
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
384
4095
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
385 // the options below were introduced during an investigation with Zeiss Cirrus software
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
386 // in order to reproduce exactly the same "weird" answers as a Zeiss server.
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
387 // Of course, this code should not remain as is. The Zeiss Cirrus Patch
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
388 // shall be implemented in a "lua callback" that would modify the response before it is sent.
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
389 // Note that, during these investigations, DefaultEncoding was set to "Utf8" and
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
390 // this line was modified in dimse.cc (DCMTK):
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
391 // E_EncodingType sequenceType_encoding = EET_UndefinedLength; // g_dimse_send_sequenceType_encoding;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
392 // and the following dictionnary was declared:
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
393 // "Dictionary" : {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
394 // "0407,10a1" : ["SQ", "OCT Cube Sequence", 1,1,"99CZM_CapeCod_OctGeneral" ],
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
395 // "0407,1005" : ["SQ", "OCT Cube Sequence2", 1, 1, "99CZM_CapeCod_OctGeneral" ],
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
396 // "0407,0010" : ["LO", "OCT Cube Sequence3", 1, 1, "99CZM_CapeCod_OctGeneral" ],
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
397 // "0407,1001" : ["US", "Undefined Private Tag 1001", 1, 1, "99CZM_CapeCod_OctGeneral" ],
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
398 // "0407,1002" : ["US", "Undefined Private Tag 1002", 1, 1, "99CZM_CapeCod_OctGeneral" ],
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
399 // "0407,1003" : ["US", "Undefined Private Tag 1003", 1, 1, "99CZM_CapeCod_OctGeneral" ],
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
400 // "0405,1001" : ["SH", "PatternType", 1, 1, "99CZM_CapeCod_OctSettings" ],
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
401 // "0405,101a" : ["FL", "SignalStrength", 1, 1, "99CZM_CapeCod_OctSettings" ]
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
402 // }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
403 bool addEmptySequences = false; // this could go into a "Manufacturer" option
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
404 bool zeissCirrusMinimumPatch = true; // investigations we tried and that are necessary for Cirrus to accept the response
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
405 if (zeissCirrusMinimumPatch)
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
406 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
407 addEmptySequences = true;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
408 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
409 bool zeissCirrusMaximumPatch = false; // investigations we tried but that finally do not seem necessary for Cirrus to accept the response (but that are required to get the same response as the Zeiss Server)
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
410
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
411 if ((source.type() == Json::objectValue &&
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
412 source.isMember("Type") &&
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
413 source.isMember("Value") &&
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
414 source["Type"].asString() == "Sequence" &&
4095
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
415 source["Value"].type() == Json::arrayValue) ||
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
416 (addEmptySequences && source.type() == Json::nullValue))
1859
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 Json::Value content = Json::arrayValue;
4095
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
419 bool replace = true;
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
420
4095
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
421 if (source.type() == Json::objectValue)
4011
914b15dedae3 fix for non private sequence tags in C-Find
Alain Mazy <alain@mazy.be>
parents: 4007
diff changeset
422 {
4095
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
423 for (Json::Value::ArrayIndex i = 0; i < source["Value"].size(); i++)
4020
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
424 {
4095
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
425 Json::Value item;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
426 ServerToolbox::SimplifyTags(item, source["Value"][i], DicomToJsonFormat_Short);
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
427 content.append(item);
4020
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
428 }
4011
914b15dedae3 fix for non private sequence tags in C-Find
Alain Mazy <alain@mazy.be>
parents: 4007
diff changeset
429 }
914b15dedae3 fix for non private sequence tags in C-Find
Alain Mazy <alain@mazy.be>
parents: 4007
diff changeset
430 else
914b15dedae3 fix for non private sequence tags in C-Find
Alain Mazy <alain@mazy.be>
parents: 4007
diff changeset
431 {
4095
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
432 LOG(INFO) << "inserting empty sequence for " << tag->Format();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
433
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
434 DcmDataset& dataset = *dicom.GetDcmtkObject().getDataset();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
435
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
436 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
437 std::unique_ptr<DcmSequenceOfItems> sequence;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
438
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
439 if (zeissCirrusMinimumPatch && tag->GetGroup() == 1031 && tag->GetElement() == 4257)
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
440 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
441 sequence.reset(new DcmSequenceOfItems(DcmTag(tag->GetGroup(), tag->GetElement(), "99CZM_CapeCod_OctGeneral")));
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
442
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
443 LOG(INFO) << "inserting first 4 empty elements into " << tag->Format();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
444 std::unique_ptr<DcmItem> item(new DcmItem(DcmTag(0xfffe, 0xe000)));
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
445 bool ok = false;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
446 ok = item->putAndInsertString(DcmTag(0x0407, 0x0010), "99CZM_CapeCod_OctGeneral").good();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
447 ok = item->insertEmptyElement(DcmTag(0x0407, 0x1001, "99CZM_CapeCod_OctGeneral")).good();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
448 ok = item->insertEmptyElement(DcmTag(0x0407, 0x1002, "99CZM_CapeCod_OctGeneral")).good();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
449 ok = item->insertEmptyElement(DcmTag(0x0407, 0x1003, "99CZM_CapeCod_OctGeneral")).good();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
450 ok = sequence->insert(item.release(), false, false).good();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
451 // LOG(INFO) << ok;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
452 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
453 else
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
454 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
455 sequence.reset(new DcmSequenceOfItems(DcmTagKey(tag->GetGroup(), tag->GetElement())));
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
456 std::unique_ptr<DcmItem> item;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
457 if (zeissCirrusMaximumPatch)
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
458 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
459 item.reset(new DcmItem(DcmTag(0xfffe, 0xe000)));
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
460 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
461 else
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
462 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
463 item.reset(new DcmItem);
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
464 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
465 bool ok = sequence->insert(item.release(), false, false).good();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
466 // LOG(INFO) << ok;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
467 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
468
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
469 bool ok3 = dataset.insert(sequence.release(), false, false).good();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
470 replace = false;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
471 // LOG(INFO) << ok3;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
472 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
473 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
474
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
475 if (zeissCirrusMaximumPatch && tag->GetGroup() == 1031 && tag->GetElement() == 4257 && content.size() > 0 && content[0].size() >= 4)
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
476 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
477 LOG(INFO) << "keeping only the first elements from " << tag->Format();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
478 Json::Value cloneContent = Json::Value();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
479
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
480 Json::Value::Members members = content[0].getMemberNames();
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
481 for (size_t i = 0; i < members.size(); i++)
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
482 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
483 const std::string& member = members[i];
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
484 cloneContent[0][member] = content[0][member];
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
485 Json::Value& v = cloneContent[0][member];
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
486 if (i == 3)
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
487 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
488 break;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
489 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
490 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
491 content = cloneContent;
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
492 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
493
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
494 if (replace)
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
495 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
496 if (tag->IsPrivate())
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
497 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
498 std::map<uint16_t, std::string>::const_iterator found = privateCreators.find(tag->GetGroup());
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
499
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
500 if (found != privateCreators.end())
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
501 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
502 dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, found->second.c_str());
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
503 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
504 else
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
505 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
506 dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator);
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
507 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
508 }
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
509 else
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
510 {
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
511 dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, "" /* no private creator */);
642b0947af84 temporarily modified the FindRequestHandler such that ZeissCirrus accepts the response from Orthanc. Work to be cleaned
Alain Mazy <alain@mazy.be>
parents: 4036
diff changeset
512 }
4011
914b15dedae3 fix for non private sequence tags in C-Find
Alain Mazy <alain@mazy.be>
parents: 4007
diff changeset
513 }
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
514 }
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
515 }
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
516
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
517 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
518 }
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
519 }
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
520
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
521
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
522
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
523 bool OrthancFindRequestHandler::FilterQueryTag(std::string& value /* can be modified */,
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
524 ResourceType level,
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
525 const DicomTag& tag,
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
526 ModalityManufacturer manufacturer)
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
527 {
2335
174c3616ab6d code review
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2317
diff changeset
528 // Whatever the manufacturer, remove the GenericGroupLength tags
174c3616ab6d code review
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2317
diff changeset
529 // 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
530 // https://bitbucket.org/sjodogne/orthanc/issues/31/
2434
63194107e61b fix issue 31 for good: removing group length correctly
amazy
parents: 2382
diff changeset
531 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
532 {
5b7556568fa4 Incoming C-Find request: removing group-length for all manufacturer -> removed EFilm2 manufacturer that is now useless
amazy
parents: 2256
diff changeset
533 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
534 }
5b7556568fa4 Incoming C-Find request: removing group-length for all manufacturer -> removed EFilm2 manufacturer that is now useless
amazy
parents: 2256
diff changeset
535
1853
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
536 switch (manufacturer)
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
537 {
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
538 case ModalityManufacturer_Vitrea:
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
539 // 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
540 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
541 {
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
542 return false;
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
543 }
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
544
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
545 break;
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
546
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
547 default:
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
548 break;
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
549 }
b7d3d3b182cf two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1851
diff changeset
550
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
551 return true;
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
552 }
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
553
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
554
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
555 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
556 const DicomMap& source,
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
557 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
558 const std::string& remoteAet,
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
559 const std::string& calledAet,
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
560 ModalityManufacturer manufacturer)
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
561 {
2221
e7beca979562 fix Windows build due to overwriting a macro
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2218
diff changeset
562 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
563
2617
912a767911b0 back to a single Lua context
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
564 LuaScripting::Lock lock(context_.GetLuaScripting());
912a767911b0 back to a single Lua context
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
565
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
566 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
567 {
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
568 return false;
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
569 }
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
570 else
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
571 {
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
572 Json::Value origin;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
573 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
574
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
575 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
576 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
577 call.PushJson(origin);
2218
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
578 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
579
2218
3eefb84ac0bd dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2208
diff changeset
580 return true;
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
581 }
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
582 }
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
583
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
584
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
585 OrthancFindRequestHandler::OrthancFindRequestHandler(ServerContext& context) :
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
586 context_(context),
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
587 maxResults_(0),
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
588 maxInstances_(0)
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
589 {
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
590 }
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
591
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2612
diff changeset
592
3021
2cbafb5d5a62 renamed LookupResource::IVisitor as ServerContext::ILookupVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3015
diff changeset
593 class OrthancFindRequestHandler::LookupVisitor : public ServerContext::ILookupVisitor
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
594 {
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
595 private:
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
596 DicomFindAnswers& answers_;
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
597 ServerContext& context_;
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
598 ResourceType level_;
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
599 const DicomMap& query_;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
600 DicomArray queryAsArray_;
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
601 const std::list<DicomTag>& sequencesToReturn_;
4020
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
602 std::string defaultPrivateCreator_; // the private creator to use if the group is not defined in the query itself
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
603 const std::map<uint16_t, std::string>& privateCreators_; // the private creators defined in the query itself
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
604
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
605 public:
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
606 LookupVisitor(DicomFindAnswers& answers,
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
607 ServerContext& context,
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
608 ResourceType level,
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
609 const DicomMap& query,
4020
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
610 const std::list<DicomTag>& sequencesToReturn,
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
611 const std::map<uint16_t, std::string>& privateCreators) :
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
612 answers_(answers),
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
613 context_(context),
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
614 level_(level),
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
615 query_(query),
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
616 queryAsArray_(query),
4020
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
617 sequencesToReturn_(sequencesToReturn),
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
618 privateCreators_(privateCreators)
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
619 {
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
620 answers_.SetComplete(false);
4007
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
621
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
622 {
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
623 OrthancConfiguration::ReaderLock lock;
4011
914b15dedae3 fix for non private sequence tags in C-Find
Alain Mazy <alain@mazy.be>
parents: 4007
diff changeset
624 defaultPrivateCreator_ = lock.GetConfiguration().GetDefaultPrivateCreator();
4007
884b55ce01f6 Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3712
diff changeset
625 }
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
626 }
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
627
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
628 virtual bool IsDicomAsJsonNeeded() const
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
629 {
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
630 // Ask the "DICOM-as-JSON" attachment only if sequences are to
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
631 // be returned OR if "query_" contains non-main DICOM tags!
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
632
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
633 DicomMap withoutSpecialTags;
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
634 withoutSpecialTags.Assign(query_);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
635
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
636 // Check out "ComputeCounters()"
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
637 withoutSpecialTags.Remove(DICOM_TAG_MODALITIES_IN_STUDY);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
638 withoutSpecialTags.Remove(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
639 withoutSpecialTags.Remove(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
640 withoutSpecialTags.Remove(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
641 withoutSpecialTags.Remove(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
642 withoutSpecialTags.Remove(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
643 withoutSpecialTags.Remove(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
644 withoutSpecialTags.Remove(DICOM_TAG_SOP_CLASSES_IN_STUDY);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
645
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
646 // Check out "AddAnswer()"
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
647 withoutSpecialTags.Remove(DICOM_TAG_SPECIFIC_CHARACTER_SET);
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
648 withoutSpecialTags.Remove(DICOM_TAG_QUERY_RETRIEVE_LEVEL);
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
649
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
650 return (!sequencesToReturn_.empty() ||
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
651 !withoutSpecialTags.HasOnlyMainDicomTags());
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
652 }
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
653
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
654 virtual void MarkAsComplete()
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
655 {
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
656 answers_.SetComplete(true);
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
657 }
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
658
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
659 virtual void Visit(const std::string& publicId,
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
660 const std::string& instanceId,
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
661 const DicomMap& mainDicomTags,
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
662 const Json::Value* dicomAsJson)
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
663 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
664 std::unique_ptr<DicomMap> counters(ComputeCounters(context_, instanceId, level_, query_));
3015
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
665
abe49ca61cd5 On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3012
diff changeset
666 AddAnswer(answers_, mainDicomTags, dicomAsJson,
4020
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
667 queryAsArray_, sequencesToReturn_, counters.get(), defaultPrivateCreator_, privateCreators_);
3003
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
668 }
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
669 };
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
670
5ae3ff2398e9 refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3001
diff changeset
671
1800
30e97a1f4093 callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
672 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers,
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
673 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
674 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
675 const std::string& remoteIp,
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1759
diff changeset
676 const std::string& remoteAet,
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
677 const std::string& calledAet,
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
678 ModalityManufacturer manufacturer)
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 {
3174
8ea7c4546c3a primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3163
diff changeset
680 MetricsRegistry::Timer timer(context_.GetMetricsRegistry(), "orthanc_find_scp_duration_ms");
8ea7c4546c3a primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3163
diff changeset
681
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 /**
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
683 * 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
684 **/
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
685
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
686 DicomMap lua;
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
687 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
688
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
689 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
690 {
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
691 filteredInput = &lua;
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
692 }
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
693
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
694
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
695 /**
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
696 * Retrieve the query level.
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
697 **/
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
699 assert(filteredInput != NULL);
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
700 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
701 if (levelTmp == NULL ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
702 levelTmp->IsNull() ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
703 levelTmp->IsBinary())
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
704 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
705 throw OrthancException(ErrorCode_BadRequest,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
706 "C-FIND request without the tag 0008,0052 (QueryRetrieveLevel)");
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707 }
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
709 ResourceType level = StringToResourceType(levelTmp->GetContent().c_str());
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
711 if (level != ResourceType_Patient &&
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
712 level != ResourceType_Study &&
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
713 level != ResourceType_Series &&
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
714 level != ResourceType_Instance)
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715 {
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
716 throw OrthancException(ErrorCode_NotImplemented);
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
717 }
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
718
665
41b3e5ccb291 fix for medInria
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 656
diff changeset
719
1888
512b6e76f531 Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1859
diff changeset
720 DicomArray query(*filteredInput);
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
721 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
722
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
723 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
724 {
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
725 if (!query.GetElement(i).GetValue().IsNull())
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
726 {
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
727 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
728 << " " << FromDcmtkBridge::GetTagName(query.GetElement(i))
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
729 << " = " << query.GetElement(i).GetValue().GetContent();
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
730 }
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 }
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732
1859
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
733 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
734 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
735 {
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
736 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
737 << ") " << 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
738 << " : 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
739 }
4e7c318a3f69 C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1856
diff changeset
740
4020
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
741 // collect the private creators from the query itself
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
742 std::map<uint16_t, std::string> privateCreators;
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
743 for (size_t i = 0; i < query.GetSize(); i++)
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
744 {
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
745 const DicomElement& element = query.GetElement(i);
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
746 if (element.GetTag().IsPrivate() && element.GetTag().GetElement() == 0x10)
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
747 {
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
748 privateCreators[element.GetTag().GetGroup()] = element.GetValue().GetContent();
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
749 }
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
750 }
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 /**
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
753 * Build up the query object.
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
754 **/
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
755
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
756 DatabaseLookup lookup;
1759
e268412adcf1 removal of old implementation of search
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1758
diff changeset
757
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
758 bool caseSensitivePN;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
759
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
760 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
761 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
762 caseSensitivePN = lock.GetConfiguration().GetBooleanParameter("CaseSensitivePN", false);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2892
diff changeset
763 }
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
764
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
765 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
766 {
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
767 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
768 const DicomTag tag = element.GetTag();
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
769
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
770 if (element.GetValue().IsNull() ||
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
771 tag == DICOM_TAG_QUERY_RETRIEVE_LEVEL ||
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
772 tag == DICOM_TAG_SPECIFIC_CHARACTER_SET)
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
773 {
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
774 continue;
714
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
775 }
6a1dbba0cca7 new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 690
diff changeset
776
2115
a657f7772e69 Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2088
diff changeset
777 std::string value = element.GetValue().GetContent();
1429
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
778 if (value.size() == 0)
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
779 {
3163
cf91b6f22278 Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3095
diff changeset
780 // An empty string corresponds to an universal constraint, so we ignore it
1429
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
781 continue;
7366a0bdda6a attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1383
diff changeset
782 }
611
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
783
2256
de1ba22fd28a simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
784 if (FilterQueryTag(value, level, tag, manufacturer))
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
785 {
2006
6301bbcbcaed more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
786 ValueRepresentation vr = FromDcmtkBridge::LookupValueRepresentation(tag);
1758
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1757
diff changeset
787
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
788 // DICOM specifies that searches must be case sensitive, except
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
789 // for tags with a PN value representation
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
790 bool sensitive = true;
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2006
diff changeset
791 if (vr == ValueRepresentation_PersonName)
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
792 {
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
793 sensitive = caseSensitivePN;
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
794 }
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
795
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
796 lookup.AddDicomConstraint(tag, value, sensitive, true /* mandatory */);
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
797 }
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
798 else
1758
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1757
diff changeset
799 {
1851
d364926389e0 OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1800
diff changeset
800 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
801 << "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
802 }
611
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
803 }
9924aec1d694 filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 610
diff changeset
804
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
805
608
0bedf8ff9288 basic find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 565
diff changeset
806 /**
1361
94ffb597d297 refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1354
diff changeset
807 * Run the query.
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 **/
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809
2876
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2827
diff changeset
810 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
811
3012
af1530b45290 Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3005
diff changeset
812
4020
320cde762fd9 collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents: 4011
diff changeset
813 LookupVisitor visitor(answers, context_, level, *filteredInput, sequencesToReturn, privateCreators);
3033
5da6d1063d8f effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3025
diff changeset
814 context_.Apply(visitor, lookup, level, 0 /* "since" is not relevant to C-FIND */, limit);
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 }
2827
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
816
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
817
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
818 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
819 const std::string& remoteIp,
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
820 const std::string& remoteAet,
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
821 const std::string& calledAet,
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
822 ModalityManufacturer manufacturer)
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
823 {
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
824 origin = Json::objectValue;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
825 origin["RemoteIp"] = remoteIp;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
826 origin["RemoteAet"] = remoteAet;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
827 origin["CalledAet"] = calledAet;
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
828 origin["Manufacturer"] = EnumerationToString(manufacturer);
d4fd4614f275 IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2617
diff changeset
829 }
565
c931ac02db82 refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 }