annotate OrthancServer/OrthancMoveRequestHandler.cpp @ 1928:84c7eaeb5244

Configuration::GetDefaultEncoding
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Mar 2016 14:12:31 +0100
parents 21fcfc428dc2
children a657f7772e69
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1799
diff changeset
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
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 810
diff changeset
32
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
33 #include "PrecompiledHeadersServer.h"
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "OrthancMoveRequestHandler.h"
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "OrthancInitialization.h"
1371
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
37 #include "FromDcmtkBridge.h"
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
38 #include "../Core/DicomFormat/DicomArray.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
39 #include "../Core/Logging.h"
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 namespace Orthanc
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 namespace
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 // Anonymous namespace to avoid clashes between compilation modules
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 class OrthancMoveRequestIterator : public IMoveRequestIterator
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 private:
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 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
51 const std::string& localAet_;
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 std::vector<std::string> instances_;
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 size_t position_;
772
31cc399c7762 RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 771
diff changeset
54 RemoteModalityParameters remote_;
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
55 uint16_t moveRequestID_;
771
537837f50fbb refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
56
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 public:
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 OrthancMoveRequestIterator(ServerContext& context,
771
537837f50fbb refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
59 const std::string& aet,
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
60 const std::string& publicId,
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
61 uint16_t moveRequestID) :
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 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
63 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
64 position_(0),
5011a597b6ce Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
65 moveRequestID_(moveRequestID)
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
771
537837f50fbb refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
67 LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\"";
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 std::list<std::string> tmp;
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 context_.GetIndex().GetChildInstances(tmp, publicId);
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 instances_.reserve(tmp.size());
656
08eca5d86aad fixes to cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 619
diff changeset
73 for (std::list<std::string>::iterator it = tmp.begin(); it != tmp.end(); ++it)
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 instances_.push_back(*it);
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
771
537837f50fbb refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
77
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 776
diff changeset
78 remote_ = Configuration::GetModalityUsingAet(aet);
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 virtual unsigned int GetSubOperationCount() const
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 return instances_.size();
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 virtual Status DoNext()
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 if (position_ >= instances_.size())
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 return Status_Failure;
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 const std::string& id = instances_[position_++];
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 std::string dicom;
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 context_.ReadFile(dicom, id, FileContentType_Dicom);
771
537837f50fbb refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
97
537837f50fbb refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
98 {
776
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 772
diff changeset
99 ReusableDicomUserConnection::Locker locker
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
100 (context_.GetReusableDicomUserConnection(), localAet_, remote_);
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
101 locker.GetConnection().Store(dicom, moveRequestID_);
771
537837f50fbb refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 722
diff changeset
102 }
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 return Status_Success;
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 };
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
1162
1ea4094d077c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
110 bool OrthancMoveRequestHandler::LookupIdentifier(std::string& publicId,
1721
3bcb01028107 removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
111 ResourceType level,
1231
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
112 const DicomMap& input)
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 {
1724
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
114 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
115
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
116 switch (level)
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
117 {
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
118 case ResourceType_Patient:
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
119 tag = DICOM_TAG_PATIENT_ID;
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
120 break;
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
121
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
122 case ResourceType_Study:
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
123 tag = (input.HasTag(DICOM_TAG_ACCESSION_NUMBER) ?
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
124 DICOM_TAG_ACCESSION_NUMBER : DICOM_TAG_STUDY_INSTANCE_UID);
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
125 break;
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
126
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
127 case ResourceType_Series:
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
128 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
129 break;
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
130
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
131 case ResourceType_Instance:
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
132 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
133 break;
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
134
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
135 default:
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
136 throw OrthancException(ErrorCode_ParameterOutOfRange);
7e0b5e413c7c C-Move SCP for studies using AccessionNumber tag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1721
diff changeset
137 }
1721
3bcb01028107 removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
138
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 if (!input.HasTag(tag))
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 return false;
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
144 const DicomValue& value = input.GetValue(tag);
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
145 if (value.IsNull() ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
146 value.IsBinary())
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
147 {
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
148 return false;
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
149 }
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
150
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
151 const std::string& content = value.GetContent();
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 std::list<std::string> ids;
1744
b3de74dec2d5 integration mainline->db-changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1728 1737
diff changeset
154 context_.GetIndex().LookupIdentifierExact(ids, level, tag, content);
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 if (ids.size() != 1)
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 return false;
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 else
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 publicId = ids.front();
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 return true;
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
1573
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
168 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
169 const DicomMap& input,
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
170 const std::string& remoteIp,
1799
4f01c9d73f02 calledAet made available to all the handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1744
diff changeset
171 const std::string& remoteAet,
1909
21fcfc428dc2 another semantics for Originator Message ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1907
diff changeset
172 const std::string& calledAet,
21fcfc428dc2 another semantics for Originator Message ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1907
diff changeset
173 uint16_t messageId)
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 {
1573
3309878b3e16 more information about the origin of requests submitted to the DICOM handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
175 LOG(WARNING) << "Move-SCU request received for AET \"" << targetAet << "\"";
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
1371
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
177 {
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
178 DicomArray query(input);
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
179 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
180 {
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
181 if (!query.GetElement(i).GetValue().IsNull())
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
182 {
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
183 LOG(INFO) << " " << query.GetElement(i).GetTag()
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
184 << " " << FromDcmtkBridge::GetName(query.GetElement(i).GetTag())
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
185 << " = " << query.GetElement(i).GetValue().GetContent();
1371
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
186 }
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
187 }
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
188 }
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
189
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
190
1909
21fcfc428dc2 another semantics for Originator Message ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1907
diff changeset
191 #if 0
1907
5011a597b6ce Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
192 /**
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
193 * Retrieve the Message ID (0000,0110) for this C-MOVE request, if
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
194 * any. If present, this Message ID will be stored in the Move
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
195 * Originator Message ID (0000,1031) field of the C-MOVE response.
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
196 * http://dicom.nema.org/medical/dicom/current/output/html/part07.html#sect_9.3.1
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
197 **/
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
198
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
199 static const DicomTag MESSAGE_ID(0x0000, 0x0110);
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
200 const DicomValue* messageIdTmp = input.TestAndGetValue(MESSAGE_ID);
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
201
1909
21fcfc428dc2 another semantics for Originator Message ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1907
diff changeset
202 messageId = 0;
1907
5011a597b6ce Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
203
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
204 if (messageIdTmp != NULL &&
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
205 !messageIdTmp->IsNull() &&
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
206 !messageIdTmp->IsBinary())
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
207 {
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
208 try
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
209 {
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
210 messageId = boost::lexical_cast<uint16_t>(messageIdTmp->GetContent());
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
211 }
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
212 catch (boost::bad_lexical_cast&)
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
213 {
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
214 LOG(WARNING) << "Cannot convert the Message ID (\"" << messageIdTmp ->GetContent()
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
215 << "\") of an incoming C-MOVE request to an integer, assuming zero";
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
216 }
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
217 }
1909
21fcfc428dc2 another semantics for Originator Message ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1907
diff changeset
218 #endif
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
219
1371
f528849ee9f7 DICOM Query/Retrieve available from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
220
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 /**
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 * Retrieve the query level.
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 **/
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 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
226
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
227 if (levelTmp == NULL ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
228 levelTmp->IsNull() ||
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
229 levelTmp->IsBinary())
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 {
1231
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
231 // 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
232 // 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
233 // 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
234 // 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
235 // 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
236
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
237 std::string publicId;
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
238
1721
3bcb01028107 removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
239 if (LookupIdentifier(publicId, ResourceType_Instance, input) ||
3bcb01028107 removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
240 LookupIdentifier(publicId, ResourceType_Series, input) ||
3bcb01028107 removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
241 LookupIdentifier(publicId, ResourceType_Study, input) ||
3bcb01028107 removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
242 LookupIdentifier(publicId, ResourceType_Patient, input))
1231
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
243 {
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
244 return new OrthancMoveRequestIterator(context_, targetAet, publicId, messageId);
1231
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
245 }
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
246 else
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
247 {
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
248 // No identifier is present in the request.
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
249 throw OrthancException(ErrorCode_BadRequest);
703fcd797186 Support of Tudor DICOM in Query/Retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
250 }
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252
1721
3bcb01028107 removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
253 assert(levelTmp != NULL);
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1724
diff changeset
254 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
255
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 /**
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 * Lookup for the resource to be sent.
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 **/
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 std::string publicId;
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262
1721
3bcb01028107 removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
263 if (LookupIdentifier(publicId, level, input))
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 {
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
265 return new OrthancMoveRequestIterator(context_, targetAet, publicId, messageId);
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 }
1721
3bcb01028107 removed another flavor of ServerIndex::LookupIdentifier
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
267 else
619
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 {
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 throw OrthancException(ErrorCode_BadRequest);
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 }
70d0f27e5bd3 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 }