annotate OrthancServer/DicomProtocol/DicomUserConnection.cpp @ 1707:9a04ad916831

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