Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancMoveRequestHandler.cpp @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
619 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1231
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5432
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
619 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
810
diff
changeset
|
23 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
24 #include "PrecompiledHeadersServer.h" |
619 | 25 #include "OrthancMoveRequestHandler.h" |
26 | |
4045 | 27 #include "../../OrthancFramework/Sources/DicomFormat/DicomArray.h" |
28 #include "../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | |
29 #include "../../OrthancFramework/Sources/Logging.h" | |
30 #include "../../OrthancFramework/Sources/MetricsRegistry.h" | |
31 | |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
32 #include "OrthancConfiguration.h" |
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3061
diff
changeset
|
33 #include "ServerContext.h" |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
34 #include "ServerJobs/DicomModalityStoreJob.h" |
619 | 35 |
3097 | 36 |
619 | 37 namespace Orthanc |
38 { | |
39 namespace | |
40 { | |
41 // Anonymous namespace to avoid clashes between compilation modules | |
42 | |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
43 class SynchronousMove : public IMoveRequestIterator |
619 | 44 { |
45 private: | |
46 ServerContext& context_; | |
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
|
47 const std::string& localAet_; |
619 | 48 std::vector<std::string> instances_; |
49 size_t position_; | |
772
31cc399c7762
RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
771
diff
changeset
|
50 RemoteModalityParameters remote_; |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2124
diff
changeset
|
51 std::string originatorAet_; |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2124
diff
changeset
|
52 uint16_t originatorId_; |
3863
9973d10bc5c4
switch to DicomStoreUserConnection in Lua routing, C-MOVE handler and straight C-STORE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
53 std::unique_ptr<DicomStoreUserConnection> connection_; |
771 | 54 |
619 | 55 public: |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
56 SynchronousMove(ServerContext& context, |
2625
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
57 const std::string& targetAet, |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
58 const std::vector<std::string>& publicIds, |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
59 const std::string& originatorAet, |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
60 uint16_t originatorId) : |
619 | 61 context_(context), |
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
|
62 localAet_(context.GetDefaultLocalApplicationEntityTitle()), |
1907
5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
63 position_(0), |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2124
diff
changeset
|
64 originatorAet_(originatorAet), |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2124
diff
changeset
|
65 originatorId_(originatorId) |
619 | 66 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
67 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
68 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
69 remote_ = lock.GetConfiguration().GetModalityUsingAet(targetAet); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
70 } |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
71 |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
72 for (size_t i = 0; i < publicIds.size(); i++) |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
73 { |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4174
diff
changeset
|
74 CLOG(INFO, DICOM) << "Sending resource " << publicIds[i] << " to modality \"" |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4174
diff
changeset
|
75 << targetAet << "\" in synchronous mode"; |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
76 |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
77 std::list<std::string> tmp; |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
78 context_.GetIndex().GetChildInstances(tmp, publicIds[i]); |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
79 |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
80 instances_.reserve(tmp.size()); |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
81 for (std::list<std::string>::iterator it = tmp.begin(); it != tmp.end(); ++it) |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
82 { |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
83 instances_.push_back(*it); |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
84 } |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
85 } |
619 | 86 } |
87 | |
88 virtual unsigned int GetSubOperationCount() const | |
89 { | |
90 return instances_.size(); | |
91 } | |
92 | |
93 virtual Status DoNext() | |
94 { | |
95 if (position_ >= instances_.size()) | |
96 { | |
97 return Status_Failure; | |
98 } | |
99 | |
100 const std::string& id = instances_[position_++]; | |
101 | |
102 std::string dicom; | |
2124 | 103 context_.ReadDicom(dicom, id); |
771 | 104 |
2590
5e2730c8e23c
getting rid of ReusableDicomConnection in QueryRetrieveHandler and OrthancMoveRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
105 if (connection_.get() == NULL) |
771 | 106 { |
3874
2effa961f67f
forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3863
diff
changeset
|
107 DicomAssociationParameters params(localAet_, remote_); |
2effa961f67f
forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3863
diff
changeset
|
108 connection_.reset(new DicomStoreUserConnection(params)); |
771 | 109 } |
619 | 110 |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3712
diff
changeset
|
111 std::string sopClassUid, sopInstanceUid; // Unused |
4174
067c679626a2
Fix transcoding in C-MOVE SCP, in the case where "SynchronousCMove" is "true"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4165
diff
changeset
|
112 context_.StoreWithTranscoding(sopClassUid, sopInstanceUid, *connection_, dicom, |
067c679626a2
Fix transcoding in C-MOVE SCP, in the case where "SynchronousCMove" is "true"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4165
diff
changeset
|
113 true, originatorAet_, originatorId_); |
2590
5e2730c8e23c
getting rid of ReusableDicomConnection in QueryRetrieveHandler and OrthancMoveRequestHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
114 |
619 | 115 return Status_Success; |
116 } | |
117 }; | |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
118 |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
119 |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
120 class AsynchronousMove : public IMoveRequestIterator |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
121 { |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
122 private: |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3700
diff
changeset
|
123 ServerContext& context_; |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3700
diff
changeset
|
124 std::unique_ptr<DicomModalityStoreJob> job_; |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3700
diff
changeset
|
125 size_t position_; |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3700
diff
changeset
|
126 size_t countInstances_; |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
127 |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
128 public: |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
129 AsynchronousMove(ServerContext& context, |
2625
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
130 const std::string& targetAet, |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
131 const std::vector<std::string>& publicIds, |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
132 const std::string& originatorAet, |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
133 uint16_t originatorId) : |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
134 context_(context), |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
135 job_(new DicomModalityStoreJob(context)), |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
136 position_(0) |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
137 { |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
138 job_->SetDescription("C-MOVE"); |
3700
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3697
diff
changeset
|
139 //job_->SetPermissive(true); // This was the behavior of Orthanc < 1.6.0 |
5cbbf14e516b
Fix issue #103 ("queries/.../retrieve" API returns HTTP code 200 even on server errors)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3697
diff
changeset
|
140 job_->SetPermissive(false); |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
141 job_->SetLocalAet(context.GetDefaultLocalApplicationEntityTitle()); |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
142 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
143 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
144 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
145 job_->SetRemoteModality(lock.GetConfiguration().GetModalityUsingAet(targetAet)); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
146 } |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
147 |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
148 if (originatorId != 0) |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
149 { |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
150 job_->SetMoveOriginator(originatorAet, originatorId); |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
151 } |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
152 |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
153 for (size_t i = 0; i < publicIds.size(); i++) |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
154 { |
4287
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4174
diff
changeset
|
155 CLOG(INFO, DICOM) << "Sending resource " << publicIds[i] << " to modality \"" |
5a3374b6e707
using CLOG in Orthanc DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4174
diff
changeset
|
156 << targetAet << "\" in asynchronous mode"; |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
157 |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
158 std::list<std::string> tmp; |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
159 context_.GetIndex().GetChildInstances(tmp, publicIds[i]); |
3157
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
160 |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
161 countInstances_ = tmp.size(); |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
162 |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
163 job_->Reserve(job_->GetCommandsCount() + tmp.size()); |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
164 |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
165 for (std::list<std::string>::iterator it = tmp.begin(); it != tmp.end(); ++it) |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
166 { |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
167 job_->AddInstance(*it); |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
168 } |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
169 } |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
170 } |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
171 |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
172 virtual unsigned int GetSubOperationCount() const |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
173 { |
3157
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
174 return countInstances_; |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
175 } |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
176 |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
177 virtual Status DoNext() |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
178 { |
3157
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
179 if (position_ >= countInstances_) |
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
180 { |
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
181 return Status_Failure; |
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
182 } |
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
183 |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
184 if (position_ == 0) |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
185 { |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
186 context_.GetJobsEngine().GetRegistry().Submit(job_.release(), 0 /* priority */); |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
187 } |
3157
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
188 |
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
189 position_ ++; |
8a9eb767280c
Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
190 return Status_Success; |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
191 } |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2590
diff
changeset
|
192 }; |
619 | 193 } |
194 | |
195 | |
4165
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
196 static bool IsNonEmptyTag(const DicomMap& dicom, |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
197 const DicomTag& tag) |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
198 { |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
199 const DicomValue* value = dicom.TestAndGetValue(tag); |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
200 if (value == NULL || |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
201 value->IsNull() || |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
202 value->IsBinary()) |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
203 { |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
204 return false; |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
205 } |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
206 else |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
207 { |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
208 return !value->GetContent().empty(); |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
209 } |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
210 } |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
211 |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
212 |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
213 bool OrthancMoveRequestHandler::LookupIdentifiers(std::vector<std::string>& publicIds, |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
214 ResourceType level, |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
215 const DicomMap& input) |
619 | 216 { |
1724
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
217 DicomTag tag(0, 0); // Dummy initialization |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
218 |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
219 switch (level) |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
220 { |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
221 case ResourceType_Patient: |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
222 tag = DICOM_TAG_PATIENT_ID; |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
223 break; |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
224 |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
225 case ResourceType_Study: |
4165
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
226 // The test below using "IsNonEmptyTag()" fixes compatibility |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
227 // with Ambra C-FIND SCU: |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
228 // https://groups.google.com/g/orthanc-users/c/yIUnZ9v9-Zs/m/GQPXiAOiCQAJ |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
229 if (IsNonEmptyTag(input, DICOM_TAG_ACCESSION_NUMBER)) |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
230 { |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
231 tag = DICOM_TAG_ACCESSION_NUMBER; |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
232 } |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
233 else |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
234 { |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
235 tag = DICOM_TAG_STUDY_INSTANCE_UID; |
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
236 } |
1724
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
237 break; |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
238 |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
239 case ResourceType_Series: |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
240 tag = DICOM_TAG_SERIES_INSTANCE_UID; |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
241 break; |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
242 |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
243 case ResourceType_Instance: |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
244 tag = DICOM_TAG_SOP_INSTANCE_UID; |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
245 break; |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
246 |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
247 default: |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
248 throw OrthancException(ErrorCode_ParameterOutOfRange); |
7e0b5e413c7c
C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1721
diff
changeset
|
249 } |
1721
3bcb01028107
removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
250 |
619 | 251 if (!input.HasTag(tag)) |
252 { | |
253 return false; | |
254 } | |
255 | |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
256 const DicomValue& value = input.GetValue(tag); |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
257 if (value.IsNull() || |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
258 value.IsBinary()) |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
259 { |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
260 return false; |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
261 } |
619 | 262 else |
263 { | |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
264 const std::string& content = value.GetContent(); |
3697
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
265 |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
266 /** |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
267 * This tokenization fixes issue 154 ("Matching against list of |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
268 * UID-s by C-MOVE"). |
5432
59e3b6f8c5be
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
269 * https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=154 |
3697
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
270 **/ |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
271 |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
272 std::vector<std::string> tokens; |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
273 Toolbox::TokenizeString(tokens, content, '\\'); |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
274 for (size_t i = 0; i < tokens.size(); i++) |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
275 { |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
276 std::vector<std::string> matches; |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
277 context_.GetIndex().LookupIdentifierExact(matches, level, tag, tokens[i]); |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
278 |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
279 // Concatenate "publicIds" with "matches" |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
280 publicIds.insert(publicIds.end(), matches.begin(), matches.end()); |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
281 } |
5331918773e7
Fix issue #154 (Matching against list of UID-s by C-MOVE)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
282 |
619 | 283 return true; |
284 } | |
285 } | |
286 | |
287 | |
2625
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
288 static IMoveRequestIterator* CreateIterator(ServerContext& context, |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
289 const std::string& targetAet, |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
290 const std::vector<std::string>& publicIds, |
2625
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
291 const std::string& originatorAet, |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
292 uint16_t originatorId) |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
293 { |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
294 if (publicIds.empty()) |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
295 { |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
296 throw OrthancException(ErrorCode_BadRequest, |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
297 "C-MOVE request matching no resource stored in Orthanc"); |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
298 } |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
299 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
300 bool synchronous; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
301 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
302 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
303 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
304 synchronous = lock.GetConfiguration().GetBooleanParameter("SynchronousCMove", true); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2932
diff
changeset
|
305 } |
2625
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
306 |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
307 if (synchronous) |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
308 { |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
309 return new SynchronousMove(context, targetAet, publicIds, originatorAet, originatorId); |
2625
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
310 } |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
311 else |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
312 { |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
313 return new AsynchronousMove(context, targetAet, publicIds, originatorAet, originatorId); |
2625
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
314 } |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
315 } |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
316 |
5469dda691cd
new configuration option: SynchronousCMove
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2624
diff
changeset
|
317 |
1573
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
318 IMoveRequestIterator* OrthancMoveRequestHandler::Handle(const std::string& targetAet, |
3309878b3e16
more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
319 const DicomMap& input, |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2124
diff
changeset
|
320 const std::string& originatorIp, |
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2124
diff
changeset
|
321 const std::string& originatorAet, |
1909
21fcfc428dc2
another semantics for Originator Message ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1907
diff
changeset
|
322 const std::string& calledAet, |
2222
21713ce8717b
Fix handling of Move Originator AET and ID in C-MOVE SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2124
diff
changeset
|
323 uint16_t originatorId) |
619 | 324 { |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3157
diff
changeset
|
325 MetricsRegistry::Timer timer(context_.GetMetricsRegistry(), "orthanc_move_scp_duration_ms"); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3157
diff
changeset
|
326 |
4806 | 327 CLOG(INFO, DICOM) << "Move-SCU request received for AET \"" << targetAet << "\""; |
619 | 328 |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
329 { |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
330 DicomArray query(input); |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
331 for (size_t i = 0; i < query.GetSize(); i++) |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
332 { |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
333 if (!query.GetElement(i).GetValue().IsNull()) |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
334 { |
4313
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4287
diff
changeset
|
335 CLOG(INFO, DICOM) << " (" << query.GetElement(i).GetTag().Format() |
91554aecff9a
removed a friend method for better abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4287
diff
changeset
|
336 << ") " << FromDcmtkBridge::GetTagName(query.GetElement(i)) |
4376
b002f9abe802
review of changeset 4375:208029732d51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4375
diff
changeset
|
337 << " = " << context_.GetDeidentifiedContent(query.GetElement(i)); |
1371
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
338 } |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
339 } |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
340 } |
f528849ee9f7
DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1288
diff
changeset
|
341 |
619 | 342 /** |
343 * Retrieve the query level. | |
344 **/ | |
345 | |
346 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); | |
1231
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
347 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
348 if (levelTmp == NULL || |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
349 levelTmp->IsNull() || |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
350 levelTmp->IsBinary()) |
619 | 351 { |
1231
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
352 // The query level is not present in the C-Move request, which |
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
353 // does not follow the DICOM standard. This is for instance the |
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
354 // behavior of Tudor DICOM. Try and automatically deduce the |
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
355 // query level: Start from the instance level, going up to the |
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
356 // patient level until a valid DICOM identifier is found. |
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
357 |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
358 std::vector<std::string> publicIds; |
1231
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
359 |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
360 if (LookupIdentifiers(publicIds, ResourceType_Instance, input) || |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
361 LookupIdentifiers(publicIds, ResourceType_Series, input) || |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
362 LookupIdentifiers(publicIds, ResourceType_Study, input) || |
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
363 LookupIdentifiers(publicIds, ResourceType_Patient, input)) |
1231
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
364 { |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
365 return CreateIterator(context_, targetAet, publicIds, originatorAet, originatorId); |
1231
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
366 } |
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
367 else |
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
368 { |
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
369 // No identifier is present in the request. |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
370 throw OrthancException(ErrorCode_BadRequest, "Invalid fields in a C-MOVE request"); |
1231
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
371 } |
619 | 372 } |
373 | |
1721
3bcb01028107
removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
374 assert(levelTmp != NULL); |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1724
diff
changeset
|
375 ResourceType level = StringToResourceType(levelTmp->GetContent().c_str()); |
1231
703fcd797186
Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
376 |
619 | 377 |
378 /** | |
379 * Lookup for the resource to be sent. | |
380 **/ | |
381 | |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
382 std::vector<std::string> publicIds; |
619 | 383 |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
384 if (LookupIdentifiers(publicIds, level, input)) |
619 | 385 { |
3301
6ce10c3b1eb7
Fix issue #131 (C-MOVE failure due to duplicate StudyInstanceUID in the database)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
386 return CreateIterator(context_, targetAet, publicIds, originatorAet, originatorId); |
619 | 387 } |
1721
3bcb01028107
removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
388 else |
619 | 389 { |
4165
e34c89e89aac
Fix compatibility with C-MOVE SCU requests issued by Ambra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
390 throw OrthancException(ErrorCode_BadRequest, "No DICOM identifier provided in the C-MOVE request for this query retrieve level"); |
619 | 391 } |
392 } | |
393 } |