Mercurial > hg > orthanc
annotate Core/DicomNetworking/DicomUserConnection.cpp @ 3700:5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 26 Feb 2020 13:21:41 +0100 |
parents | 94f4a18a79cc |
children | 736907ecb626 58f92b1c8061 |
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 |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3561
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
136 | 11 * |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
0 | 23 * |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
766
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 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
37 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
|
38 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
39 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
|
40 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
|
41 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
42 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
|
43 All rights reserved. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
44 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
45 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
|
46 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
47 OFFIS e.V. |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
48 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
|
49 Escherweg 2 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
50 26121 Oldenburg, Germany |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
51 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
52 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
|
53 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
|
54 are met: |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
55 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
56 - 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
|
57 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
|
58 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
59 - 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
|
60 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
|
61 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
|
62 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
63 - 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
|
64 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
|
65 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
|
66 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
67 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
|
68 "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
|
69 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
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 (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
|
77 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
|
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 |
0a2f8c707c78
Fix missing licensing terms about reuse of some DCMTK code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
763
diff
changeset
|
81 |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
82 #include "../PrecompiledHeaders.h" |
0 | 83 #include "DicomUserConnection.h" |
84 | |
3117 | 85 #if !defined(DCMTK_VERSION_NUMBER) |
86 # error The macro DCMTK_VERSION_NUMBER must be defined | |
87 #endif | |
88 | |
2382
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
89 #include "../DicomFormat/DicomArray.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
90 #include "../Logging.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
91 #include "../OrthancException.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
92 #include "../DicomParsing/FromDcmtkBridge.h" |
7284093111b0
big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2381
diff
changeset
|
93 #include "../DicomParsing/ToDcmtkBridge.h" |
0 | 94 |
3369 | 95 #include <dcmtk/dcmdata/dcdeftag.h> |
96 #include <dcmtk/dcmdata/dcfilefo.h> | |
0 | 97 #include <dcmtk/dcmdata/dcistrmb.h> |
98 #include <dcmtk/dcmdata/dcistrmf.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
|
99 #include <dcmtk/dcmdata/dcmetinf.h> |
0 | 100 #include <dcmtk/dcmnet/diutil.h> |
101 | |
102 #include <set> | |
103 | |
104 | |
105 #ifdef _WIN32 | |
106 /** | |
107 * "The maximum length, in bytes, of the string returned in the buffer | |
108 * pointed to by the name parameter is dependent on the namespace provider, | |
109 * but this string must be 256 bytes or less. | |
110 * http://msdn.microsoft.com/en-us/library/windows/desktop/ms738527(v=vs.85).aspx | |
111 **/ | |
2340 | 112 # define HOST_NAME_MAX 256 |
113 # include <winsock.h> | |
0 | 114 #endif |
115 | |
116 | |
918 | 117 #if !defined(HOST_NAME_MAX) && defined(_POSIX_HOST_NAME_MAX) |
890 | 118 /** |
119 * TO IMPROVE: "_POSIX_HOST_NAME_MAX is only the minimum value that | |
120 * HOST_NAME_MAX can ever have [...] Therefore you cannot allocate an | |
121 * array of size _POSIX_HOST_NAME_MAX, invoke gethostname() and expect | |
122 * that the result will fit." | |
123 * http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00128.html | |
124 **/ | |
125 #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX | |
126 #endif | |
127 | |
128 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
129 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
|
130 |
763
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 * "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
|
133 * 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
|
134 * 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
|
135 * limit of 128 contexts for one association." |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
136 **/ |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
137 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
|
138 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
139 |
62 | 140 namespace Orthanc |
0 | 141 { |
2069
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
142 // By default, the timeout for DICOM SCU (client) connections is set to 10 seconds |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
143 static uint32_t defaultTimeout_ = 10; |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
144 |
0 | 145 struct DicomUserConnection::PImpl |
146 { | |
147 // Connection state | |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
148 uint32_t dimseTimeout_; |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
149 uint32_t acseTimeout_; |
0 | 150 T_ASC_Network* net_; |
151 T_ASC_Parameters* params_; | |
152 T_ASC_Association* assoc_; | |
153 | |
154 bool IsOpen() const | |
155 { | |
156 return assoc_ != NULL; | |
157 } | |
158 | |
159 void CheckIsOpen() const; | |
160 | |
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
|
161 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
|
162 DicomUserConnection& connection, |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
163 const std::string& moveOriginatorAET, |
1997
f9f2aa1cc594
"MoveOriginatorID" can be specified for /modalities/.../store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
164 uint16_t moveOriginatorID); |
0 | 165 }; |
166 | |
167 | |
3208
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
168 static void Check(const OFCondition& cond, |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
169 const std::string& aet, |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
170 const std::string& command) |
0 | 171 { |
172 if (cond.bad()) | |
173 { | |
3208
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
174 // Reformat the error message from DCMTK by turning multiline |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
175 // errors into a single line |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
176 |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
177 std::string s(cond.text()); |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
178 std::string info; |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
179 info.reserve(s.size()); |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
180 |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
181 bool isMultiline = false; |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
182 for (size_t i = 0; i < s.size(); i++) |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
183 { |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
184 if (s[i] == '\r') |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
185 { |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
186 // Ignore |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
187 } |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
188 else if (s[i] == '\n') |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
189 { |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
190 if (isMultiline) |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
191 { |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
192 info += "; "; |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
193 } |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
194 else |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
195 { |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
196 info += " ("; |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
197 isMultiline = true; |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
198 } |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
199 } |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
200 else |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
201 { |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
202 info.push_back(s[i]); |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
203 } |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
204 } |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
205 |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
206 if (isMultiline) |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
207 { |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
208 info += ")"; |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
209 } |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
210 |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2888
diff
changeset
|
211 throw OrthancException(ErrorCode_NetworkProtocol, |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
212 "DicomUserConnection - " + command + |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
213 " to AET \"" + aet + "\": " + info); |
0 | 214 } |
215 } | |
216 | |
217 void DicomUserConnection::PImpl::CheckIsOpen() const | |
218 { | |
219 if (!IsOpen()) | |
220 { | |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2888
diff
changeset
|
221 throw OrthancException(ErrorCode_NetworkProtocol, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2888
diff
changeset
|
222 "DicomUserConnection: First open the connection"); |
0 | 223 } |
224 } | |
225 | |
226 | |
227 void DicomUserConnection::CheckIsOpen() const | |
228 { | |
229 pimpl_->CheckIsOpen(); | |
230 } | |
231 | |
232 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
233 static void RegisterStorageSOPClass(T_ASC_Parameters* params, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
234 unsigned int& presentationContextId, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
235 const std::string& sopClass, |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
236 const char* asPreferred[], |
3208
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
237 std::vector<const char*>& asFallback, |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
238 const std::string& aet) |
0 | 239 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
240 Check(ASC_addPresentationContext(params, presentationContextId, |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
241 sopClass.c_str(), asPreferred, 1), |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
242 aet, "initializing"); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
243 presentationContextId += 2; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
244 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
245 if (asFallback.size() > 0) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
246 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
247 Check(ASC_addPresentationContext(params, presentationContextId, |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
248 sopClass.c_str(), &asFallback[0], asFallback.size()), |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
249 aet, "initializing"); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
250 presentationContextId += 2; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
251 } |
0 | 252 } |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
253 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
254 |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
255 void DicomUserConnection::SetupPresentationContexts(const std::string& preferredTransferSyntax) |
0 | 256 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
257 // 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
|
258 const char* asPreferred[1] = { preferredTransferSyntax.c_str() }; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
259 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
260 // 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
|
261 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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
267 // 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
|
268 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
|
269 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
|
270 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
|
271 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
|
272 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
273 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
|
274 } |
0 | 275 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
276 CheckStorageSOPClassesInvariant(); |
0 | 277 unsigned int presentationContextId = 1; |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
278 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
279 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
|
280 it != reservedStorageSOPClasses_.end(); ++it) |
0 | 281 { |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
282 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
3208
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
283 *it, asPreferred, asFallback, remoteAet_); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
284 } |
0 | 285 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
286 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
|
287 it != storageSOPClasses_.end(); ++it) |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
288 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
289 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
3208
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
290 *it, asPreferred, asFallback, remoteAet_); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
291 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
292 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
293 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
|
294 it != defaultStorageSOPClasses_.end(); ++it) |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
295 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
296 RegisterStorageSOPClass(pimpl_->params_, presentationContextId, |
3208
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
297 *it, asPreferred, asFallback, remoteAet_); |
0 | 298 } |
299 } | |
300 | |
301 | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
302 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
|
303 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
304 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
|
305 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
|
306 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
|
307 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
308 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
309 |
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
|
310 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
|
311 DicomUserConnection& connection, |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
312 const std::string& moveOriginatorAET, |
1997
f9f2aa1cc594
"MoveOriginatorID" can be specified for /modalities/.../store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
313 uint16_t moveOriginatorID) |
0 | 314 { |
315 DcmFileFormat dcmff; | |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
316 Check(dcmff.read(is, EXS_Unknown, EGL_noChange, DCM_MaxReadLength), |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
317 connection.remoteAet_, "C-STORE"); |
0 | 318 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
319 // 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
|
320 OFString sopClassUid; |
3369 | 321 if (dcmff.getDataset()->findAndGetOFString(DCM_SOPClassUID, sopClassUid).good()) |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
322 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
323 connection.AddStorageSOPClass(sopClassUid.c_str()); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
324 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
325 |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
326 // 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
|
327 // 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
|
328 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
|
329 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
|
330 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
|
331 |
2161
7219cdce7bba
spelling: negociate -> negotiate
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
332 bool renegotiate; |
2580
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
333 |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
334 if (!IsOpen()) |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
335 { |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
336 renegotiate = true; |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
337 } |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
338 else 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
|
339 { |
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
|
340 // 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
|
341 // the transfer syntax? If this is the case, renegotiate the connection. |
2161
7219cdce7bba
spelling: negociate -> negotiate
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
342 renegotiate = !IsGenericTransferSyntax(connection.GetPreferredTransferSyntax()); |
2580
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
343 |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
344 if (renegotiate) |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
345 { |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
346 LOG(INFO) << "Use of non-generic transfer syntax: the C-Store associated must be renegotiated"; |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
347 } |
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
|
348 } |
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
|
349 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
|
350 { |
2161
7219cdce7bba
spelling: negociate -> negotiate
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
351 // We are using a specific transfer syntax. Renegotiate if the |
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
|
352 // current connection does not match this transfer syntax. |
2161
7219cdce7bba
spelling: negociate -> negotiate
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
353 renegotiate = (syntax != connection.GetPreferredTransferSyntax()); |
2580
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
354 |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
355 if (renegotiate) |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
356 { |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
357 LOG(INFO) << "Change in the transfer syntax: the C-Store associated must be renegotiated"; |
055d7d4a823f
avoid unecessary openings of DICOM connection for C-Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
358 } |
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
|
359 } |
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
|
360 |
2161
7219cdce7bba
spelling: negociate -> negotiate
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
361 if (renegotiate) |
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
|
362 { |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
363 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
|
364 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
365 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
|
366 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
367 else |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
368 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
369 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
|
370 } |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
371 } |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
372 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
373 if (!connection.IsOpen()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
374 { |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
375 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
|
376 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
377 |
0 | 378 // Figure out which SOP class and SOP instance is encapsulated in the file |
379 DIC_UI sopClass; | |
380 DIC_UI sopInstance; | |
3117 | 381 |
382 #if DCMTK_VERSION_NUMBER >= 364 | |
383 if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sizeof(sopClass), sopInstance, sizeof(sopInstance))) | |
384 #else | |
0 | 385 if (!DU_findSOPClassAndInstanceInDataSet(dcmff.getDataset(), sopClass, sopInstance)) |
3117 | 386 #endif |
0 | 387 { |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
388 throw OrthancException(ErrorCode_NoSopClassOrInstance, |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
389 "Unable to determine the SOP class/instance for C-STORE with AET " + |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
390 connection.remoteAet_); |
0 | 391 } |
392 | |
393 // Figure out which of the accepted presentation contexts should be used | |
394 int presID = ASC_findAcceptedPresentationContextID(assoc_, sopClass); | |
395 if (presID == 0) | |
396 { | |
397 const char *modalityName = dcmSOPClassUIDToModality(sopClass); | |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
398 if (modalityName == NULL) modalityName = dcmFindNameOfUID(sopClass); |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
399 if (modalityName == NULL) modalityName = "unknown SOP class"; |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
400 throw OrthancException(ErrorCode_NoPresentationContext, |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
401 "Unable to determine the accepted presentation contexts for C-STORE with AET " + |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
402 connection.remoteAet_ + " (" + std::string(modalityName) + ")"); |
0 | 403 } |
404 | |
405 // 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
|
406 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
|
407 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
|
408 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
|
409 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
|
410 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
|
411 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
|
412 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
|
413 |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
414 if (!moveOriginatorAET.empty()) |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
415 { |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
416 strncpy(request.MoveOriginatorApplicationEntityTitle, |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
417 moveOriginatorAET.c_str(), DIC_AE_LEN); |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
418 request.opts = O_STORE_MOVEORIGINATORAETITLE; |
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
|
419 |
1997
f9f2aa1cc594
"MoveOriginatorID" can be specified for /modalities/.../store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
420 request.MoveOriginatorID = moveOriginatorID; // The type DIC_US is an alias for uint16_t |
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
|
421 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
|
422 } |
0 | 423 |
424 // Finally conduct transmission of data | |
3700
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
425 T_DIMSE_C_StoreRSP response; |
0 | 426 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
|
427 Check(DIMSE_storeUser(assoc_, presID, &request, |
0 | 428 NULL, dcmff.getDataset(), /*progressCallback*/ NULL, NULL, |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
429 /*opt_blockMode*/ DIMSE_BLOCKING, /*opt_dimse_timeout*/ dimseTimeout_, |
3700
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
430 &response, &statusDetail, NULL), |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
431 connection.remoteAet_, "C-STORE"); |
0 | 432 |
433 if (statusDetail != NULL) | |
434 { | |
435 delete statusDetail; | |
436 } | |
3700
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
437 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
438 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
439 /** |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
440 * New in Orthanc 1.6.0: Deal with failures during C-STORE. |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
441 * http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_B.2.3.html#table_B.2-1 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
442 **/ |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
443 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
444 if (response.DimseStatus != 0x0000 && // Success |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
445 response.DimseStatus != 0xB000 && // Warning - Coercion of Data Elements |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
446 response.DimseStatus != 0xB007 && // Warning - Data Set does not match SOP Class |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
447 response.DimseStatus != 0xB006) // Warning - Elements Discarded |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
448 { |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
449 char buf[16]; |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
450 sprintf(buf, "%04X", response.DimseStatus); |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
451 throw OrthancException(ErrorCode_NetworkProtocol, |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
452 "C-STORE SCU to AET \"" + connection.remoteAet_ + |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
453 "\" has failed with DIMSE status 0x" + buf); |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
454 } |
0 | 455 } |
456 | |
457 | |
1366 | 458 namespace |
459 { | |
460 struct FindPayload | |
461 { | |
462 DicomFindAnswers* answers; | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
463 const char* level; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
464 bool isWorklist; |
1366 | 465 }; |
466 } | |
467 | |
468 | |
0 | 469 static void FindCallback( |
470 /* in */ | |
471 void *callbackData, | |
472 T_DIMSE_C_FindRQ *request, /* original find request */ | |
473 int responseCount, | |
474 T_DIMSE_C_FindRSP *response, /* pending response received */ | |
475 DcmDataset *responseIdentifiers /* pending response identifiers */ | |
476 ) | |
477 { | |
1366 | 478 FindPayload& payload = *reinterpret_cast<FindPayload*>(callbackData); |
0 | 479 |
480 if (responseIdentifiers != NULL) | |
481 { | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
482 if (payload.isWorklist) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
483 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
484 ParsedDicomFile answer(*responseIdentifiers); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
485 payload.answers->Add(answer); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
486 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
487 else |
1366 | 488 { |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
489 DicomMap m; |
2381
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2352
diff
changeset
|
490 FromDcmtkBridge::ExtractDicomSummary(m, *responseIdentifiers); |
b8969010b534
uncoupling DCMTK primitives from Orthanc::Configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2352
diff
changeset
|
491 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
492 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
|
493 { |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
494 m.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, payload.level, false); |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
495 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
496 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
497 payload.answers->Add(m); |
1366 | 498 } |
0 | 499 } |
500 } | |
501 | |
1368 | 502 |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
503 static void NormalizeFindQuery(DicomMap& fixedQuery, |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
504 ResourceType level, |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
505 const DicomMap& fields) |
1368 | 506 { |
507 std::set<DicomTag> allowedTags; | |
508 | |
509 // WARNING: Do not add "break" or reorder items in this switch-case! | |
510 switch (level) | |
511 { | |
512 case ResourceType_Instance: | |
513 DicomTag::AddTagsForModule(allowedTags, DicomModule_Instance); | |
514 | |
515 case ResourceType_Series: | |
516 DicomTag::AddTagsForModule(allowedTags, DicomModule_Series); | |
517 | |
518 case ResourceType_Study: | |
519 DicomTag::AddTagsForModule(allowedTags, DicomModule_Study); | |
520 | |
521 case ResourceType_Patient: | |
522 DicomTag::AddTagsForModule(allowedTags, DicomModule_Patient); | |
523 break; | |
524 | |
525 default: | |
526 throw OrthancException(ErrorCode_InternalError); | |
527 } | |
528 | |
2005
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
529 switch (level) |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
530 { |
2005
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
531 case ResourceType_Patient: |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
532 allowedTags.insert(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_STUDIES); |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
533 allowedTags.insert(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_SERIES); |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
534 allowedTags.insert(DICOM_TAG_NUMBER_OF_PATIENT_RELATED_INSTANCES); |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
535 break; |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
536 |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
537 case ResourceType_Study: |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
538 allowedTags.insert(DICOM_TAG_MODALITIES_IN_STUDY); |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
539 allowedTags.insert(DICOM_TAG_NUMBER_OF_STUDY_RELATED_SERIES); |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
540 allowedTags.insert(DICOM_TAG_NUMBER_OF_STUDY_RELATED_INSTANCES); |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
541 allowedTags.insert(DICOM_TAG_SOP_CLASSES_IN_STUDY); |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
542 break; |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
543 |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
544 case ResourceType_Series: |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
545 allowedTags.insert(DICOM_TAG_NUMBER_OF_SERIES_RELATED_INSTANCES); |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
546 break; |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
547 |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
548 default: |
9e021b2b348b
Support of optional tags for counting resources in C-Find SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
549 break; |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
550 } |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
551 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
552 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
|
553 |
1368 | 554 DicomArray query(fields); |
555 for (size_t i = 0; i < query.GetSize(); i++) | |
556 { | |
557 const DicomTag& tag = query.GetElement(i).GetTag(); | |
558 if (allowedTags.find(tag) == allowedTags.end()) | |
559 { | |
1707
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
560 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
|
561 } |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
562 else |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
563 { |
9a04ad916831
more tolerant c-find scp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1684
diff
changeset
|
564 fixedQuery.SetValue(tag, query.GetElement(i).GetValue()); |
1368 | 565 } |
566 } | |
567 } | |
568 | |
569 | |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2161
diff
changeset
|
570 static ParsedDicomFile* ConvertQueryFields(const DicomMap& fields, |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2161
diff
changeset
|
571 ModalityManufacturer manufacturer) |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
572 { |
2335 | 573 // Fix outgoing C-Find requests issue for Syngo.Via and its |
574 // solution was reported by Emsy Chan by private mail on | |
575 // 2015-06-17. According to Robert van Ommen (2015-11-30), the | |
576 // same fix is required for Agfa Impax. This was generalized for | |
577 // generic manufacturer since it seems to affect PhilipsADW, | |
578 // GEWAServer as well: | |
579 // https://bitbucket.org/sjodogne/orthanc/issues/31/ | |
2319
ae6245053bcf
made some manufacturer obsolete: MedInria (that was not used), Syngovia & AgfaImpax (replaced by GenericNoWildcardInDates) + added 'GenericNoWildcards'
amazy
parents:
2244
diff
changeset
|
580 |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
581 switch (manufacturer) |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
582 { |
2319
ae6245053bcf
made some manufacturer obsolete: MedInria (that was not used), Syngovia & AgfaImpax (replaced by GenericNoWildcardInDates) + added 'GenericNoWildcards'
amazy
parents:
2244
diff
changeset
|
583 case ModalityManufacturer_GenericNoWildcardInDates: |
2352
3ab96768d144
Fix issue 52 (DICOM level security association problems)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2340
diff
changeset
|
584 case ModalityManufacturer_GenericNoUniversalWildcard: |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
585 { |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
586 std::auto_ptr<DicomMap> fix(fields.Clone()); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
587 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
588 std::set<DicomTag> tags; |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
589 fix->GetTags(tags); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
590 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
591 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
|
592 { |
2335 | 593 // Replace a "*" wildcard query by an empty query ("") for |
594 // "date" or "all" value representations depending on the | |
595 // type of manufacturer. | |
2352
3ab96768d144
Fix issue 52 (DICOM level security association problems)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2340
diff
changeset
|
596 if (manufacturer == ModalityManufacturer_GenericNoUniversalWildcard || |
2335 | 597 (manufacturer == ModalityManufacturer_GenericNoWildcardInDates && |
598 FromDcmtkBridge::LookupValueRepresentation(*it) == ValueRepresentation_Date)) | |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
599 { |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
600 const DicomValue* value = fix->TestAndGetValue(*it); |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
601 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
602 if (value != NULL && |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1707
diff
changeset
|
603 !value->IsNull() && |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1707
diff
changeset
|
604 value->GetContent() == "*") |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
605 { |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
606 fix->SetValue(*it, "", false); |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
607 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
608 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
609 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
610 |
3342
63f59ad9381a
Fix issue #136 (C-Find request fails when found DICOM file does not have certain tags)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3215
diff
changeset
|
611 return new ParsedDicomFile(*fix, GetDefaultDicomEncoding(), false /* be strict */); |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
612 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
613 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
614 default: |
3342
63f59ad9381a
Fix issue #136 (C-Find request fails when found DICOM file does not have certain tags)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3215
diff
changeset
|
615 return new ParsedDicomFile(fields, GetDefaultDicomEncoding(), false /* be strict */); |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
616 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
617 } |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
618 |
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
619 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
620 static void ExecuteFind(DicomFindAnswers& answers, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
621 T_ASC_Association* association, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
622 DcmDataset* dataset, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
623 const char* sopClass, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
624 bool isWorklist, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
625 const char* level, |
3208
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
626 uint32_t dimseTimeout, |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
627 const std::string& remoteAet) |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
628 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
629 assert(isWorklist ^ (level != NULL)); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
630 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
631 FindPayload payload; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
632 payload.answers = &answers; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
633 payload.level = level; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
634 payload.isWorklist = isWorklist; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
635 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
636 // 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
|
637 int presID = ASC_findAcceptedPresentationContextID(association, sopClass); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
638 if (presID == 0) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
639 { |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
640 throw OrthancException(ErrorCode_DicomFindUnavailable, |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
641 "Remote AET is " + remoteAet); |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
642 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
643 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
644 T_DIMSE_C_FindRQ request; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
645 memset(&request, 0, sizeof(request)); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
646 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
|
647 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
|
648 request.Priority = DIMSE_PRIORITY_MEDIUM; |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
649 request.DataSetType = DIMSE_DATASET_PRESENT; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
650 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
651 T_DIMSE_C_FindRSP response; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
652 DcmDataset* statusDetail = NULL; |
3117 | 653 |
654 #if DCMTK_VERSION_NUMBER >= 364 | |
655 int responseCount; | |
656 #endif | |
657 | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
658 OFCondition cond = DIMSE_findUser(association, presID, &request, dataset, |
3117 | 659 #if DCMTK_VERSION_NUMBER >= 364 |
660 responseCount, | |
661 #endif | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
662 FindCallback, &payload, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
663 /*opt_blockMode*/ DIMSE_BLOCKING, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
664 /*opt_dimse_timeout*/ dimseTimeout, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
665 &response, &statusDetail); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
666 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
667 if (statusDetail) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
668 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
669 delete statusDetail; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
670 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
671 |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
672 Check(cond, remoteAet, "C-FIND"); |
3700
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
673 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
674 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
675 /** |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
676 * New in Orthanc 1.6.0: Deal with failures during C-FIND. |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
677 * http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.html#table_C.4-1 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
678 **/ |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
679 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
680 if (response.DimseStatus != 0x0000 && // Success |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
681 response.DimseStatus != 0xFF00 && // Pending - Matches are continuing |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
682 response.DimseStatus != 0xFF01) // Pending - Matches are continuing |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
683 { |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
684 char buf[16]; |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
685 sprintf(buf, "%04X", response.DimseStatus); |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
686 throw OrthancException(ErrorCode_NetworkProtocol, |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
687 "C-FIND SCU to AET \"" + remoteAet + |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
688 "\" has failed with DIMSE status 0x" + buf); |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
689 } |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
690 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
691 } |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
692 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
693 |
0 | 694 void DicomUserConnection::Find(DicomFindAnswers& result, |
1368 | 695 ResourceType level, |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
696 const DicomMap& originalFields, |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
697 bool normalize) |
0 | 698 { |
699 CheckIsOpen(); | |
700 | |
3369 | 701 std::auto_ptr<ParsedDicomFile> query; |
702 | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
703 if (normalize) |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
704 { |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
705 DicomMap fields; |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
706 NormalizeFindQuery(fields, level, originalFields); |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
707 query.reset(ConvertQueryFields(fields, manufacturer_)); |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
708 } |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3369
diff
changeset
|
709 else |
3369 | 710 { |
711 query.reset(new ParsedDicomFile(originalFields, | |
712 GetDefaultDicomEncoding(), | |
713 false /* be strict */)); | |
714 } | |
715 | |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2161
diff
changeset
|
716 DcmDataset* dataset = query->GetDcmtkObject().getDataset(); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2161
diff
changeset
|
717 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
718 const char* clevel = NULL; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
719 const char* sopClass = NULL; |
1366 | 720 |
1368 | 721 switch (level) |
0 | 722 { |
1368 | 723 case ResourceType_Patient: |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
724 clevel = "PATIENT"; |
3369 | 725 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "PATIENT"); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
726 sopClass = UID_FINDPatientRootQueryRetrieveInformationModel; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
727 break; |
0 | 728 |
1368 | 729 case ResourceType_Study: |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
730 clevel = "STUDY"; |
3369 | 731 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "STUDY"); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
732 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
733 break; |
0 | 734 |
1368 | 735 case ResourceType_Series: |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
736 clevel = "SERIES"; |
3369 | 737 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "SERIES"); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
738 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
739 break; |
0 | 740 |
1368 | 741 case ResourceType_Instance: |
3561
bdafff1ce443
C-Find SCU at Instance level now sets the 0008,0052 tag to IMAGE per default (was INSTANCE). Source: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/orthanc-users/FYxHXzlaQ0M/rn6d0SowAAAJ
Alain Mazy <alain@mazy.be>
parents:
3402
diff
changeset
|
742 clevel = "IMAGE"; |
bdafff1ce443
C-Find SCU at Instance level now sets the 0008,0052 tag to IMAGE per default (was INSTANCE). Source: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/orthanc-users/FYxHXzlaQ0M/rn6d0SowAAAJ
Alain Mazy <alain@mazy.be>
parents:
3402
diff
changeset
|
743 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "IMAGE"); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
744 sopClass = UID_FINDStudyRootQueryRetrieveInformationModel; |
1368 | 745 break; |
0 | 746 |
1368 | 747 default: |
748 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
749 } | |
750 | |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
751 |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
752 const char* universal; |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
753 if (manufacturer_ == ModalityManufacturer_GE) |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
754 { |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
755 universal = "*"; |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
756 } |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
757 else |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
758 { |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
759 universal = ""; |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
760 } |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
761 |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
762 |
1368 | 763 // Add the expected tags for this query level. |
764 // WARNING: Do not reorder or add "break" in this switch-case! | |
765 switch (level) | |
766 { | |
767 case ResourceType_Instance: | |
3369 | 768 if (!dataset->tagExists(DCM_SOPInstanceUID)) |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
769 { |
3369 | 770 DU_putStringDOElement(dataset, DCM_SOPInstanceUID, universal); |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
771 } |
1368 | 772 |
773 case ResourceType_Series: | |
3369 | 774 if (!dataset->tagExists(DCM_SeriesInstanceUID)) |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
775 { |
3369 | 776 DU_putStringDOElement(dataset, DCM_SeriesInstanceUID, universal); |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
777 } |
1368 | 778 |
779 case ResourceType_Study: | |
3369 | 780 if (!dataset->tagExists(DCM_AccessionNumber)) |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
781 { |
3369 | 782 DU_putStringDOElement(dataset, DCM_AccessionNumber, universal); |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
783 } |
0 | 784 |
3369 | 785 if (!dataset->tagExists(DCM_StudyInstanceUID)) |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
786 { |
3369 | 787 DU_putStringDOElement(dataset, DCM_StudyInstanceUID, universal); |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
788 } |
0 | 789 |
1368 | 790 case ResourceType_Patient: |
3369 | 791 if (!dataset->tagExists(DCM_PatientID)) |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
792 { |
3369 | 793 DU_putStringDOElement(dataset, DCM_PatientID, universal); |
2888
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
794 } |
61a5667f37d9
New modality manufacturer: "GE" for GE Healthcare EA and AW
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2715
diff
changeset
|
795 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
796 break; |
0 | 797 |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
798 default: |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
799 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0 | 800 } |
801 | |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
802 assert(clevel != NULL && sopClass != NULL); |
3208
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
803 ExecuteFind(result, pimpl_->assoc_, dataset, sopClass, false, clevel, |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
804 pimpl_->dimseTimeout_, remoteAet_); |
0 | 805 } |
806 | |
807 | |
1366 | 808 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
|
809 ResourceType level, |
1366 | 810 const DicomMap& fields) |
0 | 811 { |
812 CheckIsOpen(); | |
813 | |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2161
diff
changeset
|
814 std::auto_ptr<ParsedDicomFile> query(ConvertQueryFields(fields, manufacturer_)); |
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2161
diff
changeset
|
815 DcmDataset* dataset = query->GetDcmtkObject().getDataset(); |
1429
7366a0bdda6a
attempt of fix for Syngo.Via
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1427
diff
changeset
|
816 |
0 | 817 const char* sopClass = UID_MOVEStudyRootQueryRetrieveInformationModel; |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
818 switch (level) |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
819 { |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
820 case ResourceType_Patient: |
3369 | 821 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "PATIENT"); |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
822 break; |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
823 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
824 case ResourceType_Study: |
3369 | 825 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "STUDY"); |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
826 break; |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
827 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
828 case ResourceType_Series: |
3369 | 829 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "SERIES"); |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
830 break; |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
831 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
832 case ResourceType_Instance: |
3561
bdafff1ce443
C-Find SCU at Instance level now sets the 0008,0052 tag to IMAGE per default (was INSTANCE). Source: https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/orthanc-users/FYxHXzlaQ0M/rn6d0SowAAAJ
Alain Mazy <alain@mazy.be>
parents:
3402
diff
changeset
|
833 DU_putStringDOElement(dataset, DCM_QueryRetrieveLevel, "IMAGE"); |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
834 break; |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
835 |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
836 default: |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
837 throw OrthancException(ErrorCode_ParameterOutOfRange); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
838 } |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
839 |
0 | 840 // Figure out which of the accepted presentation contexts should be used |
841 int presID = ASC_findAcceptedPresentationContextID(pimpl_->assoc_, sopClass); | |
842 if (presID == 0) | |
843 { | |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
844 throw OrthancException(ErrorCode_DicomMoveUnavailable, |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
845 "Remote AET is " + remoteAet_); |
0 | 846 } |
847 | |
848 T_DIMSE_C_MoveRQ request; | |
849 memset(&request, 0, sizeof(request)); | |
850 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
|
851 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
|
852 request.Priority = DIMSE_PRIORITY_MEDIUM; |
0 | 853 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
|
854 strncpy(request.MoveDestination, targetAet.c_str(), DIC_AE_LEN); |
0 | 855 |
856 T_DIMSE_C_MoveRSP response; | |
857 DcmDataset* statusDetail = NULL; | |
858 DcmDataset* responseIdentifiers = NULL; | |
2202
9b373b7d6713
Fix handling of encodings in C-FIND requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2161
diff
changeset
|
859 OFCondition cond = DIMSE_moveUser(pimpl_->assoc_, presID, &request, dataset, |
0 | 860 NULL, NULL, |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
861 /*opt_blockMode*/ DIMSE_BLOCKING, |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
862 /*opt_dimse_timeout*/ pimpl_->dimseTimeout_, |
0 | 863 pimpl_->net_, NULL, NULL, |
864 &response, &statusDetail, &responseIdentifiers); | |
865 | |
866 if (statusDetail) | |
867 { | |
868 delete statusDetail; | |
869 } | |
870 | |
871 if (responseIdentifiers) | |
872 { | |
873 delete responseIdentifiers; | |
874 } | |
875 | |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
876 Check(cond, remoteAet_, "C-MOVE"); |
3700
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
877 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
878 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
879 /** |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
880 * New in Orthanc 1.6.0: Deal with failures during C-MOVE. |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
881 * http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.2.html#table_C.4-2 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
882 **/ |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
883 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
884 if (response.DimseStatus != 0x0000 && // Success |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
885 response.DimseStatus != 0xFF00) // Pending - Sub-operations are continuing |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
886 { |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
887 char buf[16]; |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
888 sprintf(buf, "%04X", response.DimseStatus); |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
889 throw OrthancException(ErrorCode_NetworkProtocol, |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
890 "C-MOVE SCU to AET \"" + remoteAet_ + |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
891 "\" has failed with DIMSE status 0x" + buf); |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
892 } |
0 | 893 } |
894 | |
895 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
896 void DicomUserConnection::ResetStorageSOPClasses() |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
897 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
898 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
899 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
900 storageSOPClasses_.clear(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
901 defaultStorageSOPClasses_.clear(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
902 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
903 // 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
|
904 // 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
|
905 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
906 std::set<std::string> uncommon; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
907 uncommon.insert(UID_BlendingSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
908 uncommon.insert(UID_GrayscaleSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
909 uncommon.insert(UID_ColorSoftcopyPresentationStateStorage); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
910 uncommon.insert(UID_PseudoColorSoftcopyPresentationStateStorage); |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
911 uncommon.insert(UID_XAXRFGrayscaleSoftcopyPresentationStateStorage); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
912 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
913 // Add the storage syntaxes for C-STORE |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
914 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
|
915 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
916 if (uncommon.find(dcmShortSCUStorageSOPClassUIDs[i]) == uncommon.end()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
917 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
918 defaultStorageSOPClasses_.insert(dcmShortSCUStorageSOPClassUIDs[i]); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
919 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
920 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
921 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
922 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
923 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
924 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
925 |
2587
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
926 void DicomUserConnection::DefaultSetup() |
0 | 927 { |
2587
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
928 preferredTransferSyntax_ = DEFAULT_PREFERRED_TRANSFER_SYNTAX; |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
929 localAet_ = "STORESCU"; |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
930 remoteAet_ = "ANY-SCP"; |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
931 remoteHost_ = "127.0.0.1"; |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
932 remotePort_ = 104; |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
933 manufacturer_ = ModalityManufacturer_Generic; |
0 | 934 |
2069
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
935 SetTimeout(defaultTimeout_); |
0 | 936 pimpl_->net_ = NULL; |
937 pimpl_->params_ = NULL; | |
938 pimpl_->assoc_ = NULL; | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
939 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
940 // 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
|
941 reservedStorageSOPClasses_.push_back(UID_VerificationSOPClass); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
942 reservedStorageSOPClasses_.push_back(UID_FINDPatientRootQueryRetrieveInformationModel); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
943 reservedStorageSOPClasses_.push_back(UID_FINDStudyRootQueryRetrieveInformationModel); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
944 reservedStorageSOPClasses_.push_back(UID_MOVEStudyRootQueryRetrieveInformationModel); |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
945 reservedStorageSOPClasses_.push_back(UID_FINDModalityWorklistInformationModel); |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
946 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
947 ResetStorageSOPClasses(); |
0 | 948 } |
2587
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
949 |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
950 |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
951 DicomUserConnection::DicomUserConnection() : |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
952 pimpl_(new PImpl) |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
953 { |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
954 DefaultSetup(); |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
955 } |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
956 |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
957 |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
958 DicomUserConnection::DicomUserConnection(const std::string& localAet, |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
959 const RemoteModalityParameters& remote) : |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
960 pimpl_(new PImpl) |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
961 { |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
962 DefaultSetup(); |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
963 SetLocalApplicationEntityTitle(localAet); |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
964 SetRemoteModality(remote); |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
965 } |
bf14b037731f
new constructor for DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2580
diff
changeset
|
966 |
0 | 967 |
968 DicomUserConnection::~DicomUserConnection() | |
969 { | |
970 Close(); | |
971 } | |
972 | |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
973 |
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
|
974 void DicomUserConnection::SetRemoteModality(const RemoteModalityParameters& parameters) |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
975 { |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
976 SetRemoteApplicationEntityTitle(parameters.GetApplicationEntityTitle()); |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
977 SetRemoteHost(parameters.GetHost()); |
2715
73bc0c32547c
fix embedding openssl within a DLL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2601
diff
changeset
|
978 SetRemotePort(parameters.GetPortNumber()); |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
979 SetRemoteManufacturer(parameters.GetManufacturer()); |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
980 } |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
981 |
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
769
diff
changeset
|
982 |
0 | 983 void DicomUserConnection::SetLocalApplicationEntityTitle(const std::string& aet) |
984 { | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
985 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
|
986 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
987 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
988 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
|
989 } |
0 | 990 } |
991 | |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
992 void DicomUserConnection::SetRemoteApplicationEntityTitle(const std::string& aet) |
0 | 993 { |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
994 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
|
995 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
996 Close(); |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
997 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
|
998 } |
0 | 999 } |
1000 | |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1001 void DicomUserConnection::SetRemoteManufacturer(ModalityManufacturer manufacturer) |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
1002 { |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1003 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
|
1004 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1005 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1006 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
|
1007 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1008 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1009 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1010 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
|
1011 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1012 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
|
1013 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1014 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1015 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
|
1016 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1017 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
|
1018 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1019 Close(); |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1020 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
|
1021 } |
519
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
1022 } |
1b2cdc855bd3
Parameter for PACS manufacturer, support for ClearCanvas
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
399
diff
changeset
|
1023 |
0 | 1024 |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1025 void DicomUserConnection::SetRemoteHost(const std::string& host) |
0 | 1026 { |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1027 if (remoteHost_ != host) |
0 | 1028 { |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1029 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
|
1030 { |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1031 throw OrthancException(ErrorCode_ParameterOutOfRange, |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1032 "Invalid host name (too long): " + host); |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1033 } |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1034 |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1035 Close(); |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1036 remoteHost_ = host; |
0 | 1037 } |
1038 } | |
1039 | |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1040 void DicomUserConnection::SetRemotePort(uint16_t port) |
0 | 1041 { |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1042 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
|
1043 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1044 Close(); |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1045 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
|
1046 } |
0 | 1047 } |
1048 | |
1049 void DicomUserConnection::Open() | |
1050 { | |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1051 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
|
1052 { |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1053 // 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
|
1054 return; |
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1055 } |
0 | 1056 |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
766
diff
changeset
|
1057 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
|
1058 << "\" 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
|
1059 << GetRemoteHost() << ":" << GetRemotePort() |
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1060 << " (manufacturer: " << EnumerationToString(GetRemoteManufacturer()) << ")"; |
769
3f946e5c3802
ReusableDicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
766
diff
changeset
|
1061 |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1062 Check(ASC_initializeNetwork(NET_REQUESTOR, 0, /*opt_acse_timeout*/ pimpl_->acseTimeout_, &pimpl_->net_), remoteAet_, "connecting"); |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1063 Check(ASC_createAssociationParameters(&pimpl_->params_, /*opt_maxReceivePDULength*/ ASC_DEFAULTMAXPDU), remoteAet_, "connecting"); |
0 | 1064 |
1065 // Set this application's title and the called application's title in the params | |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1066 Check(ASC_setAPTitles(pimpl_->params_, localAet_.c_str(), remoteAet_.c_str(), NULL), |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1067 remoteAet_, "connecting"); |
0 | 1068 |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1069 // Set the network addresses of the local and remote entities |
0 | 1070 char localHost[HOST_NAME_MAX]; |
1071 gethostname(localHost, HOST_NAME_MAX - 1); | |
1072 | |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1073 char remoteHostAndPort[HOST_NAME_MAX]; |
2 | 1074 |
1075 #ifdef _MSC_VER | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1076 _snprintf |
2 | 1077 #else |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1078 snprintf |
2 | 1079 #endif |
1285
5730f374e4e6
Access to called AET and remote AET from Lua scripts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1186
diff
changeset
|
1080 (remoteHostAndPort, HOST_NAME_MAX - 1, "%s:%d", remoteHost_.c_str(), remotePort_); |
0 | 1081 |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1082 Check(ASC_setPresentationAddresses(pimpl_->params_, localHost, remoteHostAndPort), |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1083 remoteAet_, "connecting"); |
0 | 1084 |
1085 // Set various options | |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1086 Check(ASC_setTransportLayerType(pimpl_->params_, /*opt_secureConnection*/ false), |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1087 remoteAet_, "connecting"); |
0 | 1088 |
662
70161eb45b5c
orthanc can act as a C-Store SCU for JPEG transfer syntax
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
657
diff
changeset
|
1089 SetupPresentationContexts(preferredTransferSyntax_); |
0 | 1090 |
1091 // Do the association | |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1092 Check(ASC_requestAssociation(pimpl_->net_, pimpl_->params_, &pimpl_->assoc_), |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1093 remoteAet_, "connecting"); |
0 | 1094 |
1095 if (ASC_countAcceptedPresentationContexts(pimpl_->params_) == 0) | |
1096 { | |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1097 throw OrthancException(ErrorCode_NoPresentationContext, |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1098 "Unable to negotiate a presentation context with AET " + |
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1099 remoteAet_); |
0 | 1100 } |
1101 } | |
1102 | |
1103 void DicomUserConnection::Close() | |
1104 { | |
1105 if (pimpl_->assoc_ != NULL) | |
1106 { | |
1107 ASC_releaseAssociation(pimpl_->assoc_); | |
1108 ASC_destroyAssociation(&pimpl_->assoc_); | |
1109 pimpl_->assoc_ = NULL; | |
1110 pimpl_->params_ = NULL; | |
1111 } | |
1112 else | |
1113 { | |
1114 if (pimpl_->params_ != NULL) | |
1115 { | |
1116 ASC_destroyAssociationParameters(&pimpl_->params_); | |
1117 pimpl_->params_ = NULL; | |
1118 } | |
1119 } | |
1120 | |
1121 if (pimpl_->net_ != NULL) | |
1122 { | |
1123 ASC_dropNetwork(&pimpl_->net_); | |
1124 pimpl_->net_ = NULL; | |
1125 } | |
1126 } | |
1127 | |
1128 bool DicomUserConnection::IsOpen() const | |
1129 { | |
1130 return pimpl_->IsOpen(); | |
1131 } | |
1132 | |
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
|
1133 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
|
1134 size_t size, |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1135 const std::string& moveOriginatorAET, |
1997
f9f2aa1cc594
"MoveOriginatorID" can be specified for /modalities/.../store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
1136 uint16_t moveOriginatorID) |
0 | 1137 { |
1138 // Prepare an input stream for the memory buffer | |
1139 DcmInputBufferStream is; | |
1140 if (size > 0) | |
1141 is.setBuffer(buffer, size); | |
1142 is.setEos(); | |
1143 | |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1144 pimpl_->Store(is, *this, moveOriginatorAET, moveOriginatorID); |
0 | 1145 } |
1146 | |
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
|
1147 void DicomUserConnection::Store(const std::string& buffer, |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1148 const std::string& moveOriginatorAET, |
1997
f9f2aa1cc594
"MoveOriginatorID" can be specified for /modalities/.../store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
1149 uint16_t moveOriginatorID) |
0 | 1150 { |
1151 if (buffer.size() > 0) | |
3402
cf31b5bacce3
removing unneeded casts
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3370
diff
changeset
|
1152 Store(&buffer[0], buffer.size(), moveOriginatorAET, moveOriginatorID); |
0 | 1153 else |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1154 Store(NULL, 0, moveOriginatorAET, moveOriginatorID); |
0 | 1155 } |
1156 | |
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
|
1157 void DicomUserConnection::StoreFile(const std::string& path, |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1158 const std::string& moveOriginatorAET, |
1997
f9f2aa1cc594
"MoveOriginatorID" can be specified for /modalities/.../store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
1159 uint16_t moveOriginatorID) |
0 | 1160 { |
1161 // Prepare an input stream for the file | |
1162 DcmInputFileStream is(path.c_str()); | |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2202
diff
changeset
|
1163 pimpl_->Store(is, *this, moveOriginatorAET, moveOriginatorID); |
0 | 1164 } |
1165 | |
1166 bool DicomUserConnection::Echo() | |
1167 { | |
1168 CheckIsOpen(); | |
1169 DIC_US status; | |
1170 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
|
1171 /*opt_blockMode*/ DIMSE_BLOCKING, |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1172 /*opt_dimse_timeout*/ pimpl_->dimseTimeout_, |
3215
4924972bce77
more verbose errors in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3208
diff
changeset
|
1173 &status, NULL), remoteAet_, "C-ECHO"); |
0 | 1174 return status == STATUS_Success; |
1175 } | |
1176 | |
1177 | |
1366 | 1178 static void TestAndCopyTag(DicomMap& result, |
1179 const DicomMap& source, | |
1180 const DicomTag& tag) | |
1181 { | |
1182 if (!source.HasTag(tag)) | |
1183 { | |
1184 throw OrthancException(ErrorCode_BadRequest); | |
1185 } | |
1186 else | |
1187 { | |
1188 result.SetValue(tag, source.GetValue(tag)); | |
1189 } | |
1190 } | |
1191 | |
1192 | |
1193 void DicomUserConnection::Move(const std::string& targetAet, | |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1194 ResourceType level, |
1366 | 1195 const DicomMap& findResult) |
0 | 1196 { |
1366 | 1197 DicomMap move; |
1198 switch (level) | |
1199 { | |
1200 case ResourceType_Patient: | |
1201 TestAndCopyTag(move, findResult, DICOM_TAG_PATIENT_ID); | |
1202 break; | |
1203 | |
1204 case ResourceType_Study: | |
1205 TestAndCopyTag(move, findResult, DICOM_TAG_STUDY_INSTANCE_UID); | |
1206 break; | |
1207 | |
1208 case ResourceType_Series: | |
1209 TestAndCopyTag(move, findResult, DICOM_TAG_STUDY_INSTANCE_UID); | |
1210 TestAndCopyTag(move, findResult, DICOM_TAG_SERIES_INSTANCE_UID); | |
1211 break; | |
1212 | |
1213 case ResourceType_Instance: | |
1214 TestAndCopyTag(move, findResult, DICOM_TAG_STUDY_INSTANCE_UID); | |
1215 TestAndCopyTag(move, findResult, DICOM_TAG_SERIES_INSTANCE_UID); | |
1216 TestAndCopyTag(move, findResult, DICOM_TAG_SOP_INSTANCE_UID); | |
1217 break; | |
1218 | |
1219 default: | |
1220 throw OrthancException(ErrorCode_InternalError); | |
1221 } | |
1222 | |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1223 MoveInternal(targetAet, level, move); |
1366 | 1224 } |
1225 | |
1226 | |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1227 void DicomUserConnection::Move(const std::string& targetAet, |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1228 const DicomMap& findResult) |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1229 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1230 if (!findResult.HasTag(DICOM_TAG_QUERY_RETRIEVE_LEVEL)) |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1231 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1232 throw OrthancException(ErrorCode_InternalError); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1233 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1234 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1235 const std::string tmp = findResult.GetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL).GetContent(); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1236 ResourceType level = StringToResourceType(tmp.c_str()); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1237 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1238 Move(targetAet, level, findResult); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1239 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1240 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1241 |
1366 | 1242 void DicomUserConnection::MovePatient(const std::string& targetAet, |
1243 const std::string& patientId) | |
1244 { | |
1245 DicomMap query; | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1246 query.SetValue(DICOM_TAG_PATIENT_ID, patientId, false); |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1247 MoveInternal(targetAet, ResourceType_Patient, query); |
1366 | 1248 } |
1249 | |
1250 void DicomUserConnection::MoveStudy(const std::string& targetAet, | |
1251 const std::string& studyUid) | |
1252 { | |
1253 DicomMap query; | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1254 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid, false); |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1255 MoveInternal(targetAet, ResourceType_Study, query); |
0 | 1256 } |
1257 | |
1258 void DicomUserConnection::MoveSeries(const std::string& targetAet, | |
1259 const std::string& studyUid, | |
1260 const std::string& seriesUid) | |
1261 { | |
1366 | 1262 DicomMap query; |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1263 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid, false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1264 query.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid, false); |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1265 MoveInternal(targetAet, ResourceType_Series, query); |
0 | 1266 } |
1267 | |
1268 void DicomUserConnection::MoveInstance(const std::string& targetAet, | |
1269 const std::string& studyUid, | |
1270 const std::string& seriesUid, | |
1271 const std::string& instanceUid) | |
1272 { | |
1366 | 1273 DicomMap query; |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1274 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyUid, false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1275 query.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid, false); |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2006
diff
changeset
|
1276 query.SetValue(DICOM_TAG_SOP_INSTANCE_UID, instanceUid, false); |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
1277 MoveInternal(targetAet, ResourceType_Instance, query); |
0 | 1278 } |
1279 | |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1280 |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1281 void DicomUserConnection::SetTimeout(uint32_t seconds) |
0 | 1282 { |
2069
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1283 if (seconds == 0) |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1284 { |
2069
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1285 DisableTimeout(); |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1286 } |
2069
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1287 else |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1288 { |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1289 dcmConnectionTimeout.set(seconds); |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1290 pimpl_->dimseTimeout_ = seconds; |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1291 pimpl_->acseTimeout_ = 10; // Timeout used during association negociation |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1292 } |
1186
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1293 } |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1294 |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1295 |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1296 void DicomUserConnection::DisableTimeout() |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1297 { |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1298 /** |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1299 * Global timeout (seconds) for connecting to remote hosts. |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1300 * 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
|
1301 */ |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1302 dcmConnectionTimeout.set(-1); |
b17b6bd59747
timeouts for HTTP and DICOM
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1017
diff
changeset
|
1303 pimpl_->dimseTimeout_ = 0; |
2069
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1304 pimpl_->acseTimeout_ = 10; // Timeout used during association negociation |
0 | 1305 } |
1306 | |
763
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1307 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1308 void DicomUserConnection::CheckStorageSOPClassesInvariant() const |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1309 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1310 assert(storageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1311 defaultStorageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1312 reservedStorageSOPClasses_.size() <= MAXIMUM_STORAGE_SOP_CLASSES); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1313 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1314 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1315 void DicomUserConnection::AddStorageSOPClass(const char* sop) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1316 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1317 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1318 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1319 if (storageSOPClasses_.find(sop) != storageSOPClasses_.end()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1320 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1321 // 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
|
1322 // nothing. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1323 return; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1324 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1325 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1326 if (defaultStorageSOPClasses_.find(sop) != defaultStorageSOPClasses_.end()) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1327 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1328 // 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
|
1329 // used by default. Just register it explicitly. |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1330 defaultStorageSOPClasses_.erase(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1331 storageSOPClasses_.insert(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1332 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1333 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1334 return; |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1335 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1336 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1337 // 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
|
1338 // 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
|
1339 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1340 Close(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1341 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1342 if (reservedStorageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1343 storageSOPClasses_.size() >= MAXIMUM_STORAGE_SOP_CLASSES) // (*) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1344 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1345 // 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
|
1346 ResetStorageSOPClasses(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1347 defaultStorageSOPClasses_.erase(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1348 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1349 else if (reservedStorageSOPClasses_.size() + storageSOPClasses_.size() + |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1350 defaultStorageSOPClasses_.size() >= MAXIMUM_STORAGE_SOP_CLASSES) |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1351 { |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1352 // Make room in the default storage syntaxes |
1303 | 1353 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
|
1354 defaultStorageSOPClasses_.erase(*defaultStorageSOPClasses_.rbegin()); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1355 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1356 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1357 // Explicitly register the new storage syntax |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1358 storageSOPClasses_.insert(sop); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1359 |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1360 CheckStorageSOPClassesInvariant(); |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1361 } |
b5e6d2823115
dynamic negotiation of storage sop classes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
732
diff
changeset
|
1362 |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1363 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1364 void DicomUserConnection::FindWorklist(DicomFindAnswers& result, |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1365 ParsedDicomFile& query) |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1366 { |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1367 CheckIsOpen(); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1368 |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1369 DcmDataset* dataset = query.GetDcmtkObject().getDataset(); |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1370 const char* sopClass = UID_FINDModalityWorklistInformationModel; |
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1371 |
3208
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
1372 ExecuteFind(result, pimpl_->assoc_, dataset, sopClass, true, |
c4e1977e5ed7
improved logging in DicomUserConnection
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3117
diff
changeset
|
1373 NULL, pimpl_->dimseTimeout_, remoteAet_); |
1805
f08978b1f45b
c-find scu for modality worklists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1374 } |
2069
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1375 |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1376 |
2601 | 1377 void DicomUserConnection::SetDefaultTimeout(uint32_t seconds) |
2069
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1378 { |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1379 LOG(INFO) << "Default timeout for DICOM connections if Orthanc acts as SCU (client): " |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1380 << seconds << " seconds (0 = no timeout)"; |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1381 defaultTimeout_ = seconds; |
fabf7820d1f1
New configuration options: "DicomScuTimeout" and "DicomScpTimeout" + validation of non-negative options
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
1382 } |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1383 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1384 |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1385 bool DicomUserConnection::IsSameAssociation(const std::string& localAet, |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1386 const RemoteModalityParameters& remote) const |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1387 { |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1388 return (localAet_ == localAet && |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1389 remoteAet_ == remote.GetApplicationEntityTitle() && |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1390 remoteHost_ == remote.GetHost() && |
2715
73bc0c32547c
fix embedding openssl within a DLL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2601
diff
changeset
|
1391 remotePort_ == remote.GetPortNumber() && |
2600
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1392 manufacturer_ == remote.GetManufacturer()); |
140a539b4eba
SequenceOfOperationsJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1393 } |
0 | 1394 } |