Mercurial > hg > orthanc
annotate OrthancServer/DicomProtocol/DicomUserConnection.cpp @ 1927:b60f27664b8f
simplification in FromDcmtkBridge
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Mar 2016 13:31:56 +0100 |
parents | 5011a597b6ce |
children | 84c7eaeb5244 |
rev | line source |
---|---|
0 | 1 /** |
62 | 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:
1285
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
0 | 5 * |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
136 | 10 * |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
0 | 22 * |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
766
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
33 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
34 /*========================================================================= |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
35 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
36 This file is based on portions of the following project: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
37 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
38 Program: DCMTK 3.6.0 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
39 Module: http://dicom.offis.de/dcmtk.php.en |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
40 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
41 Copyright (C) 1994-2011, OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
42 All rights reserved. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
43 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
44 This software and supporting documentation were developed by |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
45 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
46 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
47 R&D Division Health |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
48 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
49 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
50 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
51 Redistribution and use in source and binary forms, with or without |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
52 modification, are permitted provided that the following conditions |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
53 are met: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
54 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
55 - Redistributions of source code must retain the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
56 notice, this list of conditions and the following disclaimer. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
57 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
58 - Redistributions in binary form must reproduce the above copyright |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
59 notice, this list of conditions and the following disclaimer in the |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
60 documentation and/or other materials provided with the distribution. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
61 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
62 - Neither the name of OFFIS nor the names of its contributors may be |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
63 used to endorse or promote products derived from this software |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
64 without specific prior written permission. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
65 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
66 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
67 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
68 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
69 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
70 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
71 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
72 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
73 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
74 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
75 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
76 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
77 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
78 =========================================================================*/ |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
79 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
80 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
81 #include "../PrecompiledHeadersServer.h" |
0 | 82 #include "DicomUserConnection.h" |
83 | |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
84 #include "../../Core/DicomFormat/DicomArray.h" |
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
85 #include "../../Core/Logging.h" |
62 | 86 #include "../../Core/OrthancException.h" |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
87 #include "../FromDcmtkBridge.h" |
0 | 88 #include "../ToDcmtkBridge.h" |
89 | |
90 #include <dcmtk/dcmdata/dcistrmb.h> | |
91 #include <dcmtk/dcmdata/dcistrmf.h> | |
92 #include <dcmtk/dcmdata/dcfilefo.h> | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
93 #include <dcmtk/dcmdata/dcmetinf.h> |
0 | 94 #include <dcmtk/dcmnet/diutil.h> |
95 | |
96 #include <set> | |
97 | |
98 | |
99 #ifdef _WIN32 | |
100 /** | |
101 * "The maximum length, in bytes, of the string returned in the buffer | |
102 * pointed to by the name parameter is dependent on the namespace provider, | |
103 * but this string must be 256 bytes or less. | |
104 * http://msdn.microsoft.com/en-us/library/windows/desktop/ms738527(v=vs.85).aspx | |
105 **/ | |
106 #define HOST_NAME_MAX 256 | |
107 #endif | |
108 | |
109 | |
918 | 110 #if !defined(HOST_NAME_MAX) && defined(_POSIX_HOST_NAME_MAX) |
890 | 111 /** |
112 * TO IMPROVE: "_POSIX_HOST_NAME_MAX is only the minimum value that | |
113 * HOST_NAME_MAX can ever have [...] Therefore you cannot allocate an | |
114 * array of size _POSIX_HOST_NAME_MAX, invoke gethostname() and expect | |
115 * that the result will fit." | |
116 * http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00128.html | |
117 **/ | |
118 #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX | |
119 #endif | |
120 | |
121 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
122 static const char* DEFAULT_PREFERRED_TRANSFER_SYNTAX = UID_LittleEndianImplicitTransferSyntax; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
123 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
124 /** |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
125 * "If we have more than 64 storage SOP classes, tools such as |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
126 * storescu will fail because they attempt to negotiate two |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
127 * presentation contexts for each SOP class, and there is a total |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
128 * limit of 128 contexts for one association." |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
129 **/ |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
130 static const unsigned int MAXIMUM_STORAGE_SOP_CLASSES = 64; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
131 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
132 |
62 | 133 namespace Orthanc |
0 | 134 { |
135 struct DicomUserConnection::PImpl | |
136 { | |
137 // Connection state | |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
138 uint32_t dimseTimeout_; |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
139 uint32_t acseTimeout_; |
0 | 140 T_ASC_Network* net_; |
141 T_ASC_Parameters* params_; | |
142 T_ASC_Association* assoc_; | |
143 | |
144 bool IsOpen() const | |
145 { | |
146 return assoc_ != NULL; | |
147 } | |
148 | |
149 void CheckIsOpen() const; | |
150 | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
151 void Store(DcmInputStream& is, |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
152 DicomUserConnection& connection, |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
153 uint16_t moveMessageID); |
0 | 154 }; |
155 | |
156 | |
157 static void Check(const OFCondition& cond) | |
158 { | |
159 if (cond.bad()) | |
160 { | |
1017 | 161 LOG(ERROR) << "DicomUserConnection: " << std::string(cond.text()); |
162 throw OrthancException(ErrorCode_NetworkProtocol); | |
0 | 163 } |
164 } | |
165 | |
166 void DicomUserConnection::PImpl::CheckIsOpen() const | |
167 { | |
168 if (!IsOpen()) | |
169 { | |
1017 | 170 LOG(ERROR) << "DicomUserConnection: First open the connection"; |
171 throw OrthancException(ErrorCode_NetworkProtocol); | |
0 | 172 } |
173 } | |
174 | |
175 | |
176 void DicomUserConnection::CheckIsOpen() const | |
177 { | |
178 pimpl_->CheckIsOpen(); | |
179 } | |
180 | |
181 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
182 static void RegisterStorageSOPClass(T_ASC_Parameters* params, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
183 unsigned int& presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
184 const std::string& sopClass, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
185 const char* asPreferred[], |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
186 std::vector<const char*>& asFallback) |
0 | 187 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
188 Check(ASC_addPresentationContext(params, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
189 sopClass.c_str(), asPreferred, 1)); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
190 presentationContextId += 2; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
191 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
192 if (asFallback.size() > 0) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
193 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
194 Check(ASC_addPresentationContext(params, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
195 sopClass.c_str(), &asFallback[0], asFallback.size())); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
196 presentationContextId += 2; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
197 } |
0 | 198 } |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
199 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
200 |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
201 void DicomUserConnection::SetupPresentationContexts(const std::string& preferredTransferSyntax) |
0 | 202 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
203 // Flatten an array with the preferred transfer syntax |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
204 const char* asPreferred[1] = { preferredTransferSyntax.c_str() }; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
205 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
206 // Setup the fallback transfer syntaxes |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
207 std::set<std::string> fallbackSyntaxes; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
208 fallbackSyntaxes.insert(UID_LittleEndianExplicitTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
209 fallbackSyntaxes.insert(UID_BigEndianExplicitTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
210 fallbackSyntaxes.insert(UID_LittleEndianImplicitTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
211 fallbackSyntaxes.erase(preferredTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
212 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
213 // Flatten an array with the fallback transfer syntaxes |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
214 std::vector<const char*> asFallback; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
215 asFallback.reserve(fallbackSyntaxes.size()); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
216 for (std::set<std::string>::const_iterator |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
217 it = fallbackSyntaxes.begin(); it != fallbackSyntaxes.end(); ++it) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
218 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
219 asFallback.push_back(it->c_str()); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
220 } |
0 | 221 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
222 CheckStorageSOPClassesInvariant(); |
0 | 223 unsigned int presentationContextId = 1; |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
224 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
225 for (std::list<std::string>::const_iterator it = reservedStorageSOPClasses_.begin(); |
942
b3f6fb1130cd
fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
930
diff
changeset
|
226 it != reservedStorageSOPClasses_.end(); ++it) |
0 | 227 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
228 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
229 *it, asPreferred, asFallback); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
230 } |
0 | 231 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
232 for (std::set<std::string>::const_iterator it = storageSOPClasses_.begin(); |
942
b3f6fb1130cd
fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
930
diff
changeset
|
233 it != storageSOPClasses_.end(); ++it) |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
234 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
235 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
236 *it, asPreferred, asFallback); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
237 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
238 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
239 for (std::set<std::string>::const_iterator it = defaultStorageSOPClasses_.begin(); |
942
b3f6fb1130cd
fixes thanks to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
930
diff
changeset
|
240 it != defaultStorageSOPClasses_.end(); ++it) |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
241 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
242 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
243 *it, asPreferred, asFallback); |
0 | 244 } |
245 } | |
246 | |
247 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
248 static bool IsGenericTransferSyntax(const std::string& syntax) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
249 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
250 return (syntax == UID_LittleEndianExplicitTransferSyntax || |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
251 syntax == UID_BigEndianExplicitTransferSyntax || |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
252 syntax == UID_LittleEndianImplicitTransferSyntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
253 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
254 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
255 |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
256 void DicomUserConnection::PImpl::Store(DcmInputStream& is, |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
257 DicomUserConnection& connection, |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
258 uint16_t moveMessageID) |
0 | 259 { |
260 CheckIsOpen(); | |
261 | |
262 DcmFileFormat dcmff; | |
263 Check(dcmff.read(is, EXS_Unknown, EGL_noChange, DCM_MaxReadLength)); | |
264 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
265 // Determine the storage SOP class UID for this instance |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
266 static const DcmTagKey DCM_SOP_CLASS_UID(0x0008, 0x0016); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
267 OFString sopClassUid; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
268 if (dcmff.getDataset()->findAndGetOFString(DCM_SOP_CLASS_UID, sopClassUid).good()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
269 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
270 connection.AddStorageSOPClass(sopClassUid.c_str()); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
271 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
272 |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
273 // Determine whether a new presentation context must be |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
274 // negotiated, depending on the transfer syntax of this instance |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
275 DcmXfer xfer(dcmff.getDataset()->getOriginalXfer()); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
276 const std::string syntax(xfer.getXferID()); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
277 bool isGeneric = IsGenericTransferSyntax(syntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
278 |
1684
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
279 bool renegociate; |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
280 if (isGeneric) |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
281 { |
1684
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
282 // Are we making a generic-to-specific or specific-to-generic change of |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
283 // the transfer syntax? If this is the case, renegotiate the connection. |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
284 renegociate = !IsGenericTransferSyntax(connection.GetPreferredTransferSyntax()); |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
285 } |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
286 else |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
287 { |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
288 // We are using a specific transfer syntax. Renegociate if the |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
289 // current connection does not match this transfer syntax. |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
290 renegociate = (syntax != connection.GetPreferredTransferSyntax()); |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
291 } |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
292 |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
293 if (renegociate) |
7dae55228b16
Fix issue 4 (C-Store Association not renegotiated on Specific-to-specific transfer syntax change)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1582
diff
changeset
|
294 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
295 LOG(INFO) << "Change in the transfer syntax: the C-Store associated must be renegotiated"; |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
296 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
297 if (isGeneric) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
298 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
299 connection.ResetPreferredTransferSyntax(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
300 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
301 else |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
302 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
303 connection.SetPreferredTransferSyntax(syntax); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
304 } |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
305 } |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
306 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
307 if (!connection.IsOpen()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
308 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
309 LOG(INFO) << "Renegotiating a C-Store association due to a change in the parameters"; |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
310 connection.Open(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
311 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
312 |
0 | 313 // Figure out which SOP class and SOP instance is encapsulated in the file |
314 DIC_UI sopClass; | |
315 DIC_UI sopInstance; | |
316 if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sopInstance)) | |
317 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
318 throw OrthancException(ErrorCode_NoSopClassOrInstance); |
0 | 319 } |
320 | |
321 // Figure out which of the accepted presentation contexts should be used | |
322 int presID = ASC_findAcceptedPresentationContextID(assoc_, sopClass); | |
323 if (presID == 0) | |
324 { | |
325 const char *modalityName = dcmSOPClassUIDToModality(sopClass); | |
326 if (!modalityName) modalityName = dcmFindNameOfUID(sopClass); | |
327 if (!modalityName) modalityName = "unknown SOP class"; | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
328 throw OrthancException(ErrorCode_NoPresentationContext); |
0 | 329 } |
330 | |
331 // Prepare the transmission of data | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
332 T_DIMSE_C_StoreRQ request; |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
333 memset(&request, 0, sizeof(request)); |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
334 request.MessageID = assoc_->nextMsgID++; |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
335 strncpy(request.AffectedSOPClassUID, sopClass, DIC_UI_LEN); |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
336 request.Priority = DIMSE_PRIORITY_MEDIUM; |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
337 request.DataSetType = DIMSE_DATASET_PRESENT; |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
338 strncpy(request.AffectedSOPInstanceUID, sopInstance, DIC_UI_LEN); |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
339 |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
340 strncpy(request.MoveOriginatorApplicationEntityTitle, |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
341 connection.GetLocalApplicationEntityTitle().c_str(), DIC_AE_LEN); |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
342 request.opts = O_STORE_MOVEORIGINATORAETITLE; |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
343 |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
344 if (moveMessageID != 0) |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
345 { |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
346 request.MoveOriginatorID = moveMessageID; // The type DIC_US is an alias for uint16_t |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
347 request.opts |= O_STORE_MOVEORIGINATORID; |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
348 } |
0 | 349 |
350 // Finally conduct transmission of data | |
351 T_DIMSE_C_StoreRSP rsp; | |
352 DcmDataset* statusDetail = NULL; | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
353 Check(DIMSE_storeUser(assoc_, presID, &request, |
0 | 354 NULL, dcmff.getDataset(), /*progressCallback*/ NULL, NULL, |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
355 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ dimseTimeout_, |
0 | 356 &rsp, &statusDetail, NULL)); |
357 | |
358 if (statusDetail != NULL) | |
359 { | |
360 delete statusDetail; | |
361 } | |
362 } | |
363 | |
364 | |
1366 | 365 namespace |
366 { | |
367 struct FindPayload | |
368 { | |
369 DicomFindAnswers* answers; | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
370 const char* level; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
371 bool isWorklist; |
1366 | 372 }; |
373 } | |
374 | |
375 | |
0 | 376 static void FindCallback( |
377 /* in */ | |
378 void *callbackData, | |
379 T_DIMSE_C_FindRQ *request, /* original find request */ | |
380 int responseCount, | |
381 T_DIMSE_C_FindRSP *response, /* pending response received */ | |
382 DcmDataset *responseIdentifiers /* pending response identifiers */ | |
383 ) | |
384 { | |
1366 | 385 FindPayload& payload = *reinterpret_cast<FindPayload*>(callbackData); |
0 | 386 |
387 if (responseIdentifiers != NULL) | |
388 { | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
389 if (payload.isWorklist) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
390 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
391 ParsedDicomFile answer(*responseIdentifiers); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
392 payload.answers->Add(answer); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
393 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
394 else |
1366 | 395 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
396 DicomMap m; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
397 FromDcmtkBridge::Convert(m, *responseIdentifiers); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
398 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
399 if (!m.HasTag(DICOM_TAG_QUERY_RETRIEVE_LEVEL)) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
400 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
401 m.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, payload.level); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
402 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
403 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
404 payload.answers->Add(m); |
1366 | 405 } |
0 | 406 } |
407 } | |
408 | |
1368 | 409 |
1707
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
410 static void FixFindQuery(DicomMap& fixedQuery, |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
411 ResourceType level, |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
412 const DicomMap& fields) |
1368 | 413 { |
414 std::set<DicomTag> allowedTags; | |
415 | |
416 // WARNING: Do not add "break" or reorder items in this switch-case! | |
417 switch (level) | |
418 { | |
419 case ResourceType_Instance: | |
420 DicomTag::AddTagsForModule(allowedTags, DicomModule_Instance); | |
421 | |
422 case ResourceType_Series: | |
423 DicomTag::AddTagsForModule(allowedTags, DicomModule_Series); | |
424 | |
425 case ResourceType_Study: | |
426 DicomTag::AddTagsForModule(allowedTags, DicomModule_Study); | |
427 | |
428 case ResourceType_Patient: | |
429 DicomTag::AddTagsForModule(allowedTags, DicomModule_Patient); | |
430 break; | |
431 | |
432 default: | |
433 throw OrthancException(ErrorCode_InternalError); | |
434 } | |
435 | |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
436 if (level == ResourceType_Study) |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
437 { |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
438 allowedTags.insert(DICOM_TAG_MODALITIES_IN_STUDY); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
439 } |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
440 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
441 allowedTags.insert(DICOM_TAG_SPECIFIC_CHARACTER_SET); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
442 |
1368 | 443 DicomArray query(fields); |
444 for (size_t i = 0; i < query.GetSize(); i++) | |
445 { | |
446 const DicomTag& tag = query.GetElement(i).GetTag(); | |
447 if (allowedTags.find(tag) == allowedTags.end()) | |
448 { | |
1707
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
449 LOG(WARNING) << "Tag not allowed for this C-Find level, will be ignored: " << tag; |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
450 } |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
451 else |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
452 { |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
453 fixedQuery.SetValue(tag, query.GetElement(i).GetValue()); |
1368 | 454 } |
455 } | |
456 } | |
457 | |
458 | |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
459 static DcmDataset* ConvertQueryFields(const DicomMap& fields, |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
460 ModalityManufacturer manufacturer) |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
461 { |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
462 switch (manufacturer) |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
463 { |
1846
3dcf5c0734c9
New "AgfaImpax" modality manufacturer for AGFA Impax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
464 case ModalityManufacturer_AgfaImpax: |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
465 case ModalityManufacturer_SyngoVia: |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
466 { |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
467 std::auto_ptr<DicomMap> fix(fields.Clone()); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
468 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
469 // This issue for Syngo.Via and its solution was reported by |
1846
3dcf5c0734c9
New "AgfaImpax" modality manufacturer for AGFA Impax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
470 // Emsy Chan by private mail on 2015-06-17. According to |
3dcf5c0734c9
New "AgfaImpax" modality manufacturer for AGFA Impax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
471 // Robert van Ommen (2015-11-30), the same fix is required for |
3dcf5c0734c9
New "AgfaImpax" modality manufacturer for AGFA Impax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1805
diff
changeset
|
472 // Agfa Impax. |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
473 std::set<DicomTag> tags; |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
474 fix->GetTags(tags); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
475 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
476 for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it) |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
477 { |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
478 if (FromDcmtkBridge::GetValueRepresentation(*it) == ValueRepresentation_Date) |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
479 { |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
480 // Replace a "*" query by an empty query ("") for "date" |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
481 // value representations. Necessary to search over dates |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
482 // in Syngo.Via. |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
483 const DicomValue* value = fix->TestAndGetValue(*it); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
484 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
485 if (value != NULL && |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1707
diff
changeset
|
486 !value->IsNull() && |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1707
diff
changeset
|
487 value->GetContent() == "*") |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
488 { |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
489 fix->SetValue(*it, ""); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
490 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
491 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
492 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
493 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
494 return ToDcmtkBridge::Convert(*fix); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
495 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
496 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
497 default: |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
498 return ToDcmtkBridge::Convert(fields); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
499 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
500 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
501 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
502 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
503 static void ExecuteFind(DicomFindAnswers& answers, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
504 T_ASC_Association* association, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
505 DcmDataset* dataset, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
506 const char* sopClass, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
507 bool isWorklist, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
508 const char* level, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
509 uint32_t dimseTimeout) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
510 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
511 assert(isWorklist ^ (level != NULL)); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
512 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
513 FindPayload payload; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
514 payload.answers = &answers; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
515 payload.level = level; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
516 payload.isWorklist = isWorklist; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
517 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
518 // Figure out which of the accepted presentation contexts should be used |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
519 int presID = ASC_findAcceptedPresentationContextID(association, sopClass); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
520 if (presID == 0) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
521 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
522 throw OrthancException(ErrorCode_DicomFindUnavailable); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
523 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
524 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
525 T_DIMSE_C_FindRQ request; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
526 memset(&request, 0, sizeof(request)); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
527 request.MessageID = association->nextMsgID++; |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
528 strncpy(request.AffectedSOPClassUID, sopClass, DIC_UI_LEN); |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
529 request.Priority = DIMSE_PRIORITY_MEDIUM; |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
530 request.DataSetType = DIMSE_DATASET_PRESENT; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
531 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
532 T_DIMSE_C_FindRSP response; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
533 DcmDataset* statusDetail = NULL; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
534 OFCondition cond = DIMSE_findUser(association, presID, &request, dataset, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
535 FindCallback, &payload, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
536 /*opt_blockMode*/ DIMSE_BLOCKING, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
537 /*opt_dimse_timeout*/ dimseTimeout, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
538 &response, &statusDetail); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
539 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
540 if (statusDetail) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
541 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
542 delete statusDetail; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
543 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
544 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
545 Check(cond); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
546 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
547 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
548 |
0 | 549 void DicomUserConnection::Find(DicomFindAnswers& result, |
1368 | 550 ResourceType level, |
1707
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
551 const DicomMap& originalFields) |
0 | 552 { |
1707
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
553 DicomMap fields; |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
554 FixFindQuery(fields, level, originalFields); |
1368 | 555 |
0 | 556 CheckIsOpen(); |
557 | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
558 std::auto_ptr<DcmDataset> dataset(ConvertQueryFields(fields, manufacturer_)); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
559 const char* clevel = NULL; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
560 const char* sopClass = NULL; |
1366 | 561 |
1368 | 562 switch (level) |
0 | 563 { |
1368 | 564 case ResourceType_Patient: |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
565 clevel = "PATIENT"; |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
566 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "PATIENT"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
567 sopClass = UID_FINDPatientRootQueryRetrieveInformationModel; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
568 break; |
0 | 569 |
1368 | 570 case ResourceType_Study: |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
571 clevel = "STUDY"; |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
572 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "STUDY"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
573 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
574 break; |
0 | 575 |
1368 | 576 case ResourceType_Series: |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
577 clevel = "SERIES"; |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
578 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "SERIES"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
579 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
580 break; |
0 | 581 |
1368 | 582 case ResourceType_Instance: |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
583 clevel = "INSTANCE"; |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
584 if (manufacturer_ == ModalityManufacturer_ClearCanvas || |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
585 manufacturer_ == ModalityManufacturer_Dcm4Chee) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
586 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
587 // This is a particular case for ClearCanvas, thanks to Peter Somlo <peter.somlo@gmail.com>. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
588 // https://groups.google.com/d/msg/orthanc-users/j-6C3MAVwiw/iolB9hclom8J |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
589 // http://www.clearcanvas.ca/Home/Community/OldForums/tabid/526/aff/11/aft/14670/afv/topic/Default.aspx |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
590 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "IMAGE"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
591 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
592 else |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
593 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
594 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "INSTANCE"); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
595 } |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
596 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
597 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel; |
1368 | 598 break; |
0 | 599 |
1368 | 600 default: |
601 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
602 } | |
603 | |
604 // Add the expected tags for this query level. | |
605 // WARNING: Do not reorder or add "break" in this switch-case! | |
606 switch (level) | |
607 { | |
608 case ResourceType_Instance: | |
609 // SOP Instance UID | |
610 if (!fields.HasTag(0x0008, 0x0018)) | |
611 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0018), ""); | |
612 | |
613 case ResourceType_Series: | |
614 // Series instance UID | |
615 if (!fields.HasTag(0x0020, 0x000e)) | |
616 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000e), ""); | |
617 | |
618 case ResourceType_Study: | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
619 // Accession number |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
620 if (!fields.HasTag(0x0008, 0x0050)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
621 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0050), ""); |
0 | 622 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
623 // Study instance UID |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
624 if (!fields.HasTag(0x0020, 0x000d)) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
625 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0020, 0x000d), ""); |
0 | 626 |
1368 | 627 case ResourceType_Patient: |
628 // Patient ID | |
629 if (!fields.HasTag(0x0010, 0x0020)) | |
630 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0010, 0x0020), ""); | |
0 | 631 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
632 break; |
0 | 633 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
634 default: |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
635 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0 | 636 } |
637 | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
638 assert(clevel != NULL && sopClass != NULL); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
639 ExecuteFind(result, pimpl_->assoc_, dataset.get(), sopClass, false, clevel, pimpl_->dimseTimeout_); |
0 | 640 } |
641 | |
642 | |
1366 | 643 void DicomUserConnection::MoveInternal(const std::string& targetAet, |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
644 ResourceType level, |
1366 | 645 const DicomMap& fields) |
0 | 646 { |
647 CheckIsOpen(); | |
648 | |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
649 std::auto_ptr<DcmDataset> dataset(ConvertQueryFields(fields, manufacturer_)); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
650 |
0 | 651 const char* sopClass = UID_MOVEStudyRootQueryRetrieveInformationModel; |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
652 switch (level) |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
653 { |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
654 case ResourceType_Patient: |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
655 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "PATIENT"); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
656 break; |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
657 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
658 case ResourceType_Study: |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
659 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "STUDY"); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
660 break; |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
661 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
662 case ResourceType_Series: |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
663 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "SERIES"); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
664 break; |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
665 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
666 case ResourceType_Instance: |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
667 if (manufacturer_ == ModalityManufacturer_ClearCanvas || |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
668 manufacturer_ == ModalityManufacturer_Dcm4Chee) |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
669 { |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
670 // This is a particular case for ClearCanvas, thanks to Peter Somlo <peter.somlo@gmail.com>. |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
671 // https://groups.google.com/d/msg/orthanc-users/j-6C3MAVwiw/iolB9hclom8J |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
672 // http://www.clearcanvas.ca/Home/Community/OldForums/tabid/526/aff/11/aft/14670/afv/topic/Default.aspx |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
673 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "IMAGE"); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
674 } |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
675 else |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
676 { |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
677 DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "INSTANCE"); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
678 } |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
679 break; |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
680 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
681 default: |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
682 throw OrthancException(ErrorCode_ParameterOutOfRange); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
683 } |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
684 |
0 | 685 // Figure out which of the accepted presentation contexts should be used |
686 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass); | |
687 if (presID == 0) | |
688 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
689 throw OrthancException(ErrorCode_DicomMoveUnavailable); |
0 | 690 } |
691 | |
692 T_DIMSE_C_MoveRQ request; | |
693 memset(&request, 0, sizeof(request)); | |
694 request.MessageID = pimpl_->assoc_->nextMsgID++; | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
695 strncpy(request.AffectedSOPClassUID, sopClass, DIC_UI_LEN); |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
696 request.Priority = DIMSE_PRIORITY_MEDIUM; |
0 | 697 request.DataSetType = DIMSE_DATASET_PRESENT; |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
698 strncpy(request.MoveDestination, targetAet.c_str(), DIC_AE_LEN); |
0 | 699 |
700 T_DIMSE_C_MoveRSP response; | |
701 DcmDataset* statusDetail = NULL; | |
702 DcmDataset* responseIdentifiers = NULL; | |
703 OFCondition cond = DIMSE_moveUser(pimpl_->assoc_, presID, &request, dataset.get(), | |
704 NULL, NULL, | |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
705 /*opt_blockMode*/ DIMSE_BLOCKING, |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
706 /*opt_dimse_timeout*/ pimpl_->dimseTimeout_, |
0 | 707 pimpl_->net_, NULL, NULL, |
708 &response, &statusDetail, &responseIdentifiers); | |
709 | |
710 if (statusDetail) | |
711 { | |
712 delete statusDetail; | |
713 } | |
714 | |
715 if (responseIdentifiers) | |
716 { | |
717 delete responseIdentifiers; | |
718 } | |
719 | |
720 Check(cond); | |
721 } | |
722 | |
723 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
724 void DicomUserConnection::ResetStorageSOPClasses() |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
725 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
726 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
727 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
728 storageSOPClasses_.clear(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
729 defaultStorageSOPClasses_.clear(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
730 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
731 // Copy the short list of storage SOP classes from DCMTK, making |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
732 // room for the 5 SOP classes reserved for C-ECHO, C-FIND, C-MOVE at (**). |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
733 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
734 std::set<std::string> uncommon; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
735 uncommon.insert(UID_BlendingSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
736 uncommon.insert(UID_GrayscaleSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
737 uncommon.insert(UID_ColorSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
738 uncommon.insert(UID_PseudoColorSoftcopyPresentationStateStorage); |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
739 uncommon.insert(UID_XAXRFGrayscaleSoftcopyPresentationStateStorage); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
740 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
741 // Add the storage syntaxes for C-STORE |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
742 for (int i = 0; i < numberOfDcmShortSCUStorageSOPClassUIDs - 1; i++) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
743 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
744 if (uncommon.find(dcmShortSCUStorageSOPClassUIDs[i]) == uncommon.end()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
745 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
746 defaultStorageSOPClasses_.insert(dcmShortSCUStorageSOPClassUIDs[i]); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
747 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
748 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
749 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
750 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
751 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
752 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
753 |
656 | 754 DicomUserConnection::DicomUserConnection() : |
755 pimpl_(new PImpl), | |
666
b8383ac0b227
fix cppcheck warning
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
662
diff
changeset
|
756 preferredTransferSyntax_(DEFAULT_PREFERRED_TRANSFER_SYNTAX), |
656 | 757 localAet_("STORESCU"), |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
758 remoteAet_("ANY-SCP"), |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
759 remoteHost_("127.0.0.1") |
0 | 760 { |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
761 remotePort_ = 104; |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
762 manufacturer_ = ModalityManufacturer_Generic; |
0 | 763 |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
764 SetTimeout(10); |
0 | 765 pimpl_->net_ = NULL; |
766 pimpl_->params_ = NULL; | |
767 pimpl_->assoc_ = NULL; | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
768 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
769 // SOP classes for C-ECHO, C-FIND and C-MOVE (**) |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
770 reservedStorageSOPClasses_.push_back(UID_VerificationSOPClass); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
771 reservedStorageSOPClasses_.push_back(UID_FINDPatientRootQueryRetrieveInformationModel); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
772 reservedStorageSOPClasses_.push_back(UID_FINDStudyRootQueryRetrieveInformationModel); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
773 reservedStorageSOPClasses_.push_back(UID_MOVEStudyRootQueryRetrieveInformationModel); |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
774 reservedStorageSOPClasses_.push_back(UID_FINDModalityWorklistInformationModel); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
775 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
776 ResetStorageSOPClasses(); |
0 | 777 } |
778 | |
779 DicomUserConnection::~DicomUserConnection() | |
780 { | |
781 Close(); | |
782 } | |
783 | |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
784 |
1427
d710ea64f0fd
Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1371
diff
changeset
|
785 void DicomUserConnection::SetRemoteModality(const RemoteModalityParameters& parameters) |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
786 { |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
787 SetRemoteApplicationEntityTitle(parameters.GetApplicationEntityTitle()); |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
788 SetRemoteHost(parameters.GetHost()); |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
789 SetRemotePort(parameters.GetPort()); |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
790 SetRemoteManufacturer(parameters.GetManufacturer()); |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
791 } |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
792 |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
793 |
0 | 794 void DicomUserConnection::SetLocalApplicationEntityTitle(const std::string& aet) |
795 { | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
796 if (localAet_ != aet) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
797 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
798 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
799 localAet_ = aet; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
800 } |
0 | 801 } |
802 | |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
803 void DicomUserConnection::SetRemoteApplicationEntityTitle(const std::string& aet) |
0 | 804 { |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
805 if (remoteAet_ != aet) |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
806 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
807 Close(); |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
808 remoteAet_ = aet; |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
809 } |
0 | 810 } |
811 | |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
812 void DicomUserConnection::SetRemoteManufacturer(ModalityManufacturer manufacturer) |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
813 { |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
814 if (manufacturer_ != manufacturer) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
815 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
816 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
817 manufacturer_ = manufacturer; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
818 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
819 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
820 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
821 void DicomUserConnection::ResetPreferredTransferSyntax() |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
822 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
823 SetPreferredTransferSyntax(DEFAULT_PREFERRED_TRANSFER_SYNTAX); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
824 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
825 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
826 void DicomUserConnection::SetPreferredTransferSyntax(const std::string& preferredTransferSyntax) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
827 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
828 if (preferredTransferSyntax_ != preferredTransferSyntax) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
829 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
830 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
831 preferredTransferSyntax_ = preferredTransferSyntax; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
832 } |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
833 } |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
834 |
0 | 835 |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
836 void DicomUserConnection::SetRemoteHost(const std::string& host) |
0 | 837 { |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
838 if (remoteHost_ != host) |
0 | 839 { |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
840 if (host.size() > HOST_NAME_MAX - 10) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
841 { |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
842 throw OrthancException(ErrorCode_ParameterOutOfRange); |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
843 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
844 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
845 Close(); |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
846 remoteHost_ = host; |
0 | 847 } |
848 } | |
849 | |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
850 void DicomUserConnection::SetRemotePort(uint16_t port) |
0 | 851 { |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
852 if (remotePort_ != port) |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
853 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
854 Close(); |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
855 remotePort_ = port; |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
856 } |
0 | 857 } |
858 | |
859 void DicomUserConnection::Open() | |
860 { | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
861 if (IsOpen()) |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
862 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
863 // Don't reopen the connection |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
864 return; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
865 } |
0 | 866 |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
766
diff
changeset
|
867 LOG(INFO) << "Opening a DICOM SCU connection from AET \"" << GetLocalApplicationEntityTitle() |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
868 << "\" to AET \"" << GetRemoteApplicationEntityTitle() << "\" on host " |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
869 << GetRemoteHost() << ":" << GetRemotePort() |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
870 << " (manufacturer: " << EnumerationToString(GetRemoteManufacturer()) << ")"; |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
766
diff
changeset
|
871 |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
872 Check(ASC_initializeNetwork(NET_REQUESTOR, 0, /*opt_acse_timeout*/ pimpl_->acseTimeout_, &pimpl_->net_)); |
0 | 873 Check(ASC_createAssociationParameters(&pimpl_->params_, /*opt_maxReceivePDULength*/ ASC_DEFAULTMAXPDU)); |
874 | |
875 // Set this application's title and the called application's title in the params | |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
876 Check(ASC_setAPTitles(pimpl_->params_, localAet_.c_str(), remoteAet_.c_str(), NULL)); |
0 | 877 |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
878 // Set the network addresses of the local and remote entities |
0 | 879 char localHost[HOST_NAME_MAX]; |
880 gethostname(localHost, HOST_NAME_MAX - 1); | |
881 | |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
882 char remoteHostAndPort[HOST_NAME_MAX]; |
2 | 883 |
884 #ifdef _MSC_VER | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
885 _snprintf |
2 | 886 #else |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
887 snprintf |
2 | 888 #endif |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
889 (remoteHostAndPort, HOST_NAME_MAX - 1, "%s:%d", remoteHost_.c_str(), remotePort_); |
0 | 890 |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
891 Check(ASC_setPresentationAddresses(pimpl_->params_, localHost, remoteHostAndPort)); |
0 | 892 |
893 // Set various options | |
894 Check(ASC_setTransportLayerType(pimpl_->params_, /*opt_secureConnection*/ false)); | |
895 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
896 SetupPresentationContexts(preferredTransferSyntax_); |
0 | 897 |
898 // Do the association | |
899 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_)); | |
900 | |
901 if (ASC_countAcceptedPresentationContexts(pimpl_->params_) == 0) | |
902 { | |
1582
bd1889029cbb
encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
903 throw OrthancException(ErrorCode_NoPresentationContext); |
0 | 904 } |
905 } | |
906 | |
907 void DicomUserConnection::Close() | |
908 { | |
909 if (pimpl_->assoc_ != NULL) | |
910 { | |
911 ASC_releaseAssociation(pimpl_->assoc_); | |
912 ASC_destroyAssociation(&pimpl_->assoc_); | |
913 pimpl_->assoc_ = NULL; | |
914 pimpl_->params_ = NULL; | |
915 } | |
916 else | |
917 { | |
918 if (pimpl_->params_ != NULL) | |
919 { | |
920 ASC_destroyAssociationParameters(&pimpl_->params_); | |
921 pimpl_->params_ = NULL; | |
922 } | |
923 } | |
924 | |
925 if (pimpl_->net_ != NULL) | |
926 { | |
927 ASC_dropNetwork(&pimpl_->net_); | |
928 pimpl_->net_ = NULL; | |
929 } | |
930 } | |
931 | |
932 bool DicomUserConnection::IsOpen() const | |
933 { | |
934 return pimpl_->IsOpen(); | |
935 } | |
936 | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
937 void DicomUserConnection::Store(const char* buffer, |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
938 size_t size, |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
939 uint16_t moveMessageID) |
0 | 940 { |
941 // Prepare an input stream for the memory buffer | |
942 DcmInputBufferStream is; | |
943 if (size > 0) | |
944 is.setBuffer(buffer, size); | |
945 is.setEos(); | |
946 | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
947 pimpl_->Store(is, *this, moveMessageID); |
0 | 948 } |
949 | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
950 void DicomUserConnection::Store(const std::string& buffer, |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
951 uint16_t moveMessageID) |
0 | 952 { |
953 if (buffer.size() > 0) | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
954 Store(reinterpret_cast<const char*>(&buffer[0]), buffer.size(), moveMessageID); |
0 | 955 else |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
956 Store(NULL, 0, moveMessageID); |
0 | 957 } |
958 | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
959 void DicomUserConnection::StoreFile(const std::string& path, |
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
960 uint16_t moveMessageID) |
0 | 961 { |
962 // Prepare an input stream for the file | |
963 DcmInputFileStream is(path.c_str()); | |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
964 pimpl_->Store(is, *this, moveMessageID); |
0 | 965 } |
966 | |
967 bool DicomUserConnection::Echo() | |
968 { | |
969 CheckIsOpen(); | |
970 DIC_US status; | |
971 Check(DIMSE_echoUser(pimpl_->assoc_, pimpl_->assoc_->nextMsgID++, | |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
972 /*opt_blockMode*/ DIMSE_BLOCKING, |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
973 /*opt_dimse_timeout*/ pimpl_->dimseTimeout_, |
0 | 974 &status, NULL)); |
975 return status == STATUS_Success; | |
976 } | |
977 | |
978 | |
1366 | 979 static void TestAndCopyTag(DicomMap& result, |
980 const DicomMap& source, | |
981 const DicomTag& tag) | |
982 { | |
983 if (!source.HasTag(tag)) | |
984 { | |
985 throw OrthancException(ErrorCode_BadRequest); | |
986 } | |
987 else | |
988 { | |
989 result.SetValue(tag, source.GetValue(tag)); | |
990 } | |
991 } | |
992 | |
993 | |
994 void DicomUserConnection::Move(const std::string& targetAet, | |
995 const DicomMap& findResult) | |
0 | 996 { |
1366 | 997 if (!findResult.HasTag(DICOM_TAG_QUERY_RETRIEVE_LEVEL)) |
998 { | |
999 throw OrthancException(ErrorCode_InternalError); | |
1000 } | |
1001 | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1707
diff
changeset
|
1002 const std::string tmp = findResult.GetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL).GetContent(); |
1366 | 1003 ResourceType level = StringToResourceType(tmp.c_str()); |
1004 | |
1005 DicomMap move; | |
1006 switch (level) | |
1007 { | |
1008 case ResourceType_Patient: | |
1009 TestAndCopyTag(move, findResult, DICOM_TAG_PATIENT_ID); | |
1010 break; | |
1011 | |
1012 case ResourceType_Study: | |
1013 TestAndCopyTag(move, findResult, DICOM_TAG_STUDY_INSTANCE_UID); | |
1014 break; | |
1015 | |
1016 case ResourceType_Series: | |
1017 TestAndCopyTag(move, findResult, DICOM_TAG_STUDY_INSTANCE_UID); | |
1018 TestAndCopyTag(move, findResult, DICOM_TAG_SERIES_INSTANCE_UID); | |
1019 break; | |
1020 | |
1021 case ResourceType_Instance: | |
1022 TestAndCopyTag(move, findResult, DICOM_TAG_STUDY_INSTANCE_UID); | |
1023 TestAndCopyTag(move, findResult, DICOM_TAG_SERIES_INSTANCE_UID); | |
1024 TestAndCopyTag(move, findResult, DICOM_TAG_SOP_INSTANCE_UID); | |
1025 break; | |
1026 | |
1027 default: | |
1028 throw OrthancException(ErrorCode_InternalError); | |
1029 } | |
1030 | |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1031 MoveInternal(targetAet, level, move); |
1366 | 1032 } |
1033 | |
1034 | |
1035 void DicomUserConnection::MovePatient(const std::string& targetAet, | |
1036 const std::string& patientId) | |
1037 { | |
1038 DicomMap query; | |
1039 query.SetValue(DICOM_TAG_PATIENT_ID, patientId); | |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1040 MoveInternal(targetAet, ResourceType_Patient, query); |
1366 | 1041 } |
1042 | |
1043 void DicomUserConnection::MoveStudy(const std::string& targetAet, | |
1044 const std::string& studyUid) | |
1045 { | |
1046 DicomMap query; | |
1047 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid); | |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1048 MoveInternal(targetAet, ResourceType_Study, query); |
0 | 1049 } |
1050 | |
1051 void DicomUserConnection::MoveSeries(const std::string& targetAet, | |
1052 const std::string& studyUid, | |
1053 const std::string& seriesUid) | |
1054 { | |
1366 | 1055 DicomMap query; |
1056 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid); | |
1057 query.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid); | |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1058 MoveInternal(targetAet, ResourceType_Series, query); |
0 | 1059 } |
1060 | |
1061 void DicomUserConnection::MoveInstance(const std::string& targetAet, | |
1062 const std::string& studyUid, | |
1063 const std::string& seriesUid, | |
1064 const std::string& instanceUid) | |
1065 { | |
1366 | 1066 DicomMap query; |
1067 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid); | |
1068 query.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid); | |
1069 query.SetValue(DICOM_TAG_SOP_INSTANCE_UID, instanceUid); | |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1070 MoveInternal(targetAet, ResourceType_Instance, query); |
0 | 1071 } |
1072 | |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1073 |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1074 void DicomUserConnection::SetTimeout(uint32_t seconds) |
0 | 1075 { |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1076 if (seconds <= 0) |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1077 { |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1078 throw OrthancException(ErrorCode_ParameterOutOfRange); |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1079 } |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1080 |
0 | 1081 dcmConnectionTimeout.set(seconds); |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1082 pimpl_->dimseTimeout_ = seconds; |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1083 pimpl_->acseTimeout_ = 10; |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1084 } |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1085 |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1086 |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1087 void DicomUserConnection::DisableTimeout() |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1088 { |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1089 /** |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1090 * Global timeout (seconds) for connecting to remote hosts. |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1091 * Default value is -1 which selects infinite timeout, i.e. blocking connect(). |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1092 */ |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1093 dcmConnectionTimeout.set(-1); |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1094 pimpl_->dimseTimeout_ = 0; |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1095 pimpl_->acseTimeout_ = 10; |
0 | 1096 } |
1097 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1098 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1099 void DicomUserConnection::CheckStorageSOPClassesInvariant() const |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1100 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1101 assert(storageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1102 defaultStorageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1103 reservedStorageSOPClasses_.size() <= MAXIMUM_STORAGE_SOP_CLASSES); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1104 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1105 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1106 void DicomUserConnection::AddStorageSOPClass(const char* sop) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1107 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1108 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1109 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1110 if (storageSOPClasses_.find(sop) != storageSOPClasses_.end()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1111 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1112 // This storage SOP class is already explicitly registered. Do |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1113 // nothing. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1114 return; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1115 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1116 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1117 if (defaultStorageSOPClasses_.find(sop) != defaultStorageSOPClasses_.end()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1118 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1119 // This storage SOP class is not explicitly registered, but is |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1120 // used by default. Just register it explicitly. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1121 defaultStorageSOPClasses_.erase(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1122 storageSOPClasses_.insert(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1123 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1124 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1125 return; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1126 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1127 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1128 // This storage SOP class is neither explicitly, nor implicitly |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1129 // registered. Close the connection and register it explicitly. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1130 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1131 Close(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1132 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1133 if (reservedStorageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1134 storageSOPClasses_.size() >= MAXIMUM_STORAGE_SOP_CLASSES) // (*) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1135 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1136 // The maximum number of SOP classes is reached |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1137 ResetStorageSOPClasses(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1138 defaultStorageSOPClasses_.erase(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1139 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1140 else if (reservedStorageSOPClasses_.size() + storageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1141 defaultStorageSOPClasses_.size() >= MAXIMUM_STORAGE_SOP_CLASSES) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1142 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1143 // Make room in the default storage syntaxes |
1303 | 1144 assert(!defaultStorageSOPClasses_.empty()); // Necessarily true because condition (*) is false |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1145 defaultStorageSOPClasses_.erase(*defaultStorageSOPClasses_.rbegin()); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1146 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1147 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1148 // Explicitly register the new storage syntax |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1149 storageSOPClasses_.insert(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1150 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1151 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1152 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1153 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1154 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1155 void DicomUserConnection::FindWorklist(DicomFindAnswers& result, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1156 ParsedDicomFile& query) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1157 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1158 CheckIsOpen(); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1159 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1160 DcmDataset* dataset = query.GetDcmtkObject().getDataset(); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1161 const char* sopClass = UID_FINDModalityWorklistInformationModel; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1162 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1163 ExecuteFind(result, pimpl_->assoc_, dataset, sopClass, true, NULL, pimpl_->dimseTimeout_); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1164 } |
0 | 1165 } |