Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancFindRequestHandler.cpp @ 5752:717acb0ea546 find-refactoring
fix DICOMWeb integration tests
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 03 Sep 2024 16:37:31 +0200 |
parents | 359a8adb3802 |
children | 0c2f0d72d143 963945d780d6 |
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 | 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 |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5639
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5639
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5432
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * 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
|
10 * 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
|
11 * 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
|
12 * License, or (at your option) any later version. |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * 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
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * General Public License for more details. |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * 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
|
20 * 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
|
21 **/ |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
23 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
24 #include "PrecompiledHeadersServer.h" |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 #include "OrthancFindRequestHandler.h" |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
4045 | 27 #include "../../OrthancFramework/Sources/DicomFormat/DicomArray.h" |
28 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | |
29 #include "../../OrthancFramework/Sources/Logging.h" | |
30 #include "../../OrthancFramework/Sources/Lua/LuaFunctionCall.h" | |
31 #include "../../OrthancFramework/Sources/MetricsRegistry.h" | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2892
diff
changeset
|
32 #include "OrthancConfiguration.h" |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
33 #include "ResourceFinder.cpp" |
3094
61da3c9b4121
cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
34 #include "Search/DatabaseLookup.h" |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
35 #include "ServerContext.h" |
1759
e268412adcf1
removal of old implementation of search
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
36 #include "ServerToolbox.h" |
608 | 37 |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
38 #include <boost/regex.hpp> |
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
39 |
608 | 40 |
1361
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1354
diff
changeset
|
41 namespace Orthanc |
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1354
diff
changeset
|
42 { |
5698 | 43 static void CopySequence(ParsedDicomFile& dicom, |
44 const DicomTag& tag, | |
45 const Json::Value& source, | |
46 const std::string& defaultPrivateCreator, | |
47 const std::map<uint16_t, std::string>& privateCreators) | |
48 { | |
49 if (source.type() == Json::objectValue && | |
50 source.isMember("Type") && | |
51 source.isMember("Value") && | |
52 source["Type"].asString() == "Sequence" && | |
53 source["Value"].type() == Json::arrayValue) | |
54 { | |
55 Json::Value content = Json::arrayValue; | |
56 | |
57 for (Json::Value::ArrayIndex i = 0; i < source["Value"].size(); i++) | |
58 { | |
59 Json::Value item; | |
60 Toolbox::SimplifyDicomAsJson(item, source["Value"][i], DicomToJsonFormat_Short); | |
61 content.append(item); | |
62 } | |
63 | |
64 if (tag.IsPrivate()) | |
65 { | |
66 std::map<uint16_t, std::string>::const_iterator found = privateCreators.find(tag.GetGroup()); | |
67 | |
68 if (found != privateCreators.end()) | |
69 { | |
70 dicom.Replace(tag, content, false, DicomReplaceMode_InsertIfAbsent, found->second.c_str()); | |
71 } | |
72 else | |
73 { | |
74 dicom.Replace(tag, content, false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator); | |
75 } | |
76 } | |
77 else | |
78 { | |
79 dicom.Replace(tag, content, false, DicomReplaceMode_InsertIfAbsent, "" /* no private creator */); | |
80 } | |
81 } | |
82 } | |
83 | |
84 | |
608 | 85 static void AddAnswer(DicomFindAnswers& answers, |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
86 ServerContext& context, |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
87 const std::string& publicId, |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
88 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
|
89 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
|
90 const Json::Value* dicomAsJson, |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
91 ResourceType level, |
1859
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
92 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
|
93 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
|
94 const std::string& defaultPrivateCreator, |
4143
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
95 const std::map<uint16_t, std::string>& privateCreators, |
5058
d4e5ca0c9307
Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents:
4978
diff
changeset
|
96 const std::string& retrieveAet, |
d4e5ca0c9307
Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents:
4978
diff
changeset
|
97 bool allowStorageAccess) |
608 | 98 { |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
99 ExpandedResource resource; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
100 std::set<DicomTag> requestedTags; |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
101 |
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
102 query.GetTags(requestedTags); |
4978
2cfa50d8eb60
Speed-up handling of DicomModalitiesInStudy in C-Find and tools/find queries
Alain Mazy <am@osimis.io>
parents:
4940
diff
changeset
|
103 requestedTags.erase(DICOM_TAG_QUERY_RETRIEVE_LEVEL); // this is not part of the answer |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
104 |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
105 // reuse ExpandResource to get missing tags and computed tags (ModalitiesInStudy ...). This code is therefore shared between C-Find, tools/find, list-resources and QIDO-RS |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
106 context.ExpandResource(resource, publicId, mainDicomTags, instanceId, dicomAsJson, |
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
107 level, requestedTags, ExpandResourceFlags_IncludeMainDicomTags, allowStorageAccess); |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
108 |
608 | 109 DicomMap result; |
110 | |
4143
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
111 /** |
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
112 * Add the mandatory "Retrieve AE Title (0008,0054)" tag, which was missing in Orthanc <= 1.7.2. |
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
113 * http://dicom.nema.org/medical/dicom/current/output/html/part04.html#sect_C.4.1.1.3.2 |
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
114 * https://groups.google.com/g/orthanc-users/c/-7zNTKR_PMU/m/kfjwzEVNAgAJ |
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
115 **/ |
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
116 result.SetValue(DICOM_TAG_RETRIEVE_AE_TITLE, retrieveAet, false /* not binary */); |
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
117 |
608 | 118 for (size_t i = 0; i < query.GetSize(); i++) |
119 { | |
1346 | 120 if (query.GetElement(i).GetTag() == DICOM_TAG_QUERY_RETRIEVE_LEVEL) |
121 { | |
1859
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
122 // Fix issue 30 on Google Code (QR response missing "Query/Retrieve Level" (008,0052)) |
1346 | 123 result.SetValue(query.GetElement(i).GetTag(), query.GetElement(i).GetValue()); |
124 } | |
125 else if (query.GetElement(i).GetTag() == DICOM_TAG_SPECIFIC_CHARACTER_SET) | |
126 { | |
1859
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
127 // Do not include the encoding, this is handled by class ParsedDicomFile |
1346 | 128 } |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
129 else |
608 | 130 { |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
131 const DicomTag& tag = query.GetElement(i).GetTag(); |
5222
3a61fd50f804
starting refactoring ExpandedResource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
132 const DicomValue* value = resource.GetMainDicomTags().TestAndGetValue(tag); |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
133 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
134 if (value != NULL && |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
135 !value->IsNull() && |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
136 !value->IsBinary()) |
608 | 137 { |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
138 result.SetValue(tag, value->GetContent(), false); |
608 | 139 } |
722 | 140 else |
141 { | |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
142 result.SetValue(tag, "", false); |
722 | 143 } |
608 | 144 } |
145 } | |
146 | |
1859
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
147 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
|
148 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
|
149 { |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
150 CLOG(WARNING, DICOM) << "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
|
151 } |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
152 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
|
153 { |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
154 answers.Add(result); |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
155 } |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
156 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
|
157 { |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
158 CLOG(WARNING, DICOM) << "C-FIND query requesting a sequence, but reading JSON from disk is disabled"; |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
159 answers.Add(result); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
160 } |
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
|
161 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
|
162 { |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
163 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
|
164 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
|
165 |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
166 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
|
167 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
|
168 { |
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
|
169 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
|
170 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
|
171 |
5698 | 172 CopySequence(dicom, *tag, source, defaultPrivateCreator, privateCreators); |
1859
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
173 } |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
174 |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
175 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
|
176 } |
608 | 177 } |
178 | |
179 | |
1851
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
180 |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
181 bool OrthancFindRequestHandler::FilterQueryTag(std::string& value /* can be modified */, |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
182 ResourceType level, |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
183 const DicomTag& tag, |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
184 ModalityManufacturer manufacturer) |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
185 { |
2335 | 186 // Whatever the manufacturer, remove the GenericGroupLength tags |
187 // http://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_7.2.html | |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5222
diff
changeset
|
188 // https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=31 |
2434
63194107e61b
fix issue 31 for good: removing group length correctly
amazy
parents:
2382
diff
changeset
|
189 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
|
190 { |
5b7556568fa4
Incoming C-Find request: removing group-length for all manufacturer -> removed EFilm2 manufacturer that is now useless
amazy
parents:
2256
diff
changeset
|
191 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
|
192 } |
5b7556568fa4
Incoming C-Find request: removing group-length for all manufacturer -> removed EFilm2 manufacturer that is now useless
amazy
parents:
2256
diff
changeset
|
193 |
1853
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
194 switch (manufacturer) |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
195 { |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
196 case ModalityManufacturer_Vitrea: |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
197 // 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
|
198 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
|
199 { |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
200 return false; |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
201 } |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
202 |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
203 break; |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
204 |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
205 default: |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
206 break; |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
207 } |
b7d3d3b182cf
two patches for manufacturers Efilm and Vitrea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1851
diff
changeset
|
208 |
1851
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
209 return true; |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
210 } |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
211 |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
212 |
1888
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
213 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
|
214 const DicomMap& source, |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
215 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
|
216 const std::string& remoteAet, |
2827
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
217 const std::string& calledAet, |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
218 ModalityManufacturer manufacturer) |
1888
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
219 { |
2221
e7beca979562
fix Windows build due to overwriting a macro
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2218
diff
changeset
|
220 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
|
221 |
2617
912a767911b0
back to a single Lua context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
222 LuaScripting::Lock lock(context_.GetLuaScripting()); |
912a767911b0
back to a single Lua context
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
223 |
2616
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
224 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
|
225 { |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2208
diff
changeset
|
226 return false; |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2208
diff
changeset
|
227 } |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2208
diff
changeset
|
228 else |
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2208
diff
changeset
|
229 { |
2827
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
230 Json::Value origin; |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
231 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
|
232 |
2616
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
233 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
|
234 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
|
235 call.PushJson(origin); |
4105
c02a2d9efbc2
move FromDcmtkBridge::ExecuteToDicom() to LuaFunctionCall, to remove dependency of DCMTK on Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4055
diff
changeset
|
236 call.ExecuteToDicom(target); |
1888
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
237 |
2218
3eefb84ac0bd
dynamically fix outgoing C-Find requests using "OutgoingFindRequestFilter()"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2208
diff
changeset
|
238 return true; |
1888
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
239 } |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
240 } |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
241 |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
242 |
2616
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
243 OrthancFindRequestHandler::OrthancFindRequestHandler(ServerContext& context) : |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
244 context_(context), |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
245 maxResults_(0), |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
246 maxInstances_(0) |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
247 { |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
248 } |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
249 |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2612
diff
changeset
|
250 |
3021
2cbafb5d5a62
renamed LookupResource::IVisitor as ServerContext::ILookupVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3015
diff
changeset
|
251 class OrthancFindRequestHandler::LookupVisitor : public ServerContext::ILookupVisitor |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
252 { |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
253 private: |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
254 DicomFindAnswers& answers_; |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
255 ServerContext& context_; |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
256 ResourceType level_; |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
257 const DicomMap& query_; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
258 DicomArray queryAsArray_; |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
259 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
|
260 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
|
261 const std::map<uint16_t, std::string>& privateCreators_; // the private creators defined in the query itself |
4143
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
262 std::string retrieveAet_; |
5058
d4e5ca0c9307
Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents:
4978
diff
changeset
|
263 FindStorageAccessMode findStorageAccessMode_; |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
264 |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
265 public: |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
266 LookupVisitor(DicomFindAnswers& answers, |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
267 ServerContext& context, |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
268 ResourceType level, |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
269 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
|
270 const std::list<DicomTag>& sequencesToReturn, |
5058
d4e5ca0c9307
Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents:
4978
diff
changeset
|
271 const std::map<uint16_t, std::string>& privateCreators, |
d4e5ca0c9307
Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents:
4978
diff
changeset
|
272 FindStorageAccessMode findStorageAccessMode) : |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
273 answers_(answers), |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
274 context_(context), |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
275 level_(level), |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
276 query_(query), |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
277 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
|
278 sequencesToReturn_(sequencesToReturn), |
5058
d4e5ca0c9307
Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents:
4978
diff
changeset
|
279 privateCreators_(privateCreators), |
d4e5ca0c9307
Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents:
4978
diff
changeset
|
280 findStorageAccessMode_(findStorageAccessMode) |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
281 { |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
282 answers_.SetComplete(false); |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
283 |
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
284 { |
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
285 OrthancConfiguration::ReaderLock lock; |
4011
914b15dedae3
fix for non private sequence tags in C-Find
Alain Mazy <alain@mazy.be>
parents:
4007
diff
changeset
|
286 defaultPrivateCreator_ = lock.GetConfiguration().GetDefaultPrivateCreator(); |
4143
1ec3e1e18f50
Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4105
diff
changeset
|
287 retrieveAet_ = lock.GetConfiguration().GetOrthancAET(); |
4007
884b55ce01f6
Private tags returned by C-FIND SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
288 } |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
289 } |
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
|
290 |
4204 | 291 virtual bool IsDicomAsJsonNeeded() const ORTHANC_OVERRIDE |
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
|
292 { |
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
|
293 // 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
|
294 // 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
|
295 |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
296 DicomMap withoutSpecialTags; |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
297 withoutSpecialTags.Assign(query_); |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
298 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
299 // Check out "ComputeCounters()" |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
309 // Check out "AddAnswer()" |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
310 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
|
311 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
|
312 |
3015
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
313 return (!sequencesToReturn_.empty() || |
abe49ca61cd5
On C-FIND, avoid accessing the storage area whenever possible
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
314 !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
|
315 } |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
316 |
4204 | 317 virtual void MarkAsComplete() ORTHANC_OVERRIDE |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
318 { |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
319 answers_.SetComplete(true); |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
320 } |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
321 |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
322 virtual void Visit(const std::string& publicId, |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
323 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
|
324 const DicomMap& mainDicomTags, |
4204 | 325 const Json::Value* dicomAsJson) ORTHANC_OVERRIDE |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
326 { |
4940
304514ce84ee
tools/find + C-Find + list-resources now all using the same code (ExpandResource) to build 'computed tags'
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
327 AddAnswer(answers_, context_, publicId, instanceId, mainDicomTags, dicomAsJson, level_, queryAsArray_, sequencesToReturn_, |
5058
d4e5ca0c9307
Fix the "Never" option of the "StorageAccessOnFind" that was sill accessing files (bug introduced in 1.11.0)
Alain Mazy <am@osimis.io>
parents:
4978
diff
changeset
|
328 defaultPrivateCreator_, privateCreators_, retrieveAet_, IsStorageAccessAllowedForAnswers(findStorageAccessMode_)); |
3003
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
329 } |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
330 }; |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
331 |
5ae3ff2398e9
refactoring OrthancFindRequestHandler using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3001
diff
changeset
|
332 |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
333 namespace |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
334 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
335 class LookupVisitorV2 : public ResourceFinder::IVisitor |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
336 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
337 private: |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
338 DicomFindAnswers& answers_; |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
339 DicomArray queryAsArray_; |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
340 const std::list<DicomTag>& sequencesToReturn_; |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
341 std::string defaultPrivateCreator_; // the private creator to use if the group is not defined in the query itself |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
342 const std::map<uint16_t, std::string>& privateCreators_; // the private creators defined in the query itself |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
343 std::string retrieveAet_; |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
344 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
345 public: |
5700
1fab9ddaf702
webdav using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5699
diff
changeset
|
346 LookupVisitorV2(DicomFindAnswers& answers, |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
347 const DicomMap& query, |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
348 const std::list<DicomTag>& sequencesToReturn, |
5700
1fab9ddaf702
webdav using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5699
diff
changeset
|
349 const std::map<uint16_t, std::string>& privateCreators) : |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
350 answers_(answers), |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
351 queryAsArray_(query), |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
352 sequencesToReturn_(sequencesToReturn), |
5700
1fab9ddaf702
webdav using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5699
diff
changeset
|
353 privateCreators_(privateCreators) |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
354 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
355 answers_.SetComplete(false); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
356 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
357 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
358 OrthancConfiguration::ReaderLock lock; |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
359 defaultPrivateCreator_ = lock.GetConfiguration().GetDefaultPrivateCreator(); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
360 retrieveAet_ = lock.GetConfiguration().GetOrthancAET(); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
361 } |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
362 } |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
363 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
364 virtual void Apply(const FindResponse::Resource& resource, |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
365 const DicomMap& requestedTags) ORTHANC_OVERRIDE |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
366 { |
5698 | 367 DicomMap resourceTags; |
368 resource.GetAllMainDicomTags(resourceTags); | |
369 resourceTags.Merge(requestedTags); | |
370 | |
371 DicomMap result; | |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
372 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
373 /** |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
374 * Add the mandatory "Retrieve AE Title (0008,0054)" tag, which was missing in Orthanc <= 1.7.2. |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
375 * http://dicom.nema.org/medical/dicom/current/output/html/part04.html#sect_C.4.1.1.3.2 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
376 * https://groups.google.com/g/orthanc-users/c/-7zNTKR_PMU/m/kfjwzEVNAgAJ |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
377 **/ |
5698 | 378 result.SetValue(DICOM_TAG_RETRIEVE_AE_TITLE, retrieveAet_, false /* not binary */); |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
379 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
380 for (size_t i = 0; i < queryAsArray_.GetSize(); i++) |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
381 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
382 const DicomTag tag = queryAsArray_.GetElement(i).GetTag(); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
383 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
384 if (tag == DICOM_TAG_QUERY_RETRIEVE_LEVEL) |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
385 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
386 // Fix issue 30 on Google Code (QR response missing "Query/Retrieve Level" (008,0052)) |
5698 | 387 result.SetValue(tag, queryAsArray_.GetElement(i).GetValue()); |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
388 } |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
389 else if (tag == DICOM_TAG_SPECIFIC_CHARACTER_SET) |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
390 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
391 // Do not include the encoding, this is handled by class ParsedDicomFile |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
392 } |
5698 | 393 else |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
394 { |
5698 | 395 const DicomValue* value = resourceTags.TestAndGetValue(tag); |
396 | |
397 if (value == NULL || | |
398 value->IsNull() || | |
399 value->IsBinary()) | |
400 { | |
401 result.SetValue(tag, "", false); | |
402 } | |
403 else | |
404 { | |
405 result.SetValue(tag, value->GetContent(), false); | |
406 } | |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
407 } |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
408 } |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
409 |
5698 | 410 if (result.GetSize() == 0 && |
411 sequencesToReturn_.empty()) | |
412 { | |
413 CLOG(WARNING, DICOM) << "The C-FIND request does not return any DICOM tag"; | |
414 } | |
415 else if (sequencesToReturn_.empty()) | |
416 { | |
417 answers_.Add(result); | |
418 } | |
419 else | |
420 { | |
421 ParsedDicomFile dicom(result, GetDefaultDicomEncoding(), | |
422 true /* be permissive, cf. issue #136 */, defaultPrivateCreator_, privateCreators_); | |
423 | |
424 for (std::list<DicomTag>::const_iterator tag = sequencesToReturn_.begin(); | |
425 tag != sequencesToReturn_.end(); ++tag) | |
426 { | |
427 const DicomValue* value = resourceTags.TestAndGetValue(*tag); | |
428 if (value != NULL && | |
429 value->IsSequence()) | |
430 { | |
431 CopySequence(dicom, *tag, value->GetSequenceContent(), defaultPrivateCreator_, privateCreators_); | |
432 } | |
433 else | |
434 { | |
435 dicom.Replace(*tag, std::string(""), false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator_); | |
436 } | |
437 } | |
438 | |
439 answers_.Add(dicom); | |
440 } | |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
441 } |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
442 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
443 virtual void MarkAsComplete() ORTHANC_OVERRIDE |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
444 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
445 answers_.SetComplete(true); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
446 } |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
447 }; |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
448 } |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
449 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
450 |
1800
30e97a1f4093
callback for handling worklists with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1799
diff
changeset
|
451 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers, |
665 | 452 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
|
453 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
|
454 const std::string& remoteIp, |
1799
4f01c9d73f02
calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1759
diff
changeset
|
455 const std::string& remoteAet, |
2256
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
456 const std::string& calledAet, |
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
457 ModalityManufacturer manufacturer) |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 { |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
459 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
|
460 |
4482
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
461 |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
462 /** |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
463 * Deal with global configuration |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
464 **/ |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
465 |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
466 bool caseSensitivePN; |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
467 |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
468 { |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
469 OrthancConfiguration::ReaderLock lock; |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
470 caseSensitivePN = lock.GetConfiguration().GetBooleanParameter("CaseSensitivePN", false); |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
471 |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
472 RemoteModalityParameters remote; |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
473 if (!lock.GetConfiguration().LookupDicomModalityUsingAETitle(remote, remoteAet)) |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
474 { |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
475 if (lock.GetConfiguration().GetBooleanParameter("DicomAlwaysAllowFind", false)) |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
476 { |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
477 CLOG(INFO, DICOM) << "C-FIND: Allowing SCU request from unknown modality with AET: " << remoteAet; |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
478 } |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
479 else |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
480 { |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
481 // This should never happen, given the test at bottom of |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
482 // "OrthancApplicationEntityFilter::IsAllowedRequest()" |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
483 throw OrthancException(ErrorCode_InexistentItem, |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
484 "C-FIND: Rejecting SCU request from unknown modality with AET: " + remoteAet); |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
485 } |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
486 } |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
487 } |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
488 |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
489 |
8efeaba1b7f9
new configuration options: "DicomAlwaysAllowFind" and "DicomAlwaysAllowGet"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4476
diff
changeset
|
490 |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 /** |
1888
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
492 * 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
|
493 **/ |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
494 |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
495 DicomMap lua; |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
496 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
|
497 |
2827
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
498 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
|
499 { |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
500 filteredInput = &lua; |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
501 } |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
502 |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
503 |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
504 /** |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 * Retrieve the query level. |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 **/ |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 |
1888
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
508 assert(filteredInput != NULL); |
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
509 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
|
510 if (levelTmp == NULL || |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
511 levelTmp->IsNull() || |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
512 levelTmp->IsBinary()) |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 { |
2955 | 514 throw OrthancException(ErrorCode_BadRequest, |
515 "C-FIND request without the tag 0008,0052 (QueryRetrieveLevel)"); | |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
516 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
518 ResourceType level = StringToResourceType(levelTmp->GetContent().c_str()); |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 |
714
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
520 if (level != ResourceType_Patient && |
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
521 level != ResourceType_Study && |
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
522 level != ResourceType_Series && |
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
523 level != ResourceType_Instance) |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 { |
714
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
525 throw OrthancException(ErrorCode_NotImplemented); |
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
526 } |
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
527 |
1888
512b6e76f531
Lua: "IncomingFindRequestFilter()" to apply filters to incoming C-Find requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1859
diff
changeset
|
528 DicomArray query(*filteredInput); |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
529 CLOG(INFO, DICOM) << "DICOM C-Find request at level: " << EnumerationToString(level); |
714
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
530 |
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
531 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
|
532 { |
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
533 if (!query.GetElement(i).GetValue().IsNull()) |
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
534 { |
4313
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4287
diff
changeset
|
535 CLOG(INFO, DICOM) << " (" << query.GetElement(i).GetTag().Format() |
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4287
diff
changeset
|
536 << ") " << FromDcmtkBridge::GetTagName(query.GetElement(i)) |
4376
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
537 << " = " << context_.GetDeidentifiedContent(query.GetElement(i)); |
714
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
538 } |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
541 std::set<DicomTag> requestedTags; |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
542 |
1859
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
543 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
|
544 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
|
545 { |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
546 requestedTags.insert(*it); |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
547 CLOG(INFO, DICOM) << " (" << it->Format() |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
548 << ") " << FromDcmtkBridge::GetTagName(*it, "") |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
549 << " : sequence tag whose content will be copied"; |
1859
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
550 } |
4e7c318a3f69
C-FIND SCP will return tags with sequence value representation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1856
diff
changeset
|
551 |
4020
320cde762fd9
collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents:
4011
diff
changeset
|
552 // 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
|
553 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
|
554 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
|
555 { |
320cde762fd9
collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents:
4011
diff
changeset
|
556 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
|
557 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
|
558 { |
320cde762fd9
collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents:
4011
diff
changeset
|
559 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
|
560 } |
320cde762fd9
collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
Alain Mazy <alain@mazy.be>
parents:
4011
diff
changeset
|
561 } |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 /** |
1361
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1354
diff
changeset
|
564 * Build up the query object. |
608 | 565 **/ |
566 | |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3025
diff
changeset
|
567 DatabaseLookup lookup; |
1759
e268412adcf1
removal of old implementation of search
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
568 |
1361
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1354
diff
changeset
|
569 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
|
570 { |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2088
diff
changeset
|
571 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
|
572 const DicomTag tag = element.GetTag(); |
714
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
573 |
5639
b6a6179a2a69
TimezoneOffsetFromUTC is now ignored for C-Find matching
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
574 // remove tags that are not used for matching |
5699
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
575 if (tag == DICOM_TAG_QUERY_RETRIEVE_LEVEL || |
5639
b6a6179a2a69
TimezoneOffsetFromUTC is now ignored for C-Find matching
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
576 tag == DICOM_TAG_SPECIFIC_CHARACTER_SET || |
b6a6179a2a69
TimezoneOffsetFromUTC is now ignored for C-Find matching
Alain Mazy <am@orthanc.team>
parents:
5485
diff
changeset
|
577 tag == DICOM_TAG_TIMEZONE_OFFSET_FROM_UTC) // time zone is not directly used for matching. Once we support "Timezone query adjustment", we may use it to adjust date-time filters but for now, just ignore it |
714
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
578 { |
1361
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1354
diff
changeset
|
579 continue; |
714
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
580 } |
6a1dbba0cca7
new implementation of C-Find handler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
690
diff
changeset
|
581 |
5699
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
582 requestedTags.insert(tag); |
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
583 |
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
584 if (element.GetValue().IsNull()) |
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
585 { |
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
586 // There is no constraint on this tag |
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
587 continue; |
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
588 } |
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
589 |
2115
a657f7772e69
Handling of private tags/creators in the "Dictionary" configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2088
diff
changeset
|
590 std::string value = element.GetValue().GetContent(); |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1383
diff
changeset
|
591 if (value.size() == 0) |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1383
diff
changeset
|
592 { |
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
|
593 // An empty string corresponds to an universal constraint, so we ignore it |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
594 requestedTags.insert(tag); |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1383
diff
changeset
|
595 continue; |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1383
diff
changeset
|
596 } |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
597 |
2256
de1ba22fd28a
simplification wrt. modality manufacturers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
598 if (FilterQueryTag(value, level, tag, manufacturer)) |
1851
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
599 { |
2006
6301bbcbcaed
more generic support of value representations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1982
diff
changeset
|
600 ValueRepresentation vr = FromDcmtkBridge::LookupValueRepresentation(tag); |
1758 | 601 |
1851
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
602 // DICOM specifies that searches must be case sensitive, except |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
603 // for tags with a PN value representation |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
604 bool sensitive = true; |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
605 if (vr == ValueRepresentation_PersonName) |
1851
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
606 { |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
607 sensitive = caseSensitivePN; |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
608 } |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
609 |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3025
diff
changeset
|
610 lookup.AddDicomConstraint(tag, value, sensitive, true /* mandatory */); |
1851
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
611 } |
d364926389e0
OrthancFindRequestHandler::FilterQueryTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1800
diff
changeset
|
612 else |
1758 | 613 { |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
614 CLOG(INFO, DICOM) << "Because of a patch for the manufacturer of the remote modality, " |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
615 << "ignoring constraint on tag (" << tag.Format() << ") " |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4204
diff
changeset
|
616 << FromDcmtkBridge::GetTagName(element); |
1759
e268412adcf1
removal of old implementation of search
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1758
diff
changeset
|
617 } |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
618 } |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
619 |
1361
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1354
diff
changeset
|
620 |
608 | 621 /** |
1361
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1354
diff
changeset
|
622 * Run the query. |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 **/ |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 |
2876 | 625 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
|
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 |
5699
e8e028aed89f
c-find tests pass using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5698
diff
changeset
|
628 if (true) |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
629 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
630 /** |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
631 * EXPERIMENTAL VERSION |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
632 **/ |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
633 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
634 ResourceFinder finder(level, false /* don't expand */); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
635 finder.SetDatabaseLookup(lookup); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
636 finder.AddRequestedTags(requestedTags); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
637 |
5700
1fab9ddaf702
webdav using ResourceFinder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5699
diff
changeset
|
638 LookupVisitorV2 visitor(answers, *filteredInput, sequencesToReturn, privateCreators); |
5696
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
639 finder.Execute(visitor, context_); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
640 } |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
641 else |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
642 { |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
643 /** |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
644 * VERSION IN ORTHANC <= 1.12.4 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
645 **/ |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
646 |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
647 LookupVisitor visitor(answers, context_, level, *filteredInput, sequencesToReturn, privateCreators, context_.GetFindStorageAccessMode()); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
648 context_.Apply(visitor, lookup, level, 0 /* "since" is not relevant to C-FIND */, limit); |
0f8b6214308a
preparing to use ResourceFinder in OrthancFindRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5640
diff
changeset
|
649 } |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 } |
2827
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
651 |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
652 |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
653 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
|
654 const std::string& remoteIp, |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
655 const std::string& remoteAet, |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
656 const std::string& calledAet, |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
657 ModalityManufacturer manufacturer) |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
658 { |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
659 origin = Json::objectValue; |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
660 origin["RemoteIp"] = remoteIp; |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
661 origin["RemoteAet"] = remoteAet; |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
662 origin["CalledAet"] = calledAet; |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
663 origin["Manufacturer"] = EnumerationToString(manufacturer); |
d4fd4614f275
IncomingWorklistRequestFilter() to filter incoming C-FIND worklist queries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2617
diff
changeset
|
664 } |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
665 } |