Mercurial > hg > orthanc
annotate OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 3680:453c0ece560a
news
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 20 Feb 2020 20:09:24 +0100 |
parents | 46cb00e4adbb |
children | 335611d2b6cd 4922bdd046dd |
rev | line source |
---|---|
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
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:
1165
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3592
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * License, or (at your option) any later version. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * program give permission to link the code of its release with the |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * in the program, then also delete it here. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * General Public License for more details. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 **/ |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
34 #include "../PrecompiledHeadersServer.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include "OrthancRestApi.h" |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
37 #include "../../Core/Cache/SharedArchive.h" |
2602 | 38 #include "../../Core/DicomParsing/FromDcmtkBridge.h" |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1446
diff
changeset
|
39 #include "../../Core/Logging.h" |
2867 | 40 #include "../../Core/SerializationToolbox.h" |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
41 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
42 #include "../OrthancConfiguration.h" |
1368 | 43 #include "../QueryRetrieveHandler.h" |
3097 | 44 #include "../ServerContext.h" |
2602 | 45 #include "../ServerJobs/DicomModalityStoreJob.h" |
2867 | 46 #include "../ServerJobs/DicomMoveScuJob.h" |
2602 | 47 #include "../ServerJobs/OrthancPeerStoreJob.h" |
1368 | 48 #include "../ServerToolbox.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
50 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 namespace Orthanc |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 { |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
53 static const char* const KEY_LEVEL = "Level"; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
54 static const char* const KEY_QUERY = "Query"; |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
55 static const char* const KEY_NORMALIZE = "Normalize"; |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
56 static const char* const KEY_RESOURCES = "Resources"; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
57 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
58 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
59 static RemoteModalityParameters MyGetModalityUsingSymbolicName(const std::string& name) |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
60 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
61 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
62 return lock.GetConfiguration().GetModalityUsingSymbolicName(name); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
63 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
64 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
65 |
1368 | 66 /*************************************************************************** |
67 * DICOM C-Echo SCU | |
68 ***************************************************************************/ | |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
69 |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
70 static void DicomEcho(RestApiPostCall& call) |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
71 { |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
72 ServerContext& context = OrthancRestApi::GetContext(call); |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
73 |
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:
1368
diff
changeset
|
74 const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
75 RemoteModalityParameters remote = |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
76 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
77 |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
78 try |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
79 { |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
80 DicomUserConnection connection(localAet, remote); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
81 connection.Open(); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
82 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
83 if (connection.Echo()) |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
84 { |
1165
0561f2087cc9
Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1142
diff
changeset
|
85 // Echo has succeeded |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
86 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
1165
0561f2087cc9
Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1142
diff
changeset
|
87 return; |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
88 } |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
89 } |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
90 catch (OrthancException&) |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
91 { |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
92 } |
1165
0561f2087cc9
Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1142
diff
changeset
|
93 |
0561f2087cc9
Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1142
diff
changeset
|
94 // Echo has failed |
0561f2087cc9
Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1142
diff
changeset
|
95 call.GetOutput().SignalError(HttpStatus_500_InternalServerError); |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
96 } |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
97 |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
98 |
1368 | 99 |
100 /*************************************************************************** | |
101 * DICOM C-Find SCU => DEPRECATED! | |
102 ***************************************************************************/ | |
103 | |
104 static bool MergeQueryAndTemplate(DicomMap& result, | |
3401 | 105 const RestApiCall& call) |
1368 | 106 { |
107 Json::Value query; | |
108 | |
3401 | 109 if (!call.ParseJsonRequest(query) || |
1368 | 110 query.type() != Json::objectValue) |
111 { | |
112 return false; | |
113 } | |
114 | |
115 Json::Value::Members members = query.getMemberNames(); | |
116 for (size_t i = 0; i < members.size(); i++) | |
117 { | |
118 DicomTag t = FromDcmtkBridge::ParseTag(members[i]); | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
119 result.SetValue(t, query[members[i]].asString(), false); |
1368 | 120 } |
121 | |
122 return true; | |
123 } | |
124 | |
125 | |
126 static void FindPatient(DicomFindAnswers& result, | |
127 DicomUserConnection& connection, | |
128 const DicomMap& fields) | |
129 { | |
130 // Only keep the filters from "fields" that are related to the patient | |
131 DicomMap s; | |
132 fields.ExtractPatientInformation(s); | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
133 connection.Find(result, ResourceType_Patient, s, true /* normalize */); |
1368 | 134 } |
135 | |
136 | |
137 static void FindStudy(DicomFindAnswers& result, | |
138 DicomUserConnection& connection, | |
139 const DicomMap& fields) | |
140 { | |
141 // Only keep the filters from "fields" that are related to the study | |
142 DicomMap s; | |
143 fields.ExtractStudyInformation(s); | |
144 | |
145 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); | |
146 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); | |
147 s.CopyTagIfExists(fields, DICOM_TAG_MODALITIES_IN_STUDY); | |
148 | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
149 connection.Find(result, ResourceType_Study, s, true /* normalize */); |
1368 | 150 } |
151 | |
152 static void FindSeries(DicomFindAnswers& result, | |
153 DicomUserConnection& connection, | |
154 const DicomMap& fields) | |
155 { | |
156 // Only keep the filters from "fields" that are related to the series | |
157 DicomMap s; | |
158 fields.ExtractSeriesInformation(s); | |
159 | |
160 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); | |
161 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); | |
162 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID); | |
163 | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
164 connection.Find(result, ResourceType_Series, s, true /* normalize */); |
1368 | 165 } |
166 | |
167 static void FindInstance(DicomFindAnswers& result, | |
168 DicomUserConnection& connection, | |
169 const DicomMap& fields) | |
170 { | |
171 // Only keep the filters from "fields" that are related to the instance | |
172 DicomMap s; | |
173 fields.ExtractInstanceInformation(s); | |
174 | |
175 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); | |
176 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); | |
177 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID); | |
178 s.CopyTagIfExists(fields, DICOM_TAG_SERIES_INSTANCE_UID); | |
179 | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
180 connection.Find(result, ResourceType_Instance, s, true /* normalize */); |
1368 | 181 } |
182 | |
183 | |
974 | 184 static void DicomFindPatient(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 { |
1368 | 186 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 187 ServerContext& context = OrthancRestApi::GetContext(call); |
188 | |
1368 | 189 DicomMap fields; |
190 DicomMap::SetupFindPatientTemplate(fields); | |
3401 | 191 if (!MergeQueryAndTemplate(fields, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 |
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:
1368
diff
changeset
|
196 const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
197 RemoteModalityParameters remote = |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
198 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
199 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
200 DicomFindAnswers answers(false); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
202 { |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
203 DicomUserConnection connection(localAet, remote); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
204 connection.Open(); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
205 FindPatient(answers, connection, fields); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
206 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 Json::Value result; |
1368 | 209 answers.ToJson(result, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 |
974 | 213 static void DicomFindStudy(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 { |
1368 | 215 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 216 ServerContext& context = OrthancRestApi::GetContext(call); |
217 | |
1368 | 218 DicomMap fields; |
219 DicomMap::SetupFindStudyTemplate(fields); | |
3401 | 220 if (!MergeQueryAndTemplate(fields, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
225 if (fields.GetValue(DICOM_TAG_ACCESSION_NUMBER).GetContent().size() <= 2 && |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
226 fields.GetValue(DICOM_TAG_PATIENT_ID).GetContent().size() <= 2) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 |
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:
1368
diff
changeset
|
231 const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
232 RemoteModalityParameters remote = |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
233 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
773 | 234 |
2059 | 235 DicomFindAnswers answers(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
236 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
237 { |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
238 DicomUserConnection connection(localAet, remote); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
239 connection.Open(); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
240 FindStudy(answers, connection, fields); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
241 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 Json::Value result; |
1368 | 244 answers.ToJson(result, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 |
974 | 248 static void DicomFindSeries(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 { |
1368 | 250 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 251 ServerContext& context = OrthancRestApi::GetContext(call); |
252 | |
1368 | 253 DicomMap fields; |
254 DicomMap::SetupFindSeriesTemplate(fields); | |
3401 | 255 if (!MergeQueryAndTemplate(fields, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
260 if ((fields.GetValue(DICOM_TAG_ACCESSION_NUMBER).GetContent().size() <= 2 && |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
261 fields.GetValue(DICOM_TAG_PATIENT_ID).GetContent().size() <= 2) || |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
262 fields.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).GetContent().size() <= 2) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 |
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:
1368
diff
changeset
|
267 const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
268 RemoteModalityParameters remote = |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
269 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
773 | 270 |
2059 | 271 DicomFindAnswers answers(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
272 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
273 { |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
274 DicomUserConnection connection(localAet, remote); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
275 connection.Open(); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
276 FindSeries(answers, connection, fields); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
277 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 Json::Value result; |
1368 | 280 answers.ToJson(result, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 |
974 | 284 static void DicomFindInstance(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 { |
1368 | 286 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 287 ServerContext& context = OrthancRestApi::GetContext(call); |
288 | |
1368 | 289 DicomMap fields; |
290 DicomMap::SetupFindInstanceTemplate(fields); | |
3401 | 291 if (!MergeQueryAndTemplate(fields, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
296 if ((fields.GetValue(DICOM_TAG_ACCESSION_NUMBER).GetContent().size() <= 2 && |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
297 fields.GetValue(DICOM_TAG_PATIENT_ID).GetContent().size() <= 2) || |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
298 fields.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).GetContent().size() <= 2 || |
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
299 fields.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).GetContent().size() <= 2) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 |
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:
1368
diff
changeset
|
304 const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
305 RemoteModalityParameters remote = |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
306 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
773 | 307 |
2059 | 308 DicomFindAnswers answers(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
309 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
310 { |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
311 DicomUserConnection connection(localAet, remote); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
312 connection.Open(); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
313 FindInstance(answers, connection, fields); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
314 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 Json::Value result; |
1368 | 317 answers.ToJson(result, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 |
1368 | 321 |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
322 static void CopyTagIfExists(DicomMap& target, |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
323 ParsedDicomFile& source, |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
324 const DicomTag& tag) |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
325 { |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
326 std::string tmp; |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
327 if (source.GetTagValue(tmp, tag)) |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
328 { |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
329 target.SetValue(tag, tmp, false); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
330 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
331 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
332 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
333 |
974 | 334 static void DicomFind(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 { |
1368 | 336 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 337 ServerContext& context = OrthancRestApi::GetContext(call); |
338 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 DicomMap m; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 DicomMap::SetupFindPatientTemplate(m); |
3401 | 341 if (!MergeQueryAndTemplate(m, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 |
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:
1368
diff
changeset
|
346 const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
347 RemoteModalityParameters remote = |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
348 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
773 | 349 |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
350 DicomUserConnection connection(localAet, remote); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
351 connection.Open(); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
352 |
2059 | 353 DicomFindAnswers patients(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
354 FindPatient(patients, connection, m); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 // Loop over the found patients |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 Json::Value result = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 for (size_t i = 0; i < patients.GetSize(); i++) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 { |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
360 Json::Value patient; |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
361 patients.ToJson(patient, i, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 DicomMap::SetupFindStudyTemplate(m); |
3401 | 364 if (!MergeQueryAndTemplate(m, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 } |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
368 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
369 CopyTagIfExists(m, patients.GetAnswer(i), DICOM_TAG_PATIENT_ID); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 |
2059 | 371 DicomFindAnswers studies(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
372 FindStudy(studies, connection, m); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 patient["Studies"] = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 // Loop over the found studies |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 for (size_t j = 0; j < studies.GetSize(); j++) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 { |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
379 Json::Value study; |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
380 studies.ToJson(study, j, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 DicomMap::SetupFindSeriesTemplate(m); |
3401 | 383 if (!MergeQueryAndTemplate(m, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 } |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
387 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
388 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_PATIENT_ID); |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
389 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_STUDY_INSTANCE_UID); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 |
2059 | 391 DicomFindAnswers series(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
392 FindSeries(series, connection, m); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 // Loop over the found series |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 study["Series"] = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 for (size_t k = 0; k < series.GetSize(); k++) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 { |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
398 Json::Value series2; |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
399 series.ToJson(series2, k, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 study["Series"].append(series2); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 patient["Studies"].append(study); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 result.append(patient); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 |
1368 | 413 |
414 /*************************************************************************** | |
415 * DICOM C-Find and C-Move SCU => Recommended since Orthanc 0.9.0 | |
416 ***************************************************************************/ | |
417 | |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
418 static void AnswerQueryHandler(RestApiPostCall& call, |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
419 std::auto_ptr<QueryRetrieveHandler>& handler) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
420 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
421 ServerContext& context = OrthancRestApi::GetContext(call); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
422 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
423 if (handler.get() == NULL) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
424 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
425 throw OrthancException(ErrorCode_NullPointer); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
426 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
427 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
428 handler->Run(); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
429 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
430 std::string s = context.GetQueryRetrieveArchive().Add(handler.release()); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
431 Json::Value result = Json::objectValue; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
432 result["ID"] = s; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
433 result["Path"] = "/queries/" + s; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
434 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
435 call.GetOutput().AnswerJson(result); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
436 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
437 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
438 |
1368 | 439 static void DicomQuery(RestApiPostCall& call) |
440 { | |
441 ServerContext& context = OrthancRestApi::GetContext(call); | |
442 Json::Value request; | |
443 | |
3345
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
444 if (!call.ParseJsonRequest(request) || |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
445 request.type() != Json::objectValue) |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
446 { |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
447 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
448 } |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
449 else if (!request.isMember(KEY_LEVEL) || |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
450 request[KEY_LEVEL].type() != Json::stringValue) |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
451 { |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
452 throw OrthancException(ErrorCode_BadFileFormat, |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
453 "The JSON body must contain field " + std::string(KEY_LEVEL)); |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
454 } |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
455 else if (request.isMember(KEY_NORMALIZE) && |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
456 request[KEY_NORMALIZE].type() != Json::booleanValue) |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
457 { |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
458 throw OrthancException(ErrorCode_BadFileFormat, |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
459 "The field " + std::string(KEY_NORMALIZE) + " must contain a Boolean"); |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
460 } |
3345
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
461 else if (request.isMember(KEY_QUERY) && |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
462 request[KEY_QUERY].type() != Json::objectValue) |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
463 { |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
464 throw OrthancException(ErrorCode_BadFileFormat, |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
465 "The field " + std::string(KEY_QUERY) + " must contain a JSON object"); |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
466 } |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
467 else |
1368 | 468 { |
469 std::auto_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context)); | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
470 |
1368 | 471 handler->SetModality(call.GetUriComponent("id", "")); |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
472 handler->SetLevel(StringToResourceType(request[KEY_LEVEL].asCString())); |
1368 | 473 |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
474 if (request.isMember(KEY_QUERY)) |
1368 | 475 { |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
476 std::map<DicomTag, std::string> query; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
477 SerializationToolbox::ReadMapOfTags(query, request, KEY_QUERY); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
478 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
479 for (std::map<DicomTag, std::string>::const_iterator |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
480 it = query.begin(); it != query.end(); ++it) |
1368 | 481 { |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
482 handler->SetQuery(it->first, it->second); |
1368 | 483 } |
484 } | |
485 | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
486 if (request.isMember(KEY_NORMALIZE)) |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
487 { |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
488 handler->SetFindNormalized(request[KEY_NORMALIZE].asBool()); |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
489 } |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
490 |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
491 AnswerQueryHandler(call, handler); |
1368 | 492 } |
493 } | |
494 | |
495 | |
496 static void ListQueries(RestApiGetCall& call) | |
497 { | |
498 ServerContext& context = OrthancRestApi::GetContext(call); | |
499 | |
500 std::list<std::string> queries; | |
501 context.GetQueryRetrieveArchive().List(queries); | |
502 | |
503 Json::Value result = Json::arrayValue; | |
504 for (std::list<std::string>::const_iterator | |
505 it = queries.begin(); it != queries.end(); ++it) | |
506 { | |
507 result.append(*it); | |
508 } | |
509 | |
510 call.GetOutput().AnswerJson(result); | |
511 } | |
512 | |
513 | |
514 namespace | |
515 { | |
516 class QueryAccessor | |
517 { | |
518 private: | |
519 ServerContext& context_; | |
520 SharedArchive::Accessor accessor_; | |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
521 QueryRetrieveHandler* handler_; |
1368 | 522 |
523 public: | |
524 QueryAccessor(RestApiCall& call) : | |
525 context_(OrthancRestApi::GetContext(call)), | |
526 accessor_(context_.GetQueryRetrieveArchive(), call.GetUriComponent("id", "")), | |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
527 handler_(NULL) |
1368 | 528 { |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
529 if (accessor_.IsValid()) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
530 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
531 handler_ = &dynamic_cast<QueryRetrieveHandler&>(accessor_.GetItem()); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
532 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
533 else |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
534 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
535 throw OrthancException(ErrorCode_UnknownResource); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
536 } |
1368 | 537 } |
538 | |
2867 | 539 QueryRetrieveHandler& GetHandler() const |
1368 | 540 { |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
541 assert(handler_ != NULL); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
542 return *handler_; |
1368 | 543 } |
544 }; | |
545 | |
546 static void AnswerDicomMap(RestApiCall& call, | |
547 const DicomMap& value, | |
548 bool simplify) | |
549 { | |
550 Json::Value full = Json::objectValue; | |
551 FromDcmtkBridge::ToJson(full, value, simplify); | |
552 call.GetOutput().AnswerJson(full); | |
553 } | |
554 } | |
555 | |
556 | |
557 static void ListQueryAnswers(RestApiGetCall& call) | |
558 { | |
2948
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
559 const bool expand = call.HasArgument("expand"); |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
560 const bool simplify = call.HasArgument("simplify"); |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
561 |
1368 | 562 QueryAccessor query(call); |
2867 | 563 size_t count = query.GetHandler().GetAnswersCount(); |
1368 | 564 |
565 Json::Value result = Json::arrayValue; | |
566 for (size_t i = 0; i < count; i++) | |
567 { | |
2948
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
568 if (expand) |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
569 { |
2988
9cc3d40e389b
Orthanc 1.4.3 is now known as 1.5.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2986
diff
changeset
|
570 // New in Orthanc 1.5.0 |
2948
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
571 DicomMap value; |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
572 query.GetHandler().GetAnswer(value, i); |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
573 |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
574 Json::Value json = Json::objectValue; |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
575 FromDcmtkBridge::ToJson(json, value, simplify); |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
576 |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
577 result.append(json); |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
578 } |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
579 else |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
580 { |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
581 result.append(boost::lexical_cast<std::string>(i)); |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
582 } |
1368 | 583 } |
584 | |
585 call.GetOutput().AnswerJson(result); | |
586 } | |
587 | |
588 | |
589 static void GetQueryOneAnswer(RestApiGetCall& call) | |
590 { | |
591 size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", "")); | |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
592 |
1368 | 593 QueryAccessor query(call); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
594 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
595 DicomMap map; |
2867 | 596 query.GetHandler().GetAnswer(map, index); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
597 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
598 AnswerDicomMap(call, map, call.HasArgument("simplify")); |
1368 | 599 } |
600 | |
601 | |
2867 | 602 static void SubmitRetrieveJob(RestApiPostCall& call, |
603 bool allAnswers, | |
604 size_t index) | |
605 { | |
606 ServerContext& context = OrthancRestApi::GetContext(call); | |
607 | |
608 std::string targetAet; | |
609 | |
610 Json::Value body; | |
611 if (call.ParseJsonRequest(body)) | |
612 { | |
613 targetAet = SerializationToolbox::ReadString(body, "TargetAet"); | |
614 } | |
615 else | |
616 { | |
617 body = Json::objectValue; | |
618 call.BodyToString(targetAet); | |
619 } | |
620 | |
621 std::auto_ptr<DicomMoveScuJob> job(new DicomMoveScuJob(context)); | |
622 | |
623 { | |
624 QueryAccessor query(call); | |
625 job->SetTargetAet(targetAet); | |
626 job->SetLocalAet(query.GetHandler().GetLocalAet()); | |
627 job->SetRemoteModality(query.GetHandler().GetRemoteModality()); | |
628 | |
629 LOG(WARNING) << "Driving C-Move SCU on remote modality " | |
630 << query.GetHandler().GetRemoteModality().GetApplicationEntityTitle() | |
631 << " to target modality " << targetAet; | |
632 | |
633 if (allAnswers) | |
634 { | |
635 for (size_t i = 0; i < query.GetHandler().GetAnswersCount(); i++) | |
636 { | |
637 job->AddFindAnswer(query.GetHandler(), i); | |
638 } | |
639 } | |
640 else | |
641 { | |
642 job->AddFindAnswer(query.GetHandler(), index); | |
643 } | |
644 } | |
645 | |
646 OrthancRestApi::GetApi(call).SubmitCommandsJob | |
647 (call, job.release(), true /* synchronous by default */, body); | |
648 } | |
649 | |
650 | |
1368 | 651 static void RetrieveOneAnswer(RestApiPostCall& call) |
652 { | |
653 size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", "")); | |
2867 | 654 SubmitRetrieveJob(call, false, index); |
1368 | 655 } |
656 | |
657 | |
658 static void RetrieveAllAnswers(RestApiPostCall& call) | |
659 { | |
2867 | 660 SubmitRetrieveJob(call, true, 0); |
1368 | 661 } |
662 | |
663 | |
664 static void GetQueryArguments(RestApiGetCall& call) | |
665 { | |
666 QueryAccessor query(call); | |
2867 | 667 AnswerDicomMap(call, query.GetHandler().GetQuery(), call.HasArgument("simplify")); |
1368 | 668 } |
669 | |
670 | |
671 static void GetQueryLevel(RestApiGetCall& call) | |
672 { | |
673 QueryAccessor query(call); | |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
674 call.GetOutput().AnswerBuffer(EnumerationToString(query.GetHandler().GetLevel()), MimeType_PlainText); |
1368 | 675 } |
676 | |
677 | |
678 static void GetQueryModality(RestApiGetCall& call) | |
679 { | |
680 QueryAccessor query(call); | |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
681 call.GetOutput().AnswerBuffer(query.GetHandler().GetModalitySymbolicName(), MimeType_PlainText); |
1368 | 682 } |
683 | |
684 | |
685 static void DeleteQuery(RestApiDeleteCall& call) | |
686 { | |
687 ServerContext& context = OrthancRestApi::GetContext(call); | |
688 context.GetQueryRetrieveArchive().Remove(call.GetUriComponent("id", "")); | |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
689 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
1368 | 690 } |
691 | |
692 | |
693 static void ListQueryOperations(RestApiGetCall& call) | |
694 { | |
695 // Ensure that the query of interest does exist | |
696 QueryAccessor query(call); | |
697 | |
698 RestApi::AutoListChildren(call); | |
699 } | |
700 | |
701 | |
702 static void ListQueryAnswerOperations(RestApiGetCall& call) | |
703 { | |
704 // Ensure that the query of interest does exist | |
705 QueryAccessor query(call); | |
706 | |
707 // Ensure that the answer of interest does exist | |
708 size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", "")); | |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
709 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
710 DicomMap map; |
2867 | 711 query.GetHandler().GetAnswer(map, index); |
1368 | 712 |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
713 Json::Value answer = Json::arrayValue; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
714 answer.append("content"); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
715 answer.append("retrieve"); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
716 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
717 switch (query.GetHandler().GetLevel()) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
718 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
719 case ResourceType_Patient: |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
720 answer.append("query-study"); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
721 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
722 case ResourceType_Study: |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
723 answer.append("query-series"); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
724 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
725 case ResourceType_Series: |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
726 answer.append("query-instances"); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
727 break; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
728 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
729 default: |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
730 break; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
731 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
732 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
733 call.GetOutput().AnswerJson(answer); |
1368 | 734 } |
735 | |
736 | |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
737 template <ResourceType CHILDREN_LEVEL> |
2986
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
738 static void QueryAnswerChildren(RestApiPostCall& call) |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
739 { |
2988
9cc3d40e389b
Orthanc 1.4.3 is now known as 1.5.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2986
diff
changeset
|
740 // New in Orthanc 1.5.0 |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
741 assert(CHILDREN_LEVEL == ResourceType_Study || |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
742 CHILDREN_LEVEL == ResourceType_Series || |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
743 CHILDREN_LEVEL == ResourceType_Instance); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
744 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
745 ServerContext& context = OrthancRestApi::GetContext(call); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
746 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
747 std::auto_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context)); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
748 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
749 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
750 const QueryAccessor parent(call); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
751 const ResourceType level = parent.GetHandler().GetLevel(); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
752 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
753 const size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", "")); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
754 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
755 Json::Value request; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
756 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
757 if (index >= parent.GetHandler().GetAnswersCount()) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
758 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
759 throw OrthancException(ErrorCode_ParameterOutOfRange); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
760 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
761 else if (CHILDREN_LEVEL == ResourceType_Study && |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
762 level != ResourceType_Patient) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
763 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
764 throw OrthancException(ErrorCode_UnknownResource); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
765 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
766 else if (CHILDREN_LEVEL == ResourceType_Series && |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
767 level != ResourceType_Patient && |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
768 level != ResourceType_Study) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
769 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
770 throw OrthancException(ErrorCode_UnknownResource); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
771 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
772 else if (CHILDREN_LEVEL == ResourceType_Instance && |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
773 level != ResourceType_Patient && |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
774 level != ResourceType_Study && |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
775 level != ResourceType_Series) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
776 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
777 throw OrthancException(ErrorCode_UnknownResource); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
778 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
779 else if (!call.ParseJsonRequest(request)) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
780 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
781 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
782 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
783 else |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
784 { |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
785 handler->SetFindNormalized(parent.GetHandler().IsFindNormalized()); |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
786 handler->SetModality(parent.GetHandler().GetModalitySymbolicName()); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
787 handler->SetLevel(CHILDREN_LEVEL); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
788 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
789 if (request.isMember(KEY_QUERY)) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
790 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
791 std::map<DicomTag, std::string> query; |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
792 SerializationToolbox::ReadMapOfTags(query, request, KEY_QUERY); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
793 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
794 for (std::map<DicomTag, std::string>::const_iterator |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
795 it = query.begin(); it != query.end(); ++it) |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
796 { |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
797 handler->SetQuery(it->first, it->second); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
798 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
799 } |
2986
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
800 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
801 DicomMap answer; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
802 parent.GetHandler().GetAnswer(answer, index); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
803 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
804 // This switch-case mimics "DicomUserConnection::Move()" |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
805 switch (parent.GetHandler().GetLevel()) |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
806 { |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
807 case ResourceType_Patient: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
808 handler->CopyStringTag(answer, DICOM_TAG_PATIENT_ID); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
809 break; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
810 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
811 case ResourceType_Study: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
812 handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
813 break; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
814 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
815 case ResourceType_Series: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
816 handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
817 handler->CopyStringTag(answer, DICOM_TAG_SERIES_INSTANCE_UID); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
818 break; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
819 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
820 case ResourceType_Instance: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
821 handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
822 handler->CopyStringTag(answer, DICOM_TAG_SERIES_INSTANCE_UID); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
823 handler->CopyStringTag(answer, DICOM_TAG_SOP_INSTANCE_UID); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
824 break; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
825 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
826 default: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
827 throw OrthancException(ErrorCode_InternalError); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
828 } |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
829 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
830 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
831 |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
832 AnswerQueryHandler(call, handler); |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
833 } |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
834 |
1368 | 835 |
836 | |
837 /*************************************************************************** | |
838 * DICOM C-Store SCU | |
839 ***************************************************************************/ | |
840 | |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
841 static void GetInstancesToExport(Json::Value& otherArguments, |
2626 | 842 SetOfInstancesJob& job, |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
843 const std::string& remote, |
974 | 844 RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
845 { |
1428 | 846 otherArguments = Json::objectValue; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
847 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
848 |
1428 | 849 Json::Value request; |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1428
diff
changeset
|
850 if (Toolbox::IsSHA1(call.GetBodyData(), call.GetBodySize())) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
851 { |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1428
diff
changeset
|
852 std::string s; |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1428
diff
changeset
|
853 call.BodyToString(s); |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1428
diff
changeset
|
854 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
855 // This is for compatibility with Orthanc <= 0.5.1. |
1428 | 856 request = Json::arrayValue; |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1428
diff
changeset
|
857 request.append(Toolbox::StripSpaces(s)); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
858 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
859 else if (!call.ParseJsonRequest(request)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
860 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
861 // Bad JSON request |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
862 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON value"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
863 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
864 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
865 if (request.isString()) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
866 { |
1428 | 867 std::string item = request.asString(); |
868 request = Json::arrayValue; | |
869 request.append(item); | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
870 } |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
871 else if (!request.isArray() && |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
872 !request.isObject()) |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
873 { |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
874 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object, or a JSON array of strings"); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
875 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
876 |
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:
1368
diff
changeset
|
877 const Json::Value* resources; |
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:
1368
diff
changeset
|
878 if (request.isArray()) |
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:
1368
diff
changeset
|
879 { |
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:
1368
diff
changeset
|
880 resources = &request; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
881 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
882 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
883 { |
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:
1368
diff
changeset
|
884 if (request.type() != Json::objectValue || |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
885 !request.isMember(KEY_RESOURCES)) |
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:
1368
diff
changeset
|
886 { |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
887 throw OrthancException(ErrorCode_BadFileFormat, |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
888 "Missing field in JSON: \"" + std::string(KEY_RESOURCES) + "\""); |
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:
1368
diff
changeset
|
889 } |
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:
1368
diff
changeset
|
890 |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
891 resources = &request[KEY_RESOURCES]; |
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:
1368
diff
changeset
|
892 if (!resources->isArray()) |
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:
1368
diff
changeset
|
893 { |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
894 throw OrthancException(ErrorCode_BadFileFormat, |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
895 "JSON field \"" + std::string(KEY_RESOURCES) + "\" must contain an array"); |
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:
1368
diff
changeset
|
896 } |
1428 | 897 |
898 // Copy the remaining arguments | |
899 Json::Value::Members members = request.getMemberNames(); | |
900 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++) | |
901 { | |
902 otherArguments[members[i]] = request[members[i]]; | |
903 } | |
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:
1368
diff
changeset
|
904 } |
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:
1368
diff
changeset
|
905 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
906 bool logExportedResources; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
907 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
908 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
909 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
910 logExportedResources = lock.GetConfiguration().GetBooleanParameter("LogExportedResources", false); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
911 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
912 |
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:
1368
diff
changeset
|
913 for (Json::Value::ArrayIndex i = 0; i < resources->size(); i++) |
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:
1368
diff
changeset
|
914 { |
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:
1368
diff
changeset
|
915 if (!(*resources) [i].isString()) |
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:
1368
diff
changeset
|
916 { |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
917 throw OrthancException(ErrorCode_BadFileFormat, |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
918 "Resources to be exported must be specified as a JSON array of strings"); |
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:
1368
diff
changeset
|
919 } |
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:
1368
diff
changeset
|
920 |
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:
1368
diff
changeset
|
921 std::string stripped = Toolbox::StripSpaces((*resources) [i].asString()); |
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:
1368
diff
changeset
|
922 if (!Toolbox::IsSHA1(stripped)) |
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:
1368
diff
changeset
|
923 { |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
924 throw OrthancException(ErrorCode_BadFileFormat, |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
925 "This string is not a valid Orthanc identifier: " + stripped); |
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:
1368
diff
changeset
|
926 } |
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:
1368
diff
changeset
|
927 |
3374
d0d6bd633e4c
Reporting of "ParentResources" in "DicomModalityStore" and "DicomModalityStore" jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3370
diff
changeset
|
928 job.AddParentResource(stripped); // New in Orthanc 1.5.7 |
d0d6bd633e4c
Reporting of "ParentResources" in "DicomModalityStore" and "DicomModalityStore" jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3370
diff
changeset
|
929 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
930 context.AddChildInstances(job, stripped); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
931 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
932 if (logExportedResources) |
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:
1368
diff
changeset
|
933 { |
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:
1368
diff
changeset
|
934 context.GetIndex().LogExportedResource(stripped, remote); |
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:
1368
diff
changeset
|
935 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
936 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
937 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
938 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
939 |
2584 | 940 static void DicomStore(RestApiPostCall& call) |
941 { | |
942 ServerContext& context = OrthancRestApi::GetContext(call); | |
943 | |
944 std::string remote = call.GetUriComponent("id", ""); | |
945 | |
946 Json::Value request; | |
2626 | 947 std::auto_ptr<DicomModalityStoreJob> job(new DicomModalityStoreJob(context)); |
2584 | 948 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
949 GetInstancesToExport(request, *job, remote, call); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
950 |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
951 std::string localAet = Toolbox::GetJsonStringField |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
952 (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle()); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
953 std::string moveOriginatorAET = Toolbox::GetJsonStringField |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
954 (request, "MoveOriginatorAet", context.GetDefaultLocalApplicationEntityTitle()); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
955 int moveOriginatorID = Toolbox::GetJsonIntegerField |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
956 (request, "MoveOriginatorID", 0 /* By default, not a C-MOVE */); |
2584 | 957 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
958 job->SetLocalAet(localAet); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
959 job->SetRemoteModality(MyGetModalityUsingSymbolicName(remote)); |
2584 | 960 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
961 if (moveOriginatorID != 0) |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
962 { |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
963 job->SetMoveOriginator(moveOriginatorAET, moveOriginatorID); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
964 } |
2626 | 965 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
966 OrthancRestApi::GetApi(call).SubmitCommandsJob |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
967 (call, job.release(), true /* synchronous by default */, request); |
2584 | 968 } |
969 | |
970 | |
1368 | 971 /*************************************************************************** |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
972 * DICOM C-Move SCU |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
973 ***************************************************************************/ |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
974 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
975 static void DicomMove(RestApiPostCall& call) |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
976 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
977 ServerContext& context = OrthancRestApi::GetContext(call); |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
978 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
979 Json::Value request; |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
980 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
981 if (!call.ParseJsonRequest(request) || |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
982 request.type() != Json::objectValue || |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
983 !request.isMember(KEY_RESOURCES) || |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
984 !request.isMember(KEY_LEVEL) || |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
985 request[KEY_RESOURCES].type() != Json::arrayValue || |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
986 request[KEY_LEVEL].type() != Json::stringValue) |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
987 { |
3345
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
988 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON body containing fields " + |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
989 std::string(KEY_RESOURCES) + " and " + std::string(KEY_LEVEL)); |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
990 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
991 |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
992 ResourceType level = StringToResourceType(request[KEY_LEVEL].asCString()); |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
993 |
2584 | 994 std::string localAet = Toolbox::GetJsonStringField |
995 (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle()); | |
996 std::string targetAet = Toolbox::GetJsonStringField | |
997 (request, "TargetAet", context.GetDefaultLocalApplicationEntityTitle()); | |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
998 |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
999 const RemoteModalityParameters source = |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1000 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1001 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1002 DicomUserConnection connection(localAet, source); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1003 connection.Open(); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1004 |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1005 for (Json::Value::ArrayIndex i = 0; i < request[KEY_RESOURCES].size(); i++) |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1006 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1007 DicomMap resource; |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1008 FromDcmtkBridge::FromJson(resource, request[KEY_RESOURCES][i]); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1009 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1010 connection.Move(targetAet, level, resource); |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1011 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1012 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1013 // Move has succeeded |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1014 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1015 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1016 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1017 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1018 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1019 /*************************************************************************** |
1368 | 1020 * Orthanc Peers => Store client |
1021 ***************************************************************************/ | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1022 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1023 static bool IsExistingPeer(const OrthancRestApi::SetOfStrings& peers, |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1024 const std::string& id) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1025 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1026 return peers.find(id) != peers.end(); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1027 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1028 |
974 | 1029 static void ListPeers(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1030 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1031 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1032 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1033 OrthancRestApi::SetOfStrings peers; |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1034 lock.GetConfiguration().GetListOfOrthancPeers(peers); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1035 |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1036 if (call.HasArgument("expand")) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1037 { |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1038 Json::Value result = Json::objectValue; |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1039 for (OrthancRestApi::SetOfStrings::const_iterator |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1040 it = peers.begin(); it != peers.end(); ++it) |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1041 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1042 WebServiceParameters peer; |
2799
6e3a60b85da6
New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2685
diff
changeset
|
1043 |
2944
f395460af74d
simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
1044 if (lock.GetConfiguration().LookupOrthancPeer(peer, *it)) |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1045 { |
3192
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3167
diff
changeset
|
1046 Json::Value info; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3167
diff
changeset
|
1047 peer.FormatPublic(info); |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3167
diff
changeset
|
1048 result[*it] = info; |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1049 } |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1050 } |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1051 call.GetOutput().AnswerJson(result); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1052 } |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1053 else // if expand is not present, keep backward compatibility and return an array of peers |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1054 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1055 Json::Value result = Json::arrayValue; |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1056 for (OrthancRestApi::SetOfStrings::const_iterator |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1057 it = peers.begin(); it != peers.end(); ++it) |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1058 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1059 result.append(*it); |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1060 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1061 |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1062 call.GetOutput().AnswerJson(result); |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1063 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1064 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1065 |
974 | 1066 static void ListPeerOperations(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1067 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1068 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1069 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1070 OrthancRestApi::SetOfStrings peers; |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1071 lock.GetConfiguration().GetListOfOrthancPeers(peers); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1072 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1073 std::string id = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1074 if (IsExistingPeer(peers, id)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1075 { |
1063
0332e6e8c679
Fix automated generation of the list of resource children in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1049
diff
changeset
|
1076 RestApi::AutoListChildren(call); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1077 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1078 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1079 |
974 | 1080 static void PeerStore(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1081 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1082 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1083 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1084 std::string remote = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1085 |
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:
1368
diff
changeset
|
1086 Json::Value request; |
2626 | 1087 std::auto_ptr<OrthancPeerStoreJob> job(new OrthancPeerStoreJob(context)); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1088 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1089 GetInstancesToExport(request, *job, remote, call); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1090 |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1091 OrthancConfiguration::ReaderLock lock; |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1092 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1093 WebServiceParameters peer; |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1094 if (lock.GetConfiguration().LookupOrthancPeer(peer, remote)) |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1095 { |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1096 job->SetPeer(peer); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1097 OrthancRestApi::GetApi(call).SubmitCommandsJob |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1098 (call, job.release(), true /* synchronous by default */, request); |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1099 } |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1100 else |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1101 { |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1102 throw OrthancException(ErrorCode_UnknownResource, |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1103 "No peer with symbolic name: " + remote); |
2626 | 1104 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1105 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1106 |
3592
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1107 static void PeerSystem(RestApiGetCall& call) |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1108 { |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1109 std::string remote = call.GetUriComponent("id", ""); |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1110 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1111 OrthancConfiguration::ReaderLock lock; |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1112 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1113 WebServiceParameters peer; |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1114 if (lock.GetConfiguration().LookupOrthancPeer(peer, remote)) |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1115 { |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1116 HttpClient client(peer, "system"); |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1117 std::string answer; |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1118 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1119 client.SetMethod(HttpMethod_Get); |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1120 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1121 if (!client.Apply(answer)) |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1122 { |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1123 LOG(ERROR) << "Unable to get the system info from remote Orthanc peer: " << peer.GetUrl(); |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1124 call.GetOutput().SignalError(client.GetLastStatus()); |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1125 return; |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1126 } |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1127 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1128 call.GetOutput().AnswerBuffer(answer, MimeType_Json); |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1129 } |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1130 else |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1131 { |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1132 throw OrthancException(ErrorCode_UnknownResource, |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1133 "No peer with symbolic name: " + remote); |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1134 } |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1135 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1136 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1137 // DICOM bridge ------------------------------------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1138 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1139 static bool IsExistingModality(const OrthancRestApi::SetOfStrings& modalities, |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1140 const std::string& id) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1141 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1142 return modalities.find(id) != modalities.end(); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1143 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1144 |
974 | 1145 static void ListModalities(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1146 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1147 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1148 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1149 OrthancRestApi::SetOfStrings modalities; |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1150 lock.GetConfiguration().GetListOfDicomModalities(modalities); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1151 |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1152 if (call.HasArgument("expand")) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1153 { |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1154 Json::Value result = Json::objectValue; |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1155 for (OrthancRestApi::SetOfStrings::const_iterator |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1156 it = modalities.begin(); it != modalities.end(); ++it) |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1157 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1158 const RemoteModalityParameters& remote = lock.GetConfiguration().GetModalityUsingSymbolicName(*it); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1159 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1160 Json::Value info; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1161 remote.Serialize(info, true /* force advanced format */); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1162 result[*it] = info; |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1163 } |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1164 call.GetOutput().AnswerJson(result); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1165 } |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1166 else // if expand is not present, keep backward compatibility and return an array of modalities ids |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1167 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1168 Json::Value result = Json::arrayValue; |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1169 for (OrthancRestApi::SetOfStrings::const_iterator |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1170 it = modalities.begin(); it != modalities.end(); ++it) |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1171 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1172 result.append(*it); |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1173 } |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1174 call.GetOutput().AnswerJson(result); |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1175 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1176 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1177 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1178 |
974 | 1179 static void ListModalityOperations(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1180 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1181 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1182 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1183 OrthancRestApi::SetOfStrings modalities; |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1184 lock.GetConfiguration().GetListOfDicomModalities(modalities); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1185 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1186 std::string id = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1187 if (IsExistingModality(modalities, id)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1188 { |
1063
0332e6e8c679
Fix automated generation of the list of resource children in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1049
diff
changeset
|
1189 RestApi::AutoListChildren(call); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1190 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1191 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1192 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1193 |
974 | 1194 static void UpdateModality(RestApiPutCall& call) |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1195 { |
2801
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1196 ServerContext& context = OrthancRestApi::GetContext(call); |
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1197 |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1198 Json::Value json; |
3401 | 1199 if (call.ParseJsonRequest(json)) |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1200 { |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1201 RemoteModalityParameters modality; |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1202 modality.Unserialize(json); |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1203 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1204 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1205 OrthancConfiguration::WriterLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1206 lock.GetConfiguration().UpdateModality(call.GetUriComponent("id", ""), modality); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1207 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1208 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1209 context.SignalUpdatedModalities(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1210 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1211 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1212 } |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1213 } |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1214 |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1215 |
974 | 1216 static void DeleteModality(RestApiDeleteCall& call) |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1217 { |
2801
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1218 ServerContext& context = OrthancRestApi::GetContext(call); |
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1219 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1220 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1221 OrthancConfiguration::WriterLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1222 lock.GetConfiguration().RemoveModality(call.GetUriComponent("id", "")); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1223 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1224 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1225 context.SignalUpdatedModalities(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1226 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1227 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1228 } |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1229 |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1230 |
974 | 1231 static void UpdatePeer(RestApiPutCall& call) |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1232 { |
2801
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1233 ServerContext& context = OrthancRestApi::GetContext(call); |
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1234 |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1235 Json::Value json; |
3401 | 1236 if (call.ParseJsonRequest(json)) |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1237 { |
2020 | 1238 WebServiceParameters peer; |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2799
diff
changeset
|
1239 peer.Unserialize(json); |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1240 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1241 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1242 OrthancConfiguration::WriterLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1243 lock.GetConfiguration().UpdatePeer(call.GetUriComponent("id", ""), peer); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1244 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1245 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1246 context.SignalUpdatedPeers(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1247 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1248 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1249 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1250 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1251 |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1252 |
974 | 1253 static void DeletePeer(RestApiDeleteCall& call) |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1254 { |
2801
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1255 ServerContext& context = OrthancRestApi::GetContext(call); |
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1256 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1257 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1258 OrthancConfiguration::WriterLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1259 lock.GetConfiguration().RemovePeer(call.GetUriComponent("id", "")); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1260 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1261 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1262 context.SignalUpdatedPeers(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1263 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1264 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1265 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1266 |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1267 |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1268 static void DicomFindWorklist(RestApiPostCall& call) |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1269 { |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1270 ServerContext& context = OrthancRestApi::GetContext(call); |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1271 |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1272 Json::Value json; |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1273 if (call.ParseJsonRequest(json)) |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1274 { |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1275 const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1276 RemoteModalityParameters remote = |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1277 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1278 |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1279 std::auto_ptr<ParsedDicomFile> query |
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1280 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0))); |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1281 |
2059 | 1282 DicomFindAnswers answers(true); |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1283 |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1284 { |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1285 DicomUserConnection connection(localAet, remote); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1286 connection.Open(); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1287 connection.FindWorklist(answers, *query); |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1288 } |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1289 |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1290 Json::Value result; |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1291 answers.ToJson(result, true); |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1292 call.GetOutput().AnswerJson(result); |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1293 } |
3345
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
1294 else |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
1295 { |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
1296 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
1297 } |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1298 } |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1299 |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1300 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1301 void OrthancRestApi::RegisterModalities() |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1302 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1303 Register("/modalities", ListModalities); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1304 Register("/modalities/{id}", ListModalityOperations); |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1305 Register("/modalities/{id}", UpdateModality); |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1306 Register("/modalities/{id}", DeleteModality); |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
1307 Register("/modalities/{id}/echo", DicomEcho); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1308 Register("/modalities/{id}/find-patient", DicomFindPatient); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1309 Register("/modalities/{id}/find-study", DicomFindStudy); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1310 Register("/modalities/{id}/find-series", DicomFindSeries); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1311 Register("/modalities/{id}/find-instance", DicomFindInstance); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1312 Register("/modalities/{id}/find", DicomFind); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1313 Register("/modalities/{id}/store", DicomStore); |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1314 Register("/modalities/{id}/move", DicomMove); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1315 |
1368 | 1316 // For Query/Retrieve |
1317 Register("/modalities/{id}/query", DicomQuery); | |
1318 Register("/queries", ListQueries); | |
1319 Register("/queries/{id}", DeleteQuery); | |
1320 Register("/queries/{id}", ListQueryOperations); | |
1321 Register("/queries/{id}/answers", ListQueryAnswers); | |
1322 Register("/queries/{id}/answers/{index}", ListQueryAnswerOperations); | |
1323 Register("/queries/{id}/answers/{index}/content", GetQueryOneAnswer); | |
1324 Register("/queries/{id}/answers/{index}/retrieve", RetrieveOneAnswer); | |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1325 Register("/queries/{id}/answers/{index}/query-instances", |
2986
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1326 QueryAnswerChildren<ResourceType_Instance>); |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1327 Register("/queries/{id}/answers/{index}/query-series", |
2986
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1328 QueryAnswerChildren<ResourceType_Series>); |
2982
94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2955
diff
changeset
|
1329 Register("/queries/{id}/answers/{index}/query-studies", |
2986
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1330 QueryAnswerChildren<ResourceType_Study>); |
1368 | 1331 Register("/queries/{id}/level", GetQueryLevel); |
1332 Register("/queries/{id}/modality", GetQueryModality); | |
1333 Register("/queries/{id}/query", GetQueryArguments); | |
1334 Register("/queries/{id}/retrieve", RetrieveAllAnswers); | |
1335 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1336 Register("/peers", ListPeers); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1337 Register("/peers/{id}", ListPeerOperations); |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1338 Register("/peers/{id}", UpdatePeer); |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1339 Register("/peers/{id}", DeletePeer); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1340 Register("/peers/{id}/store", PeerStore); |
3592
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1341 Register("/peers/{id}/system", PeerSystem); |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1342 |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
1343 Register("/modalities/{id}/find-worklist", DicomFindWorklist); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1344 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1345 } |