Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerJobs/DicomGetScuJob.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 | |
children |
rev | line source |
---|---|
5853
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
1 /** |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
8 * |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
9 * This program is free software: you can redistribute it and/or |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU General Public License as |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
11 * published by the Free Software Foundation, either version 3 of the |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
12 * License, or (at your option) any later version. |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
13 * |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
17 * General Public License for more details. |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
18 * |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
21 **/ |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
22 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
23 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
24 #include "DicomGetScuJob.h" |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
25 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
26 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
27 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
28 #include "../ServerContext.h" |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
29 #include <dcmtk/dcmnet/dimse.h> |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
30 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
31 static const char* const LOCAL_AET = "LocalAet"; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
32 static const char* const QUERY = "Query"; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
33 static const char* const QUERY_FORMAT = "QueryFormat"; // New in 1.9.5 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
34 static const char* const REMOTE = "Remote"; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
35 static const char* const TIMEOUT = "Timeout"; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
36 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
37 namespace Orthanc |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
38 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
39 class DicomGetScuJob::Command : public SetOfCommandsJob::ICommand |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
40 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
41 private: |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
42 DicomGetScuJob& that_; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
43 std::unique_ptr<DicomMap> findAnswer_; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
44 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
45 public: |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
46 Command(DicomGetScuJob& that, |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
47 const DicomMap& findAnswer) : |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
48 that_(that), |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
49 findAnswer_(findAnswer.Clone()) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
50 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
51 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
52 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
53 virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
54 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
55 that_.Retrieve(*findAnswer_); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
56 return true; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
57 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
58 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
59 virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
60 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
61 findAnswer_->Serialize(target); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
62 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
63 }; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
64 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
65 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
66 class DicomGetScuJob::Unserializer : |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
67 public SetOfCommandsJob::ICommandUnserializer |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
68 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
69 private: |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
70 DicomGetScuJob& that_; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
71 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
72 public: |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
73 explicit Unserializer(DicomGetScuJob& that) : |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
74 that_(that) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
75 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
76 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
77 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
78 virtual ICommand* Unserialize(const Json::Value& source) const ORTHANC_OVERRIDE |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
79 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
80 DicomMap findAnswer; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
81 findAnswer.Unserialize(source); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
82 return new Command(that_, findAnswer); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
83 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
84 }; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
85 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
86 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
87 static uint16_t InstanceReceivedHandler(void* callbackContext, |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
88 DcmDataset& dataset, |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
89 const std::string& remoteAet, |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
90 const std::string& remoteIp, |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
91 const std::string& calledAet) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
92 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
93 // this code is equivalent to OrthancStoreRequestHandler |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
94 ServerContext* context = reinterpret_cast<ServerContext*>(callbackContext); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
95 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
96 std::unique_ptr<DicomInstanceToStore> toStore(DicomInstanceToStore::CreateFromDcmDataset(dataset)); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
97 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
98 if (toStore->GetBufferSize() > 0) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
99 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
100 toStore->SetOrigin(DicomInstanceOrigin::FromDicomProtocol |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
101 (remoteIp.c_str(), remoteAet.c_str(), calledAet.c_str())); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
102 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
103 std::string id; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
104 ServerContext::StoreResult result = context->Store(id, *toStore, StoreInstanceMode_Default); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
105 return result.GetCStoreStatusCode(); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
106 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
107 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
108 return STATUS_STORE_Error_CannotUnderstand; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
109 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
110 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
111 void DicomGetScuJob::Retrieve(const DicomMap& findAnswer) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
112 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
113 if (connection_.get() == NULL) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
114 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
115 connection_.reset(new DicomControlUserConnection(parameters_)); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
116 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
117 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
118 connection_->Get(findAnswer, InstanceReceivedHandler, &context_); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
119 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
120 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
121 void DicomGetScuJob::AddResourceToRetrieve(ResourceType level, const std::string& dicomId) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
122 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
123 // TODO-GET: when retrieving a single series, one must provide the StudyInstanceUID too |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
124 DicomMap item; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
125 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
126 switch (level) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
127 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
128 case ResourceType_Patient: |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
129 item.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, ResourceTypeToDicomQueryRetrieveLevel(level), false); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
130 item.SetValue(DICOM_TAG_PATIENT_ID, dicomId, false); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
131 break; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
132 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
133 case ResourceType_Study: |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
134 item.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, ResourceTypeToDicomQueryRetrieveLevel(level), false); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
135 item.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, dicomId, false); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
136 break; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
137 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
138 case ResourceType_Series: |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
139 item.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, ResourceTypeToDicomQueryRetrieveLevel(level), false); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
140 item.SetValue(DICOM_TAG_SERIES_INSTANCE_UID, dicomId, false); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
141 break; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
142 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
143 case ResourceType_Instance: |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
144 item.SetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL, ResourceTypeToDicomQueryRetrieveLevel(level), false); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
145 item.SetValue(DICOM_TAG_SOP_INSTANCE_UID, dicomId, false); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
146 break; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
147 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
148 default: |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
149 throw OrthancException(ErrorCode_InternalError); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
150 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
151 query_.Add(item); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
152 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
153 AddCommand(new Command(*this, item)); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
154 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
155 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
156 void DicomGetScuJob::SetLocalAet(const std::string& aet) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
157 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
158 if (IsStarted()) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
159 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
160 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
161 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
162 else |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
163 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
164 parameters_.SetLocalApplicationEntityTitle(aet); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
165 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
166 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
167 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
168 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
169 void DicomGetScuJob::SetRemoteModality(const RemoteModalityParameters& remote) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
170 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
171 if (IsStarted()) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
172 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
173 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
174 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
175 else |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
176 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
177 parameters_.SetRemoteModality(remote); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
178 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
179 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
180 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
181 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
182 void DicomGetScuJob::SetTimeout(uint32_t seconds) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
183 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
184 if (IsStarted()) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
185 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
186 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
187 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
188 else |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
189 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
190 parameters_.SetTimeout(seconds); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
191 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
192 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
193 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
194 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
195 void DicomGetScuJob::Stop(JobStopReason reason) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
196 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
197 connection_.reset(); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
198 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
199 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
200 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
201 void DicomGetScuJob::SetQueryFormat(DicomToJsonFormat format) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
202 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
203 if (IsStarted()) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
204 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
205 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
206 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
207 else |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
208 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
209 queryFormat_ = format; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
210 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
211 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
212 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
213 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
214 void DicomGetScuJob::GetPublicContent(Json::Value& value) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
215 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
216 SetOfCommandsJob::GetPublicContent(value); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
217 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
218 value[LOCAL_AET] = parameters_.GetLocalApplicationEntityTitle(); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
219 value["RemoteAet"] = parameters_.GetRemoteModality().GetApplicationEntityTitle(); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
220 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
221 value[QUERY] = Json::objectValue; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
222 // query_.ToJson(value[QUERY], queryFormat_); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
223 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
224 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
225 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
226 DicomGetScuJob::DicomGetScuJob(ServerContext& context, |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
227 const Json::Value& serialized) : |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
228 SetOfCommandsJob(new Unserializer(*this), serialized), |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
229 context_(context), |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
230 parameters_(DicomAssociationParameters::UnserializeJob(serialized)), |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
231 // targetAet_(SerializationToolbox::ReadString(serialized, TARGET_AET)), |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
232 query_(true), |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
233 queryFormat_(DicomToJsonFormat_Short) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
234 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
235 if (serialized.isMember(QUERY)) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
236 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
237 const Json::Value& query = serialized[QUERY]; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
238 if (query.type() == Json::arrayValue) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
239 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
240 for (Json::Value::ArrayIndex i = 0; i < query.size(); i++) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
241 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
242 DicomMap item; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
243 FromDcmtkBridge::FromJson(item, query[i]); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
244 // AddToQuery(query_, item); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
245 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
246 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
247 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
248 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
249 if (serialized.isMember(QUERY_FORMAT)) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
250 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
251 queryFormat_ = StringToDicomToJsonFormat(SerializationToolbox::ReadString(serialized, QUERY_FORMAT)); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
252 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
253 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
254 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
255 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
256 bool DicomGetScuJob::Serialize(Json::Value& target) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
257 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
258 if (!SetOfCommandsJob::Serialize(target)) |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
259 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
260 return false; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
261 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
262 else |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
263 { |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
264 parameters_.SerializeJob(target); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
265 // target[TARGET_AET] = targetAet_; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
266 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
267 // "Short" is for compatibility with Orthanc <= 1.9.4 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
268 target[QUERY] = Json::objectValue; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
269 // query_.ToJson(target[QUERY], DicomToJsonFormat_Short); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
270 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
271 target[QUERY_FORMAT] = EnumerationToString(queryFormat_); |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
272 |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
273 return true; |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
274 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
275 } |
4d932683049d
very first implementation of C-Get SCU
Alain Mazy <am@orthanc.team>
parents:
diff
changeset
|
276 } |