Mercurial > hg > orthanc
annotate OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp @ 4438:4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 Jan 2021 16:53:35 +0100 |
parents | d9473bd5ed43 |
children | 6831de40acd9 |
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 |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4423
diff
changeset
|
5 * Copyright (C) 2017-2021 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 |
4045 | 37 #include "../../../OrthancFramework/Sources/Cache/SharedArchive.h" |
38 #include "../../../OrthancFramework/Sources/DicomNetworking/DicomAssociation.h" | |
39 #include "../../../OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.h" | |
40 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | |
41 #include "../../../OrthancFramework/Sources/Logging.h" | |
42 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" | |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
43 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
44 #include "../OrthancConfiguration.h" |
1368 | 45 #include "../QueryRetrieveHandler.h" |
3097 | 46 #include "../ServerContext.h" |
2602 | 47 #include "../ServerJobs/DicomModalityStoreJob.h" |
2867 | 48 #include "../ServerJobs/DicomMoveScuJob.h" |
2602 | 49 #include "../ServerJobs/OrthancPeerStoreJob.h" |
1368 | 50 #include "../ServerToolbox.h" |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
51 #include "../StorageCommitmentReports.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
53 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 namespace Orthanc |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 { |
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_LEVEL = "Level"; |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
57 static const char* const KEY_LOCAL_AET = "LocalAet"; |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
58 static const char* const KEY_NORMALIZE = "Normalize"; |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
59 static const char* const KEY_QUERY = "Query"; |
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
|
60 static const char* const KEY_RESOURCES = "Resources"; |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
61 static const char* const KEY_TARGET_AET = "TargetAet"; |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
62 static const char* const KEY_TIMEOUT = "Timeout"; |
4340
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
63 static const char* const KEY_CHECK_FIND = "CheckFind"; |
3808
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
64 static const char* const SOP_CLASS_UID = "SOPClassUID"; |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
65 static const char* const SOP_INSTANCE_UID = "SOPInstanceUID"; |
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
|
66 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
67 static RemoteModalityParameters MyGetModalityUsingSymbolicName(const std::string& name) |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
68 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
69 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
70 return lock.GetConfiguration().GetModalityUsingSymbolicName(name); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
71 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
72 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
73 |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
74 static void InjectAssociationTimeout(DicomAssociationParameters& params, |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
75 const Json::Value& body) |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
76 { |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
77 if (body.type() == Json::objectValue && |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
78 body.isMember(KEY_TIMEOUT)) |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
79 { |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
80 // New in Orthanc 1.7.0 |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
81 params.SetTimeout(SerializationToolbox::ReadUnsignedInteger(body, KEY_TIMEOUT)); |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
82 } |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
83 } |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
84 |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
85 static DicomAssociationParameters GetAssociationParameters(RestApiPostCall& call, |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
86 const Json::Value& body) |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
87 { |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
88 const std::string& localAet = |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
89 OrthancRestApi::GetContext(call).GetDefaultLocalApplicationEntityTitle(); |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
90 const RemoteModalityParameters remote = |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
91 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
92 |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
93 DicomAssociationParameters params(localAet, remote); |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
94 InjectAssociationTimeout(params, body); |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
95 |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
96 return params; |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
97 } |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
98 |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
99 |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
100 static DicomAssociationParameters GetAssociationParameters(RestApiPostCall& call) |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
101 { |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
102 Json::Value body; |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
103 |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
104 if (!call.ParseJsonRequest(body)) |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
105 { |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
106 throw OrthancException(ErrorCode_BadFileFormat, "Cannot parse the JSON body"); |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
107 } |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
108 |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
109 return GetAssociationParameters(call, body); |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
110 } |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
111 |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
112 |
4421 | 113 static void DocumentModalityParametersShared(RestApiCall& call, |
114 bool includePermissions) | |
115 { | |
116 call.GetDocumentation() | |
117 .SetRequestField("AET", RestApiCallDocumentation::Type_String, | |
118 "AET of the remote DICOM modality", true) | |
119 .SetRequestField("Host", RestApiCallDocumentation::Type_String, | |
120 "Host address of the remote DICOM modality (typically, an IP address)", true) | |
121 .SetRequestField("Port", RestApiCallDocumentation::Type_Number, | |
122 "TCP port of the remote DICOM modality", true) | |
123 .SetRequestField("Manufacturer", RestApiCallDocumentation::Type_String, "Manufacturer of the remote DICOM " | |
4438
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
124 "modality (check configuration option `DicomModalities` for possible values", false) |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
125 .SetRequestField("UseDicomTls", RestApiCallDocumentation::Type_Boolean, "Whether to use DICOM TLS " |
4a4e33c9082d
configuration options for DICOM TLS in Orthanc SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
126 "in the SCU connection initiated by Orthanc (new in Orthanc 1.9.0)", false); |
4421 | 127 |
128 if (includePermissions) | |
129 { | |
130 call.GetDocumentation() | |
131 .SetRequestField("AllowEcho", RestApiCallDocumentation::Type_Boolean, | |
132 "Whether to accept C-ECHO SCU commands issued by the remote modality", false) | |
133 .SetRequestField("AllowStore", RestApiCallDocumentation::Type_Boolean, | |
134 "Whether to accept C-STORE SCU commands issued by the remote modality", false) | |
135 .SetRequestField("AllowFind", RestApiCallDocumentation::Type_Boolean, | |
136 "Whether to accept C-FIND SCU commands issued by the remote modality", false) | |
137 .SetRequestField("AllowMove", RestApiCallDocumentation::Type_Boolean, | |
138 "Whether to accept C-MOVE SCU commands issued by the remote modality", false) | |
139 .SetRequestField("AllowGet", RestApiCallDocumentation::Type_Boolean, | |
140 "Whether to accept C-GET SCU commands issued by the remote modality", false) | |
141 .SetRequestField("AllowStorageCommitment", RestApiCallDocumentation::Type_Boolean, | |
142 "Whether to accept storage commitment requests issued by the remote modality", false) | |
143 .SetRequestField("AllowTranscoding", RestApiCallDocumentation::Type_Boolean, | |
144 "Whether to allow transcoding for operations initiated by this modality (typically, C-GET)", false); | |
145 } | |
146 } | |
147 | |
148 | |
1368 | 149 /*************************************************************************** |
150 * DICOM C-Echo SCU | |
151 ***************************************************************************/ | |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
152 |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
153 static void ExecuteEcho(RestApiOutput& output, |
4340
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
154 const DicomAssociationParameters& parameters, |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
155 const Json::Value& body) |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
156 { |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
157 DicomControlUserConnection connection(parameters); |
3875
ea1d32861cfc
moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3874
diff
changeset
|
158 |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3876
diff
changeset
|
159 if (connection.Echo()) |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3876
diff
changeset
|
160 { |
4340
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
161 bool find = false; |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
162 |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
163 if (body.type() == Json::objectValue && |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
164 body.isMember(KEY_CHECK_FIND)) |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
165 { |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
166 find = SerializationToolbox::ReadBoolean(body, KEY_CHECK_FIND); |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
167 } |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
168 else |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
169 { |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
170 OrthancConfiguration::ReaderLock lock; |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
171 find = lock.GetConfiguration().GetBooleanParameter("DicomEchoChecksFind", false); |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
172 } |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
173 |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
174 if (find) |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
175 { |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
176 // Issue a C-FIND request at the study level about a random Study Instance UID |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
177 const std::string studyInstanceUid = FromDcmtkBridge::GenerateUniqueIdentifier(ResourceType_Study); |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
178 |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
179 DicomMap query; |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
180 query.SetValue(DICOM_TAG_STUDY_INSTANCE_UID, studyInstanceUid, false); |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
181 |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
182 DicomFindAnswers answers(false /* not a worklist */); |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
183 |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
184 // The following line throws an exception if the remote modality doesn't support C-FIND |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
185 connection.Find(answers, ResourceType_Study, query, false /* normalize */); |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
186 } |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
187 |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3876
diff
changeset
|
188 // Echo has succeeded |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
189 output.AnswerBuffer("{}", MimeType_Json); |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
190 } |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3876
diff
changeset
|
191 else |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
192 { |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3876
diff
changeset
|
193 // Echo has failed |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
194 output.SignalError(HttpStatus_500_InternalServerError); |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
195 } |
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
196 } |
4421 | 197 |
198 | |
199 static void DocumentEchoShared(RestApiPostCall& call) | |
200 { | |
201 call.GetDocumentation() | |
202 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number, | |
203 "Timeout for the C-ECHO command, in seconds", false) | |
204 .SetRequestField(KEY_CHECK_FIND, RestApiCallDocumentation::Type_Boolean, | |
205 "Issue a dummy C-FIND command after the C-GET SCU, in order to check whether the remote " | |
206 "modality knows about Orthanc. This field defaults to the value of the `DicomEchoChecksFind` " | |
207 "configuration option. New in Orthanc 1.8.1.", false); | |
208 } | |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
209 |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
210 |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
211 static void DicomEcho(RestApiPostCall& call) |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
212 { |
4421 | 213 if (call.IsDocumentation()) |
214 { | |
215 DocumentEchoShared(call); | |
216 call.GetDocumentation() | |
217 .SetTag("Networking") | |
218 .SetSummary("Trigger C-ECHO SCU") | |
219 .SetDescription("Trigger C-ECHO SCU command against the DICOM modality whose identifier is provided in URL: " | |
220 "https://book.orthanc-server.com/users/rest.html#performing-c-echo") | |
221 .SetUriArgument("id", "Identifier of the modality of interest"); | |
222 return; | |
223 } | |
224 | |
4367
189e48f4a92a
Allow empty request body in "/modalities/{id}/echo"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4340
diff
changeset
|
225 Json::Value body = Json::objectValue; |
189e48f4a92a
Allow empty request body in "/modalities/{id}/echo"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4340
diff
changeset
|
226 |
189e48f4a92a
Allow empty request body in "/modalities/{id}/echo"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4340
diff
changeset
|
227 if (call.GetBodySize() == 0 /* allow empty body, was disallowed in Orthanc 1.7.0->1.8.1 */ || |
189e48f4a92a
Allow empty request body in "/modalities/{id}/echo"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4340
diff
changeset
|
228 call.ParseJsonRequest(body)) |
4340
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
229 { |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
230 const DicomAssociationParameters parameters = GetAssociationParameters(call, body); |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
231 ExecuteEcho(call.GetOutput(), parameters, body); |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
232 } |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
233 else |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
234 { |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
235 throw OrthancException(ErrorCode_BadFileFormat, "Cannot parse the JSON body"); |
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
236 } |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
237 } |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
238 |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
239 |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
240 static void DicomEchoTool(RestApiPostCall& call) |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
241 { |
4421 | 242 if (call.IsDocumentation()) |
243 { | |
244 DocumentEchoShared(call); | |
245 DocumentModalityParametersShared(call, false); | |
246 call.GetDocumentation() | |
247 .SetTag("System") | |
248 .SetSummary("Trigger C-ECHO SCU") | |
249 .SetDescription("Trigger C-ECHO SCU command against a DICOM modality described in the POST body, " | |
250 "without having to register the modality in some `/modalities/{id}` (new in Orthanc 1.8.1)"); | |
251 return; | |
252 } | |
253 | |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
254 Json::Value body; |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
255 if (call.ParseJsonRequest(body)) |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
256 { |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
257 RemoteModalityParameters modality; |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
258 modality.Unserialize(body); |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
259 |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
260 const std::string& localAet = |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
261 OrthancRestApi::GetContext(call).GetDefaultLocalApplicationEntityTitle(); |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
262 |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
263 DicomAssociationParameters params(localAet, modality); |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
264 InjectAssociationTimeout(params, body); |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
265 |
4340
6fa8bb987be2
"DicomEchoChecksFind" config option + "CheckFind" field in /modalities/.../echo
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4339
diff
changeset
|
266 ExecuteEcho(call.GetOutput(), params, body); |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
267 } |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
268 else |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
269 { |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
270 throw OrthancException(ErrorCode_BadFileFormat, "Cannot parse the JSON body"); |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
271 } |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
272 } |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
273 |
1368 | 274 |
275 /*************************************************************************** | |
276 * DICOM C-Find SCU => DEPRECATED! | |
277 ***************************************************************************/ | |
278 | |
279 static bool MergeQueryAndTemplate(DicomMap& result, | |
3401 | 280 const RestApiCall& call) |
1368 | 281 { |
282 Json::Value query; | |
283 | |
3401 | 284 if (!call.ParseJsonRequest(query) || |
1368 | 285 query.type() != Json::objectValue) |
286 { | |
287 return false; | |
288 } | |
289 | |
290 Json::Value::Members members = query.getMemberNames(); | |
291 for (size_t i = 0; i < members.size(); i++) | |
292 { | |
293 DicomTag t = FromDcmtkBridge::ParseTag(members[i]); | |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
294 result.SetValue(t, query[members[i]].asString(), false); |
1368 | 295 } |
296 | |
297 return true; | |
298 } | |
299 | |
300 | |
301 static void FindPatient(DicomFindAnswers& result, | |
3830
447880856ce8
removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3808
diff
changeset
|
302 DicomControlUserConnection& connection, |
1368 | 303 const DicomMap& fields) |
304 { | |
305 // Only keep the filters from "fields" that are related to the patient | |
306 DicomMap s; | |
307 fields.ExtractPatientInformation(s); | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
308 connection.Find(result, ResourceType_Patient, s, true /* normalize */); |
1368 | 309 } |
310 | |
311 | |
312 static void FindStudy(DicomFindAnswers& result, | |
3830
447880856ce8
removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3808
diff
changeset
|
313 DicomControlUserConnection& connection, |
1368 | 314 const DicomMap& fields) |
315 { | |
316 // Only keep the filters from "fields" that are related to the study | |
317 DicomMap s; | |
318 fields.ExtractStudyInformation(s); | |
319 | |
320 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); | |
321 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); | |
322 s.CopyTagIfExists(fields, DICOM_TAG_MODALITIES_IN_STUDY); | |
323 | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
324 connection.Find(result, ResourceType_Study, s, true /* normalize */); |
1368 | 325 } |
326 | |
327 static void FindSeries(DicomFindAnswers& result, | |
3830
447880856ce8
removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3808
diff
changeset
|
328 DicomControlUserConnection& connection, |
1368 | 329 const DicomMap& fields) |
330 { | |
331 // Only keep the filters from "fields" that are related to the series | |
332 DicomMap s; | |
333 fields.ExtractSeriesInformation(s); | |
334 | |
335 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); | |
336 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); | |
337 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID); | |
338 | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
339 connection.Find(result, ResourceType_Series, s, true /* normalize */); |
1368 | 340 } |
341 | |
342 static void FindInstance(DicomFindAnswers& result, | |
3830
447880856ce8
removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3808
diff
changeset
|
343 DicomControlUserConnection& connection, |
1368 | 344 const DicomMap& fields) |
345 { | |
346 // Only keep the filters from "fields" that are related to the instance | |
347 DicomMap s; | |
348 fields.ExtractInstanceInformation(s); | |
349 | |
350 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID); | |
351 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER); | |
352 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID); | |
353 s.CopyTagIfExists(fields, DICOM_TAG_SERIES_INSTANCE_UID); | |
354 | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
355 connection.Find(result, ResourceType_Instance, s, true /* normalize */); |
1368 | 356 } |
357 | |
358 | |
974 | 359 static void DicomFindPatient(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 { |
4421 | 361 if (call.IsDocumentation()) |
362 { | |
363 call.GetDocumentation() | |
364 .SetDeprecated() | |
365 .SetTag("Networking") | |
366 .SetSummary("C-FIND SCU for patients") | |
367 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL, " | |
368 "in order to find a patient. Deprecated in favor of `/modalities/{id}/query`.") | |
369 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags") | |
370 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching patients") | |
371 .SetUriArgument("id", "Identifier of the modality of interest"); | |
372 return; | |
373 } | |
374 | |
1368 | 375 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 376 |
1368 | 377 DicomMap fields; |
378 DicomMap::SetupFindPatientTemplate(fields); | |
3401 | 379 if (!MergeQueryAndTemplate(fields, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
384 DicomFindAnswers answers(false); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
386 { |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
387 DicomControlUserConnection connection(GetAssociationParameters(call)); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
388 FindPatient(answers, connection, fields); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
389 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 Json::Value result; |
1368 | 392 answers.ToJson(result, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 |
974 | 396 static void DicomFindStudy(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 { |
4421 | 398 if (call.IsDocumentation()) |
399 { | |
400 call.GetDocumentation() | |
401 .SetDeprecated() | |
402 .SetTag("Networking") | |
403 .SetSummary("C-FIND SCU for studies") | |
404 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL, " | |
405 "in order to find a study. Deprecated in favor of `/modalities/{id}/query`.") | |
406 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags") | |
407 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching studies") | |
408 .SetUriArgument("id", "Identifier of the modality of interest"); | |
409 return; | |
410 } | |
411 | |
1368 | 412 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 413 |
1368 | 414 DicomMap fields; |
415 DicomMap::SetupFindStudyTemplate(fields); | |
3401 | 416 if (!MergeQueryAndTemplate(fields, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
421 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
|
422 fields.GetValue(DICOM_TAG_PATIENT_ID).GetContent().size() <= 2) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 |
2059 | 427 DicomFindAnswers answers(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
428 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
429 { |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
430 DicomControlUserConnection connection(GetAssociationParameters(call)); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
431 FindStudy(answers, connection, fields); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
432 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 Json::Value result; |
1368 | 435 answers.ToJson(result, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 |
974 | 439 static void DicomFindSeries(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 { |
4421 | 441 if (call.IsDocumentation()) |
442 { | |
443 call.GetDocumentation() | |
444 .SetDeprecated() | |
445 .SetTag("Networking") | |
446 .SetSummary("C-FIND SCU for series") | |
447 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL, " | |
448 "in order to find a series. Deprecated in favor of `/modalities/{id}/query`.") | |
449 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags") | |
450 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching series") | |
451 .SetUriArgument("id", "Identifier of the modality of interest"); | |
452 return; | |
453 } | |
454 | |
1368 | 455 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 456 |
1368 | 457 DicomMap fields; |
458 DicomMap::SetupFindSeriesTemplate(fields); | |
3401 | 459 if (!MergeQueryAndTemplate(fields, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
464 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
|
465 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
|
466 fields.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).GetContent().size() <= 2) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 |
2059 | 471 DicomFindAnswers answers(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
472 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
473 { |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
474 DicomControlUserConnection connection(GetAssociationParameters(call)); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
475 FindSeries(answers, connection, fields); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
476 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 Json::Value result; |
1368 | 479 answers.ToJson(result, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 |
974 | 483 static void DicomFindInstance(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 { |
4421 | 485 if (call.IsDocumentation()) |
486 { | |
487 call.GetDocumentation() | |
488 .SetDeprecated() | |
489 .SetTag("Networking") | |
490 .SetSummary("C-FIND SCU for instances") | |
491 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL, " | |
492 "in order to find an instance. Deprecated in favor of `/modalities/{id}/query`.") | |
493 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags") | |
494 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching instances") | |
495 .SetUriArgument("id", "Identifier of the modality of interest"); | |
496 return; | |
497 } | |
498 | |
1368 | 499 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 500 |
1368 | 501 DicomMap fields; |
502 DicomMap::SetupFindInstanceTemplate(fields); | |
3401 | 503 if (!MergeQueryAndTemplate(fields, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 |
1737
ec66a16aa398
removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
508 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
|
509 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
|
510 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
|
511 fields.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).GetContent().size() <= 2) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 |
2059 | 516 DicomFindAnswers answers(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
517 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
518 { |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
519 DicomControlUserConnection connection(GetAssociationParameters(call)); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
520 FindInstance(answers, connection, fields); |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
521 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 Json::Value result; |
1368 | 524 answers.ToJson(result, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 |
1368 | 528 |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
529 static void CopyTagIfExists(DicomMap& target, |
4205 | 530 const ParsedDicomFile& source, |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
531 const DicomTag& tag) |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
532 { |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
533 std::string tmp; |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
534 if (source.GetTagValue(tmp, tag)) |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
535 { |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1998
diff
changeset
|
536 target.SetValue(tag, tmp, false); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
537 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
538 } |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
539 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
540 |
974 | 541 static void DicomFind(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 { |
4421 | 543 if (call.IsDocumentation()) |
544 { | |
545 call.GetDocumentation() | |
546 .SetDeprecated() | |
547 .SetTag("Networking") | |
548 .SetSummary("Hierarchical C-FIND SCU") | |
549 .SetDescription("Trigger a sequence of C-FIND SCU commands against the DICOM modality whose identifier is provided in URL, " | |
550 "in order to discover a hierarchy of matching patients/studies/series. " | |
551 "Deprecated in favor of `/modalities/{id}/query`.") | |
552 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags") | |
553 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching patients, embedding the " | |
554 "matching studies, then the matching series.") | |
555 .SetUriArgument("id", "Identifier of the modality of interest"); | |
556 return; | |
557 } | |
558 | |
1368 | 559 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri(); |
773 | 560 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 DicomMap m; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 DicomMap::SetupFindPatientTemplate(m); |
3401 | 563 if (!MergeQueryAndTemplate(m, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
568 DicomControlUserConnection connection(GetAssociationParameters(call)); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
569 |
2059 | 570 DicomFindAnswers patients(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
571 FindPatient(patients, connection, m); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 // Loop over the found patients |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 Json::Value result = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 for (size_t i = 0; i < patients.GetSize(); i++) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 { |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
577 Json::Value patient; |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
578 patients.ToJson(patient, i, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 DicomMap::SetupFindStudyTemplate(m); |
3401 | 581 if (!MergeQueryAndTemplate(m, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 } |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
585 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
586 CopyTagIfExists(m, patients.GetAnswer(i), DICOM_TAG_PATIENT_ID); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 |
2059 | 588 DicomFindAnswers studies(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
589 FindStudy(studies, connection, m); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
590 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 patient["Studies"] = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
593 // Loop over the found studies |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
594 for (size_t j = 0; j < studies.GetSize(); j++) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
595 { |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
596 Json::Value study; |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
597 studies.ToJson(study, j, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 DicomMap::SetupFindSeriesTemplate(m); |
3401 | 600 if (!MergeQueryAndTemplate(m, call)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 } |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
604 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
605 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_PATIENT_ID); |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
606 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_STUDY_INSTANCE_UID); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 |
2059 | 608 DicomFindAnswers series(false); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
609 FindSeries(series, connection, m); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 // Loop over the found series |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 study["Series"] = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 for (size_t k = 0; k < series.GetSize(); k++) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
614 { |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
615 Json::Value series2; |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
616 series.ToJson(series2, k, true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 study["Series"].append(series2); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
618 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
619 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
620 patient["Studies"].append(study); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 result.append(patient); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
625 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
627 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
629 |
1368 | 630 |
631 /*************************************************************************** | |
632 * DICOM C-Find and C-Move SCU => Recommended since Orthanc 0.9.0 | |
633 ***************************************************************************/ | |
634 | |
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
|
635 static void AnswerQueryHandler(RestApiPostCall& call, |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
636 std::unique_ptr<QueryRetrieveHandler>& handler) |
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
|
637 { |
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
|
638 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
|
639 |
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
|
640 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
|
641 { |
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
|
642 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
|
643 } |
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
|
644 |
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
|
645 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
|
646 |
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
|
647 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
|
648 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
|
649 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
|
650 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
|
651 |
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
|
652 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
|
653 } |
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
|
654 |
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
|
655 |
1368 | 656 static void DicomQuery(RestApiPostCall& call) |
657 { | |
4421 | 658 if (call.IsDocumentation()) |
659 { | |
660 call.GetDocumentation() | |
661 .SetTag("Networking") | |
662 .SetSummary("Trigger C-FIND SCU") | |
663 .SetDescription("Trigger C-FIND SCU command against the DICOM modality whose identifier is provided in URL: " | |
664 "https://book.orthanc-server.com/users/rest.html#performing-query-retrieve-c-find-and-find-with-rest") | |
665 .SetUriArgument("id", "Identifier of the modality of interest") | |
666 .SetRequestField(KEY_QUERY, RestApiCallDocumentation::Type_JsonObject, | |
667 "Associative array containing the filter on the values of the DICOM tags", true) | |
668 .SetRequestField(KEY_LEVEL, RestApiCallDocumentation::Type_String, | |
669 "Level of the query (`Patient`, `Study`, `Series` or `Instance`)", true) | |
670 .SetRequestField(KEY_NORMALIZE, RestApiCallDocumentation::Type_Boolean, | |
671 "Whether to normalize the query, i.e. whether to wipe out from the query, the DICOM tags " | |
672 "that are not applicable for the query-retrieve level of interest", false) | |
673 .SetAnswerField("ID", RestApiCallDocumentation::Type_JsonObject, | |
674 "Identifier of the query, to be used with `/queries/{id}`") | |
675 .SetAnswerField("Path", RestApiCallDocumentation::Type_JsonObject, | |
676 "Root path to the query in the REST API"); | |
677 return; | |
678 } | |
679 | |
1368 | 680 ServerContext& context = OrthancRestApi::GetContext(call); |
681 Json::Value request; | |
682 | |
3345
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
683 if (!call.ParseJsonRequest(request) || |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
684 request.type() != Json::objectValue) |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
685 { |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
686 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
687 } |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
688 else if (!request.isMember(KEY_LEVEL) || |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
689 request[KEY_LEVEL].type() != Json::stringValue) |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
690 { |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
691 throw OrthancException(ErrorCode_BadFileFormat, |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
692 "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
|
693 } |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
694 else if (request.isMember(KEY_NORMALIZE) && |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
695 request[KEY_NORMALIZE].type() != Json::booleanValue) |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
696 { |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
697 throw OrthancException(ErrorCode_BadFileFormat, |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
698 "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
|
699 } |
3345
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
700 else if (request.isMember(KEY_QUERY) && |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
701 request[KEY_QUERY].type() != Json::objectValue) |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
702 { |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
703 throw OrthancException(ErrorCode_BadFileFormat, |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
704 "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
|
705 } |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
706 else |
1368 | 707 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
708 std::unique_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context)); |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
709 |
1368 | 710 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
|
711 handler->SetLevel(StringToResourceType(request[KEY_LEVEL].asCString())); |
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 if (request.isMember(KEY_QUERY)) |
1368 | 714 { |
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
|
715 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
|
716 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
|
717 |
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 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
|
719 it = query.begin(); it != query.end(); ++it) |
1368 | 720 { |
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
|
721 handler->SetQuery(it->first, it->second); |
1368 | 722 } |
723 } | |
724 | |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
725 if (request.isMember(KEY_NORMALIZE)) |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
726 { |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
727 handler->SetFindNormalized(request[KEY_NORMALIZE].asBool()); |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
728 } |
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
729 |
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
|
730 AnswerQueryHandler(call, handler); |
1368 | 731 } |
732 } | |
733 | |
734 | |
735 static void ListQueries(RestApiGetCall& call) | |
736 { | |
4419 | 737 if (call.IsDocumentation()) |
738 { | |
739 call.GetDocumentation() | |
740 .SetTag("Networking") | |
741 .SetSummary("List query/retrieve operations") | |
742 .SetDescription("List the identifiers of all the query/retrieve operations on DICOM modalities, " | |
743 "as initiated by calls to `/modalities/{id}/query`. The length of this list is bounded " | |
744 "by the `QueryRetrieveSize` configuration option of Orthanc. " | |
745 "https://book.orthanc-server.com/users/rest.html#performing-query-retrieve-c-find-and-find-with-rest") | |
746 .AddAnswerType(MimeType_Json, "JSON array containing the identifiers"); | |
747 return; | |
748 } | |
749 | |
1368 | 750 ServerContext& context = OrthancRestApi::GetContext(call); |
751 | |
752 std::list<std::string> queries; | |
753 context.GetQueryRetrieveArchive().List(queries); | |
754 | |
755 Json::Value result = Json::arrayValue; | |
756 for (std::list<std::string>::const_iterator | |
757 it = queries.begin(); it != queries.end(); ++it) | |
758 { | |
759 result.append(*it); | |
760 } | |
761 | |
762 call.GetOutput().AnswerJson(result); | |
763 } | |
764 | |
765 | |
766 namespace | |
767 { | |
768 class QueryAccessor | |
769 { | |
770 private: | |
771 ServerContext& context_; | |
772 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
|
773 QueryRetrieveHandler* handler_; |
1368 | 774 |
775 public: | |
4205 | 776 explicit QueryAccessor(RestApiCall& call) : |
1368 | 777 context_(OrthancRestApi::GetContext(call)), |
778 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
|
779 handler_(NULL) |
1368 | 780 { |
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
|
781 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
|
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 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
|
784 } |
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
|
785 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
|
786 { |
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 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
|
788 } |
1368 | 789 } |
790 | |
2867 | 791 QueryRetrieveHandler& GetHandler() const |
1368 | 792 { |
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
|
793 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
|
794 return *handler_; |
1368 | 795 } |
796 }; | |
797 | |
798 static void AnswerDicomMap(RestApiCall& call, | |
799 const DicomMap& value, | |
800 bool simplify) | |
801 { | |
802 Json::Value full = Json::objectValue; | |
803 FromDcmtkBridge::ToJson(full, value, simplify); | |
804 call.GetOutput().AnswerJson(full); | |
805 } | |
806 } | |
807 | |
808 | |
809 static void ListQueryAnswers(RestApiGetCall& call) | |
810 { | |
4419 | 811 if (call.IsDocumentation()) |
812 { | |
813 call.GetDocumentation() | |
814 .SetTag("Networking") | |
815 .SetSummary("List answers to a query") | |
816 .SetDescription("List the indices of all the available answers resulting from a query/retrieve operation " | |
817 "on some DICOM modality, whose identifier is provided in the URL") | |
818 .SetUriArgument("id", "Identifier of the query of interest") | |
819 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, | |
820 "If present, retrieve detailed information about the individual answers", false) | |
821 .SetHttpGetArgument("simplify", RestApiCallDocumentation::Type_String, | |
822 "If present and if `expand` is present, format the tags of the answers in human-readable format", false) | |
823 .AddAnswerType(MimeType_Json, "JSON array containing the indices of the answers, or detailed information " | |
824 "about the reported answers (if `expand` argument is provided)"); | |
825 return; | |
826 } | |
827 | |
2948
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
828 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
|
829 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
|
830 |
1368 | 831 QueryAccessor query(call); |
2867 | 832 size_t count = query.GetHandler().GetAnswersCount(); |
1368 | 833 |
834 Json::Value result = Json::arrayValue; | |
835 for (size_t i = 0; i < count; i++) | |
836 { | |
2948
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
837 if (expand) |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
838 { |
2988
9cc3d40e389b
Orthanc 1.4.3 is now known as 1.5.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2986
diff
changeset
|
839 // 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
|
840 DicomMap value; |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
841 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
|
842 |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
843 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
|
844 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
|
845 |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
846 result.append(json); |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
847 } |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
848 else |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
849 { |
d2e548e643af
New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2944
diff
changeset
|
850 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
|
851 } |
1368 | 852 } |
853 | |
854 call.GetOutput().AnswerJson(result); | |
855 } | |
856 | |
857 | |
858 static void GetQueryOneAnswer(RestApiGetCall& call) | |
859 { | |
4419 | 860 if (call.IsDocumentation()) |
861 { | |
862 call.GetDocumentation() | |
863 .SetTag("Networking") | |
864 .SetSummary("Get one answer") | |
865 .SetDescription("Get the content (DICOM tags) of one answer associated with the " | |
866 "query/retrieve operation whose identifier is provided in the URL") | |
867 .SetUriArgument("id", "Identifier of the query of interest") | |
868 .SetUriArgument("index", "Index of the answer") | |
869 .SetHttpGetArgument("simplify", RestApiCallDocumentation::Type_String, | |
870 "If present, format the tags of the answer in human-readable format", false) | |
871 .AddAnswerType(MimeType_Json, "JSON object containing the DICOM tags of the answer"); | |
872 return; | |
873 } | |
874 | |
1368 | 875 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
|
876 |
1368 | 877 QueryAccessor query(call); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
878 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
879 DicomMap map; |
2867 | 880 query.GetHandler().GetAnswer(map, index); |
1787
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
881 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
882 AnswerDicomMap(call, map, call.HasArgument("simplify")); |
1368 | 883 } |
884 | |
885 | |
2867 | 886 static void SubmitRetrieveJob(RestApiPostCall& call, |
887 bool allAnswers, | |
888 size_t index) | |
889 { | |
890 ServerContext& context = OrthancRestApi::GetContext(call); | |
891 | |
892 std::string targetAet; | |
3870
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
893 int timeout = -1; |
2867 | 894 |
895 Json::Value body; | |
896 if (call.ParseJsonRequest(body)) | |
897 { | |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
898 targetAet = Toolbox::GetJsonStringField(body, KEY_TARGET_AET, context.GetDefaultLocalApplicationEntityTitle()); |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
899 timeout = Toolbox::GetJsonIntegerField(body, KEY_TIMEOUT, -1); |
2867 | 900 } |
901 else | |
902 { | |
903 body = Json::objectValue; | |
3870
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
904 if (call.GetBodySize() > 0) |
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
905 { |
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
906 call.BodyToString(targetAet); |
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
907 } |
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
908 else |
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
909 { |
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
910 targetAet = context.GetDefaultLocalApplicationEntityTitle(); |
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
911 } |
2867 | 912 } |
913 | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
914 std::unique_ptr<DicomMoveScuJob> job(new DicomMoveScuJob(context)); |
2867 | 915 |
916 { | |
917 QueryAccessor query(call); | |
918 job->SetTargetAet(targetAet); | |
919 job->SetLocalAet(query.GetHandler().GetLocalAet()); | |
920 job->SetRemoteModality(query.GetHandler().GetRemoteModality()); | |
3875
ea1d32861cfc
moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3874
diff
changeset
|
921 |
ea1d32861cfc
moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3874
diff
changeset
|
922 if (timeout >= 0) |
ea1d32861cfc
moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3874
diff
changeset
|
923 { |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
924 // New in Orthanc 1.7.0 |
3875
ea1d32861cfc
moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3874
diff
changeset
|
925 job->SetTimeout(static_cast<uint32_t>(timeout)); |
ea1d32861cfc
moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3874
diff
changeset
|
926 } |
2867 | 927 |
928 LOG(WARNING) << "Driving C-Move SCU on remote modality " | |
929 << query.GetHandler().GetRemoteModality().GetApplicationEntityTitle() | |
930 << " to target modality " << targetAet; | |
931 | |
932 if (allAnswers) | |
933 { | |
934 for (size_t i = 0; i < query.GetHandler().GetAnswersCount(); i++) | |
935 { | |
936 job->AddFindAnswer(query.GetHandler(), i); | |
937 } | |
938 } | |
939 else | |
940 { | |
941 job->AddFindAnswer(query.GetHandler(), index); | |
942 } | |
943 } | |
944 | |
945 OrthancRestApi::GetApi(call).SubmitCommandsJob | |
946 (call, job.release(), true /* synchronous by default */, body); | |
947 } | |
4419 | 948 |
949 | |
950 static void DocumentRetrieveShared(RestApiPostCall& call) | |
951 { | |
952 OrthancRestApi::DocumentSubmitCommandsJob(call); | |
953 call.GetDocumentation() | |
954 .SetTag("Networking") | |
955 .SetUriArgument("id", "Identifier of the query of interest") | |
956 .SetRequestField(KEY_TARGET_AET, RestApiCallDocumentation::Type_String, | |
957 "AET of the target modality. By default, the AET of Orthanc is used, as defined in the " | |
958 "`DicomAet` configuration option.", false) | |
959 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number, | |
4421 | 960 "Timeout for the C-MOVE command, in seconds", false) |
4419 | 961 .AddRequestType(MimeType_PlainText, "AET of the target modality"); |
962 } | |
2867 | 963 |
964 | |
1368 | 965 static void RetrieveOneAnswer(RestApiPostCall& call) |
966 { | |
4419 | 967 if (call.IsDocumentation()) |
968 { | |
969 DocumentRetrieveShared(call); | |
970 call.GetDocumentation() | |
971 .SetSummary("Retrieve one answer") | |
4422 | 972 .SetDescription("Start a C-MOVE SCU command as a job, in order to retrieve one answer associated with the " |
4419 | 973 "query/retrieve operation whose identifiers are provided in the URL: " |
974 "https://book.orthanc-server.com/users/rest.html#performing-retrieve-c-move") | |
975 .SetUriArgument("index", "Index of the answer"); | |
976 return; | |
977 } | |
978 | |
1368 | 979 size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", "")); |
2867 | 980 SubmitRetrieveJob(call, false, index); |
1368 | 981 } |
982 | |
983 | |
984 static void RetrieveAllAnswers(RestApiPostCall& call) | |
985 { | |
4419 | 986 if (call.IsDocumentation()) |
987 { | |
988 DocumentRetrieveShared(call); | |
989 call.GetDocumentation() | |
990 .SetSummary("Retrieve all answers") | |
4422 | 991 .SetDescription("Start a C-MOVE SCU command as a job, in order to retrieve all the answers associated with the " |
4419 | 992 "query/retrieve operation whose identifier is provided in the URL: " |
993 "https://book.orthanc-server.com/users/rest.html#performing-retrieve-c-move"); | |
994 return; | |
995 } | |
996 | |
2867 | 997 SubmitRetrieveJob(call, true, 0); |
1368 | 998 } |
999 | |
1000 | |
1001 static void GetQueryArguments(RestApiGetCall& call) | |
1002 { | |
4419 | 1003 if (call.IsDocumentation()) |
1004 { | |
1005 call.GetDocumentation() | |
1006 .SetTag("Networking") | |
1007 .SetSummary("Get original query arguments") | |
1008 .SetDescription("Get the original DICOM filter associated with the query/retrieve operation " | |
1009 "whose identifier is provided in the URL") | |
1010 .SetUriArgument("id", "Identifier of the query of interest") | |
1011 .SetHttpGetArgument("simplify", RestApiCallDocumentation::Type_String, | |
1012 "If present, format the tags of the DICOM filter in human-readable format", false) | |
1013 .AddAnswerType(MimeType_Json, "Content of the original query"); | |
1014 return; | |
1015 } | |
1016 | |
1368 | 1017 QueryAccessor query(call); |
2867 | 1018 AnswerDicomMap(call, query.GetHandler().GetQuery(), call.HasArgument("simplify")); |
1368 | 1019 } |
1020 | |
1021 | |
1022 static void GetQueryLevel(RestApiGetCall& call) | |
1023 { | |
4419 | 1024 if (call.IsDocumentation()) |
1025 { | |
1026 call.GetDocumentation() | |
1027 .SetTag("Networking") | |
1028 .SetSummary("Get level of original query") | |
1029 .SetDescription("Get the query level (value of the `QueryRetrieveLevel` tag) of the query/retrieve operation " | |
1030 "whose identifier is provided in the URL") | |
1031 .SetUriArgument("id", "Identifier of the query of interest") | |
1032 .AddAnswerType(MimeType_PlainText, "The level"); | |
1033 return; | |
1034 } | |
1035 | |
1368 | 1036 QueryAccessor query(call); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1037 call.GetOutput().AnswerBuffer(EnumerationToString(query.GetHandler().GetLevel()), MimeType_PlainText); |
1368 | 1038 } |
1039 | |
1040 | |
1041 static void GetQueryModality(RestApiGetCall& call) | |
1042 { | |
4419 | 1043 if (call.IsDocumentation()) |
1044 { | |
1045 call.GetDocumentation() | |
1046 .SetTag("Networking") | |
1047 .SetSummary("Get modality of original query") | |
1048 .SetDescription("Get the identifier of the DICOM modality that was targeted by the query/retrieve operation " | |
1049 "whose identifier is provided in the URL") | |
1050 .SetUriArgument("id", "Identifier of the query of interest") | |
1051 .AddAnswerType(MimeType_PlainText, "The identifier of the DICOM modality"); | |
1052 return; | |
1053 } | |
1054 | |
1368 | 1055 QueryAccessor query(call); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1056 call.GetOutput().AnswerBuffer(query.GetHandler().GetModalitySymbolicName(), MimeType_PlainText); |
1368 | 1057 } |
1058 | |
1059 | |
1060 static void DeleteQuery(RestApiDeleteCall& call) | |
1061 { | |
4419 | 1062 if (call.IsDocumentation()) |
1063 { | |
1064 call.GetDocumentation() | |
1065 .SetTag("Networking") | |
1066 .SetSummary("Delete a query") | |
1067 .SetDescription("Delete the query/retrieve operation whose identifier is provided in the URL") | |
1068 .SetUriArgument("id", "Identifier of the query of interest"); | |
1069 return; | |
1070 } | |
1071 | |
1368 | 1072 ServerContext& context = OrthancRestApi::GetContext(call); |
1073 context.GetQueryRetrieveArchive().Remove(call.GetUriComponent("id", "")); | |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1074 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
1368 | 1075 } |
1076 | |
1077 | |
1078 static void ListQueryOperations(RestApiGetCall& call) | |
1079 { | |
4419 | 1080 if (call.IsDocumentation()) |
1081 { | |
1082 call.GetDocumentation() | |
1083 .SetTag("Networking") | |
1084 .SetSummary("List operations on a query") | |
1085 .SetDescription("List the available operations for the query/retrieve operation whose identifier is provided in the URL") | |
1086 .SetUriArgument("id", "Identifier of the query of interest") | |
1087 .AddAnswerType(MimeType_Json, "JSON array containing the list of operations"); | |
1088 return; | |
1089 } | |
1090 | |
1368 | 1091 // Ensure that the query of interest does exist |
1092 QueryAccessor query(call); | |
1093 | |
1094 RestApi::AutoListChildren(call); | |
1095 } | |
1096 | |
1097 | |
1098 static void ListQueryAnswerOperations(RestApiGetCall& call) | |
1099 { | |
4419 | 1100 if (call.IsDocumentation()) |
1101 { | |
1102 call.GetDocumentation() | |
1103 .SetTag("Networking") | |
1104 .SetSummary("List operations on an answer") | |
1105 .SetDescription("List the available operations on an answer associated with the " | |
1106 "query/retrieve operation whose identifier is provided in the URL") | |
1107 .SetUriArgument("id", "Identifier of the query of interest") | |
1108 .SetUriArgument("index", "Index of the answer") | |
1109 .AddAnswerType(MimeType_Json, "JSON array containing the list of operations"); | |
1110 return; | |
1111 } | |
1112 | |
1368 | 1113 // Ensure that the query of interest does exist |
1114 QueryAccessor query(call); | |
1115 | |
1116 // Ensure that the answer of interest does exist | |
1117 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
|
1118 |
1b1d5470233f
refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1737
diff
changeset
|
1119 DicomMap map; |
2867 | 1120 query.GetHandler().GetAnswer(map, index); |
1368 | 1121 |
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
|
1122 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
|
1123 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
|
1124 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
|
1125 |
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
|
1126 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
|
1127 { |
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
|
1128 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
|
1129 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
|
1130 |
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
|
1131 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
|
1132 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
|
1133 |
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
|
1134 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
|
1135 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
|
1136 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
|
1137 |
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
|
1138 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
|
1139 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
|
1140 } |
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
|
1141 |
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
|
1142 call.GetOutput().AnswerJson(answer); |
1368 | 1143 } |
1144 | |
1145 | |
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
|
1146 template <ResourceType CHILDREN_LEVEL> |
2986
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1147 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
|
1148 { |
2988
9cc3d40e389b
Orthanc 1.4.3 is now known as 1.5.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2986
diff
changeset
|
1149 // 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
|
1150 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
|
1151 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
|
1152 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
|
1153 |
4419 | 1154 if (call.IsDocumentation()) |
1155 { | |
1156 const std::string resources = GetResourceTypeText(CHILDREN_LEVEL, true /* plural */, false /* lower case */); | |
1157 call.GetDocumentation() | |
1158 .SetTag("Networking") | |
1159 .SetSummary("Query the child " + resources + " of an answer") | |
1160 .SetDescription("Issue a second DICOM C-FIND operation, in order to query the child " + resources + | |
1161 " associated with one answer to some query/retrieve operation whose identifiers are provided in the URL") | |
1162 .SetUriArgument("id", "Identifier of the query of interest") | |
1163 .SetUriArgument("index", "Index of the answer") | |
1164 .SetRequestField(KEY_QUERY, RestApiCallDocumentation::Type_JsonObject, | |
4421 | 1165 "Associative array containing the filter on the values of the DICOM tags", true) |
4419 | 1166 .SetAnswerField("ID", RestApiCallDocumentation::Type_JsonObject, |
1167 "Identifier of the query, to be used with `/queries/{id}`") | |
1168 .SetAnswerField("Path", RestApiCallDocumentation::Type_JsonObject, | |
1169 "Root path to the query in the REST API"); | |
1170 return; | |
1171 } | |
1172 | |
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
|
1173 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
|
1174 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1175 std::unique_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context)); |
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
|
1176 |
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
|
1177 { |
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
|
1178 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
|
1179 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
|
1180 |
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
|
1181 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
|
1182 |
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
|
1183 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
|
1184 |
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
|
1185 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
|
1186 { |
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
|
1187 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
|
1188 } |
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
|
1189 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
|
1190 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
|
1191 { |
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
|
1192 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
|
1193 } |
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
|
1194 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
|
1195 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
|
1196 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
|
1197 { |
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
|
1198 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
|
1199 } |
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
|
1200 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
|
1201 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
|
1202 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
|
1203 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
|
1204 { |
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
|
1205 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
|
1206 } |
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
|
1207 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
|
1208 { |
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
|
1209 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
|
1210 } |
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
|
1211 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
|
1212 { |
3370
872bd3b6ec72
"/modalities/{id}/query": New argument "Normalize"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3345
diff
changeset
|
1213 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
|
1214 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
|
1215 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
|
1216 |
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
|
1217 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
|
1218 { |
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
|
1219 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
|
1220 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
|
1221 |
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
|
1222 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
|
1223 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
|
1224 { |
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
|
1225 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
|
1226 } |
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
|
1227 } |
2986
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1228 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1229 DicomMap answer; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1230 parent.GetHandler().GetAnswer(answer, index); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1231 |
3830
447880856ce8
removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3808
diff
changeset
|
1232 // This switch-case mimics "DicomControlUserConnection::Move()" |
2986
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1233 switch (parent.GetHandler().GetLevel()) |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1234 { |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1235 case ResourceType_Patient: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1236 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
|
1237 break; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1238 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1239 case ResourceType_Study: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1240 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
|
1241 break; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1242 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1243 case ResourceType_Series: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1244 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
|
1245 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
|
1246 break; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1247 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1248 case ResourceType_Instance: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1249 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
|
1250 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
|
1251 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
|
1252 break; |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1253 |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1254 default: |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1255 throw OrthancException(ErrorCode_InternalError); |
b1ba0a8311b5
exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2982
diff
changeset
|
1256 } |
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
|
1257 } |
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
|
1258 } |
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
|
1259 |
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
|
1260 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
|
1261 } |
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
|
1262 |
1368 | 1263 |
1264 | |
1265 /*************************************************************************** | |
1266 * DICOM C-Store SCU | |
1267 ***************************************************************************/ | |
1268 | |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1269 static void GetInstancesToExport(Json::Value& otherArguments, |
2626 | 1270 SetOfInstancesJob& job, |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1271 const std::string& remote, |
974 | 1272 RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1273 { |
1428 | 1274 otherArguments = Json::objectValue; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1275 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1276 |
1428 | 1277 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
|
1278 if (Toolbox::IsSHA1(call.GetBodyData(), call.GetBodySize())) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1279 { |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1428
diff
changeset
|
1280 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
|
1281 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
|
1282 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1283 // This is for compatibility with Orthanc <= 0.5.1. |
1428 | 1284 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
|
1285 request.append(Toolbox::StripSpaces(s)); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1286 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1287 else if (!call.ParseJsonRequest(request)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1288 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1289 // 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
|
1290 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON value"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1291 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1292 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1293 if (request.isString()) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1294 { |
1428 | 1295 std::string item = request.asString(); |
1296 request = Json::arrayValue; | |
1297 request.append(item); | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1298 } |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1299 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
|
1300 !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
|
1301 { |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1302 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
|
1303 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1304 |
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
|
1305 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
|
1306 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
|
1307 { |
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
|
1308 resources = &request; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1309 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1310 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1311 { |
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
|
1312 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
|
1313 !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
|
1314 { |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1315 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
|
1316 "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
|
1317 } |
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
|
1318 |
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
|
1319 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
|
1320 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
|
1321 { |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1322 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
|
1323 "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
|
1324 } |
1428 | 1325 |
1326 // Copy the remaining arguments | |
1327 Json::Value::Members members = request.getMemberNames(); | |
1328 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++) | |
1329 { | |
1330 otherArguments[members[i]] = request[members[i]]; | |
1331 } | |
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
|
1332 } |
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
|
1333 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1334 bool logExportedResources; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1335 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1336 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1337 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1338 logExportedResources = lock.GetConfiguration().GetBooleanParameter("LogExportedResources", false); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1339 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1340 |
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
|
1341 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
|
1342 { |
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
|
1343 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
|
1344 { |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1345 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
|
1346 "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
|
1347 } |
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
|
1348 |
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
|
1349 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
|
1350 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
|
1351 { |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1352 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
|
1353 "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
|
1354 } |
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
|
1355 |
3374
d0d6bd633e4c
Reporting of "ParentResources" in "DicomModalityStore" and "DicomModalityStore" jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3370
diff
changeset
|
1356 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
|
1357 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1358 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
|
1359 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1360 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
|
1361 { |
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
|
1362 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
|
1363 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1364 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1365 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1366 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1367 |
2584 | 1368 static void DicomStore(RestApiPostCall& call) |
1369 { | |
4422 | 1370 static const char* KEY_MOVE_ORIGINATOR_AET = "MoveOriginatorAet"; |
1371 static const char* KEY_MOVE_ORIGINATOR_ID = "MoveOriginatorID"; | |
1372 static const char* KEY_STORAGE_COMMITMENT = "StorageCommitment"; | |
1373 | |
1374 if (call.IsDocumentation()) | |
1375 { | |
1376 OrthancRestApi::DocumentSubmitCommandsJob(call); | |
1377 call.GetDocumentation() | |
1378 .SetTag("Networking") | |
1379 .SetSummary("Trigger C-STORE SCU") | |
1380 .SetDescription("Start a C-STORE SCU command as a job, in order to send DICOM resources stored locally " | |
1381 "to some remote DICOM modality whose identifier is provided in the URL: " | |
1382 "https://book.orthanc-server.com/users/rest.html#rest-store-scu") | |
4423 | 1383 .AddRequestType(MimeType_PlainText, "The Orthanc identifier of one resource to be sent") |
4422 | 1384 .SetRequestField(KEY_RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, |
1385 "List of the Orthanc identifiers of all the DICOM resources to be sent", true) | |
1386 .SetRequestField(KEY_LOCAL_AET, RestApiCallDocumentation::Type_String, | |
1387 "Local AET that is used for this commands, defaults to `DicomAet` configuration option", false) | |
1388 .SetRequestField(KEY_MOVE_ORIGINATOR_AET, RestApiCallDocumentation::Type_String, | |
1389 "Move originator AET that is used for this commands, in order to fake a C-MOVE SCU", false) | |
1390 .SetRequestField(KEY_MOVE_ORIGINATOR_ID, RestApiCallDocumentation::Type_Number, | |
1391 "Move originator ID that is used for this commands, in order to fake a C-MOVE SCU", false) | |
1392 .SetRequestField(KEY_STORAGE_COMMITMENT, RestApiCallDocumentation::Type_Boolean, | |
4423 | 1393 "Whether to chain C-STORE with DICOM storage commitment to validate the success of the transmission: " |
1394 "https://book.orthanc-server.com/users/storage-commitment.html#chaining-c-store-with-storage-commitment", false) | |
4422 | 1395 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number, |
1396 "Timeout for the C-STORE command, in seconds", false) | |
1397 .SetUriArgument("id", "Identifier of the modality of interest"); | |
1398 return; | |
1399 } | |
1400 | |
2584 | 1401 ServerContext& context = OrthancRestApi::GetContext(call); |
1402 | |
1403 std::string remote = call.GetUriComponent("id", ""); | |
1404 | |
1405 Json::Value request; | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1406 std::unique_ptr<DicomModalityStoreJob> job(new DicomModalityStoreJob(context)); |
2584 | 1407 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1408 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
|
1409 |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1410 std::string localAet = Toolbox::GetJsonStringField |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
1411 (request, KEY_LOCAL_AET, context.GetDefaultLocalApplicationEntityTitle()); |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1412 std::string moveOriginatorAET = Toolbox::GetJsonStringField |
4422 | 1413 (request, KEY_MOVE_ORIGINATOR_AET, context.GetDefaultLocalApplicationEntityTitle()); |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1414 int moveOriginatorID = Toolbox::GetJsonIntegerField |
4422 | 1415 (request, KEY_MOVE_ORIGINATOR_ID, 0 /* By default, not a C-MOVE */); |
2584 | 1416 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1417 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
|
1418 job->SetRemoteModality(MyGetModalityUsingSymbolicName(remote)); |
2584 | 1419 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1420 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
|
1421 { |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1422 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
|
1423 } |
2626 | 1424 |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
1425 // New in Orthanc 1.6.0 |
4422 | 1426 if (Toolbox::GetJsonBooleanField(request, KEY_STORAGE_COMMITMENT, false)) |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
1427 { |
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
1428 job->EnableStorageCommitment(true); |
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
1429 } |
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
1430 |
3870
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
1431 // New in Orthanc 1.7.0 |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
1432 if (request.isMember(KEY_TIMEOUT)) |
3875
ea1d32861cfc
moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3874
diff
changeset
|
1433 { |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
1434 job->SetTimeout(SerializationToolbox::ReadUnsignedInteger(request, KEY_TIMEOUT)); |
3875
ea1d32861cfc
moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3874
diff
changeset
|
1435 } |
3870
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
1436 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1437 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
|
1438 (call, job.release(), true /* synchronous by default */, request); |
2584 | 1439 } |
1440 | |
1441 | |
3808
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1442 static void DicomStoreStraight(RestApiPostCall& call) |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1443 { |
4421 | 1444 if (call.IsDocumentation()) |
1445 { | |
1446 call.GetDocumentation() | |
1447 .SetTag("Networking") | |
1448 .SetSummary("Straight C-STORE SCU") | |
1449 .SetDescription("Synchronously send the DICOM instance in the POST body to the remote DICOM modality " | |
1450 "whose identifier is provided in URL, without having to first store it locally within Orthanc. " | |
1451 "This is an alternative to command-line tools such as `storescu` from DCMTK or dcm4che.") | |
1452 .SetUriArgument("id", "Identifier of the modality of interest") | |
1453 .AddRequestType(MimeType_Dicom, "DICOM instance to be sent") | |
1454 .SetAnswerField(SOP_CLASS_UID, RestApiCallDocumentation::Type_String, | |
1455 "SOP class UID of the DICOM instance, if the C-STORE SCU has succeeded") | |
1456 .SetAnswerField(SOP_INSTANCE_UID, RestApiCallDocumentation::Type_String, | |
1457 "SOP instance UID of the DICOM instance, if the C-STORE SCU has succeeded"); | |
1458 return; | |
1459 } | |
1460 | |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
1461 Json::Value body = Json::objectValue; // No body |
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
1462 DicomStoreUserConnection connection(GetAssociationParameters(call, body)); |
3808
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1463 |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1464 std::string sopClassUid, sopInstanceUid; |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3876
diff
changeset
|
1465 connection.Store(sopClassUid, sopInstanceUid, call.GetBodyData(), |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3876
diff
changeset
|
1466 call.GetBodySize(), false /* Not a C-MOVE */, "", 0); |
3808
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1467 |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1468 Json::Value answer = Json::objectValue; |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1469 answer[SOP_CLASS_UID] = sopClassUid; |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1470 answer[SOP_INSTANCE_UID] = sopInstanceUid; |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1471 |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1472 call.GetOutput().AnswerJson(answer); |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1473 } |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1474 |
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
1475 |
1368 | 1476 /*************************************************************************** |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1477 * 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
|
1478 ***************************************************************************/ |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1479 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1480 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
|
1481 { |
4423 | 1482 if (call.IsDocumentation()) |
1483 { | |
1484 OrthancRestApi::DocumentSubmitCommandsJob(call); | |
1485 call.GetDocumentation() | |
1486 .SetTag("Networking") | |
1487 .SetSummary("Trigger C-MOVE SCU") | |
1488 .SetDescription("Start a C-MOVE SCU command as a job, in order to drive the execution of a sequence of " | |
1489 "C-STORE commands by some remote DICOM modality whose identifier is provided in the URL: " | |
1490 "https://book.orthanc-server.com/users/rest.html#performing-c-move") | |
1491 .SetRequestField(KEY_RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, | |
1492 "List of the Orthanc identifiers of all the DICOM resources to be sent", true) | |
1493 .SetRequestField(KEY_LEVEL, RestApiCallDocumentation::Type_String, | |
1494 "Level of the query (`Patient`, `Study`, `Series` or `Instance`)", true) | |
1495 .SetRequestField(KEY_LOCAL_AET, RestApiCallDocumentation::Type_String, | |
1496 "Local AET that is used for this commands, defaults to `DicomAet` configuration option", false) | |
1497 .SetRequestField(KEY_TARGET_AET, RestApiCallDocumentation::Type_String, | |
1498 "Target AET that will be used by the remote DICOM modality as a target for its C-STORE SCU " | |
1499 "commands, defaults to `DicomAet` configuration option in order to do a simple query/retrieve", false) | |
1500 .SetRequestField(KEY_TIMEOUT, RestApiCallDocumentation::Type_Number, | |
1501 "Timeout for the C-STORE command, in seconds", false) | |
1502 .SetUriArgument("id", "Identifier of the modality of interest"); | |
1503 return; | |
1504 } | |
1505 | |
4205 | 1506 const ServerContext& context = OrthancRestApi::GetContext(call); |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1507 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1508 Json::Value request; |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1509 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1510 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
|
1511 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
|
1512 !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
|
1513 !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
|
1514 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
|
1515 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
|
1516 { |
3345
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
1517 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
|
1518 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
|
1519 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1520 |
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
|
1521 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
|
1522 |
2584 | 1523 std::string localAet = Toolbox::GetJsonStringField |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
1524 (request, KEY_LOCAL_AET, context.GetDefaultLocalApplicationEntityTitle()); |
2584 | 1525 std::string targetAet = Toolbox::GetJsonStringField |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
1526 (request, KEY_TARGET_AET, context.GetDefaultLocalApplicationEntityTitle()); |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1527 |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1528 const RemoteModalityParameters source = |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1529 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1530 |
3874
2effa961f67f
forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3870
diff
changeset
|
1531 DicomAssociationParameters params(localAet, source); |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
1532 InjectAssociationTimeout(params, request); |
3875
ea1d32861cfc
moving timeout from DicomAssocation to DicomAssociationParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3874
diff
changeset
|
1533 |
3874
2effa961f67f
forcing use of DicomAssociationParameters if creating an SCU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3870
diff
changeset
|
1534 DicomControlUserConnection connection(params); |
3870
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3863
diff
changeset
|
1535 |
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
|
1536 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
|
1537 { |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1538 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
|
1539 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
|
1540 |
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
1541 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
|
1542 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1543 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1544 // Move has succeeded |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1545 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
|
1546 } |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1547 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1548 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1549 |
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
1550 /*************************************************************************** |
1368 | 1551 * Orthanc Peers => Store client |
1552 ***************************************************************************/ | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1553 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1554 static bool IsExistingPeer(const OrthancRestApi::SetOfStrings& peers, |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1555 const std::string& id) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1556 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1557 return peers.find(id) != peers.end(); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1558 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1559 |
974 | 1560 static void ListPeers(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1561 { |
4418 | 1562 if (call.IsDocumentation()) |
1563 { | |
1564 call.GetDocumentation() | |
1565 .SetTag("Networking") | |
1566 .SetSummary("List Orthanc peers") | |
1567 .SetDescription("List all the Orthanc peers that are known to Orthanc. This corresponds either to the content of the " | |
1568 "`OrthancPeers` configuration option, or to the information stored in the database if " | |
1569 "`OrthancPeersInDatabase` is `true`.") | |
1570 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, | |
1571 "If present, retrieve detailed information about the individual Orthanc peers", false) | |
1572 .AddAnswerType(MimeType_Json, "JSON array containing either the identifiers of the peers, or detailed information " | |
1573 "about the peers (if `expand` argument is provided)"); | |
1574 return; | |
1575 } | |
1576 | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1577 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1578 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1579 OrthancRestApi::SetOfStrings peers; |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1580 lock.GetConfiguration().GetListOfOrthancPeers(peers); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1581 |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1582 if (call.HasArgument("expand")) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1583 { |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1584 Json::Value result = Json::objectValue; |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1585 for (OrthancRestApi::SetOfStrings::const_iterator |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1586 it = peers.begin(); it != peers.end(); ++it) |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1587 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1588 WebServiceParameters peer; |
2799
6e3a60b85da6
New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2685
diff
changeset
|
1589 |
2944
f395460af74d
simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
1590 if (lock.GetConfiguration().LookupOrthancPeer(peer, *it)) |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1591 { |
3192
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3167
diff
changeset
|
1592 Json::Value info; |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3167
diff
changeset
|
1593 peer.FormatPublic(info); |
595bfee4391a
URI "/peers?expand" provides more information
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3167
diff
changeset
|
1594 result[*it] = info; |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1595 } |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1596 } |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1597 call.GetOutput().AnswerJson(result); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1598 } |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1599 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
|
1600 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1601 Json::Value result = Json::arrayValue; |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1602 for (OrthancRestApi::SetOfStrings::const_iterator |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1603 it = peers.begin(); it != peers.end(); ++it) |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1604 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1605 result.append(*it); |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1606 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1607 |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1608 call.GetOutput().AnswerJson(result); |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1609 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1610 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1611 |
974 | 1612 static void ListPeerOperations(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1613 { |
4418 | 1614 if (call.IsDocumentation()) |
1615 { | |
1616 call.GetDocumentation() | |
1617 .SetTag("Networking") | |
1618 .SetSummary("List operations on peer") | |
1619 .SetDescription("List the operations that are available for an Orthanc peer.") | |
4419 | 1620 .SetUriArgument("id", "Identifier of the peer of interest") |
4418 | 1621 .AddAnswerType(MimeType_Json, "List of the available operations"); |
1622 return; | |
1623 } | |
1624 | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1625 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1626 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1627 OrthancRestApi::SetOfStrings peers; |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1628 lock.GetConfiguration().GetListOfOrthancPeers(peers); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1629 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1630 std::string id = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1631 if (IsExistingPeer(peers, id)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1632 { |
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
|
1633 RestApi::AutoListChildren(call); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1634 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1635 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1636 |
974 | 1637 static void PeerStore(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1638 { |
4423 | 1639 static const char* KEY_TRANSCODE = "Transcode"; |
1640 static const char* KEY_COMPRESS = "Compress"; | |
1641 | |
1642 if (call.IsDocumentation()) | |
1643 { | |
1644 OrthancRestApi::DocumentSubmitCommandsJob(call); | |
1645 call.GetDocumentation() | |
1646 .SetTag("Networking") | |
1647 .SetSummary("Send to Orthanc peer") | |
1648 .SetDescription("Send DICOM resources stored locally to some remote Orthanc peer whose identifier is provided in the URL: " | |
1649 "https://book.orthanc-server.com/users/rest.html#sending-one-resource") | |
1650 .AddRequestType(MimeType_PlainText, "The Orthanc identifier of one resource to be sent") | |
1651 .SetRequestField(KEY_RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, | |
1652 "List of the Orthanc identifiers of all the DICOM resources to be sent", true) | |
1653 .SetRequestField(KEY_TRANSCODE, RestApiCallDocumentation::Type_String, | |
1654 "Transcode to the provided DICOM transfer syntax before the actual sending", false) | |
1655 .SetRequestField(KEY_COMPRESS, RestApiCallDocumentation::Type_Boolean, | |
1656 "Whether to compress the DICOM instances using gzip before the actual sending", false) | |
1657 .SetUriArgument("id", "Identifier of the modality of interest"); | |
1658 return; | |
1659 } | |
1660 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1661 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1662 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1663 std::string remote = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1664 |
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
|
1665 Json::Value request; |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
1666 std::unique_ptr<OrthancPeerStoreJob> job(new OrthancPeerStoreJob(context)); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1667 |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1668 GetInstancesToExport(request, *job, remote, call); |
3950
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1669 |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1670 if (request.type() == Json::objectValue && |
4423 | 1671 request.isMember(KEY_TRANSCODE)) |
3950
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1672 { |
4423 | 1673 job->SetTranscode(SerializationToolbox::ReadString(request, KEY_TRANSCODE)); |
3950
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1674 } |
4153
a4664f169cd7
"/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
1675 |
a4664f169cd7
"/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
1676 if (request.type() == Json::objectValue && |
4423 | 1677 request.isMember(KEY_COMPRESS)) |
4153
a4664f169cd7
"/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
1678 { |
4423 | 1679 job->SetCompress(SerializationToolbox::ReadBoolean(request, KEY_COMPRESS)); |
4153
a4664f169cd7
"/peers/{id}/store": New option "Compress" to compress DICOM data using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
1680 } |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1681 |
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1682 { |
3950
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1683 OrthancConfiguration::ReaderLock lock; |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1684 |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1685 WebServiceParameters peer; |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1686 if (lock.GetConfiguration().LookupOrthancPeer(peer, remote)) |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1687 { |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1688 job->SetPeer(peer); |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1689 } |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1690 else |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1691 { |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1692 throw OrthancException(ErrorCode_UnknownResource, |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1693 "No peer with symbolic name: " + remote); |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1694 } |
3167
860aed8258c3
Fix issue #73 (/modalities/{modalityId}/store raises 500 errors instead of 404)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3097
diff
changeset
|
1695 } |
3950
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1696 |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1697 OrthancRestApi::GetApi(call).SubmitCommandsJob |
5797ca4f3b8d
"/peers/{id}/store": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3894
diff
changeset
|
1698 (call, job.release(), true /* synchronous by default */, request); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1699 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1700 |
3592
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1701 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
|
1702 { |
4418 | 1703 if (call.IsDocumentation()) |
1704 { | |
1705 call.GetDocumentation() | |
1706 .SetTag("Networking") | |
1707 .SetSummary("Get peer system information") | |
1708 .SetDescription("Get system information about some Orthanc peer. This corresponds to doing a `GET` request " | |
1709 "against the `/system` URI of the remote peer. This route can be used to test connectivity.") | |
4419 | 1710 .SetUriArgument("id", "Identifier of the peer of interest") |
4418 | 1711 .AddAnswerType(MimeType_Json, "System information about the peer"); |
1712 return; | |
1713 } | |
1714 | |
3592
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1715 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
|
1716 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1717 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
|
1718 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1719 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
|
1720 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
|
1721 { |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1722 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
|
1723 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
|
1724 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1725 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
|
1726 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1727 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
|
1728 { |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1729 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
|
1730 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
|
1731 return; |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1732 } |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1733 |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1734 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
|
1735 } |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1736 else |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1737 { |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1738 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
|
1739 "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
|
1740 } |
de1665e7b341
added '/peers/{id}/system' route to test the connectivity with a remote peer
Alain Mazy <alain@mazy.be>
parents:
3401
diff
changeset
|
1741 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1742 |
4338
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1743 static void GetPeerConfiguration(RestApiGetCall& call) |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1744 { |
4418 | 1745 if (call.IsDocumentation()) |
1746 { | |
1747 Json::Value sample; | |
1748 sample["HttpHeaders"] = Json::objectValue; | |
1749 sample["Password"] = Json::nullValue; | |
1750 sample["Pkcs11"] = false; | |
1751 sample["Url"] = "http://127.0.1.1:5000/"; | |
1752 sample["Username"] = "alice"; | |
1753 call.GetDocumentation() | |
1754 .SetTag("Networking") | |
1755 .SetSummary("Get peer configuration") | |
4421 | 1756 .SetDescription("Get detailed information about the configuration of some Orthanc peer") |
4419 | 1757 .SetUriArgument("id", "Identifier of the peer of interest") |
4418 | 1758 .AddAnswerType(MimeType_Json, "Configuration of the peer") |
1759 .SetSample(sample); | |
1760 return; | |
1761 } | |
1762 | |
4338
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1763 OrthancConfiguration::ReaderLock lock; |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1764 const std::string peer = call.GetUriComponent("id", ""); |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1765 |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1766 WebServiceParameters info; |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1767 if (lock.GetConfiguration().LookupOrthancPeer(info, peer)) |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1768 { |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1769 Json::Value answer; |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1770 info.FormatPublic(answer); |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1771 call.GetOutput().AnswerJson(answer); |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1772 } |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1773 else |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1774 { |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1775 throw OrthancException(ErrorCode_UnknownResource, |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1776 "No peer with symbolic name: " + peer); |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1777 } |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1778 } |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1779 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1780 // DICOM bridge ------------------------------------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1781 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1782 static bool IsExistingModality(const OrthancRestApi::SetOfStrings& modalities, |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1783 const std::string& id) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1784 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1785 return modalities.find(id) != modalities.end(); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1786 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1787 |
974 | 1788 static void ListModalities(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1789 { |
4418 | 1790 if (call.IsDocumentation()) |
1791 { | |
1792 call.GetDocumentation() | |
1793 .SetTag("Networking") | |
1794 .SetSummary("List DICOM modalities") | |
1795 .SetDescription("List all the DICOM modalities that are known to Orthanc. This corresponds either to the content of the " | |
1796 "`DicomModalities` configuration option, or to the information stored in the database if " | |
1797 "`DicomModalitiesInDatabase` is `true`.") | |
1798 .SetHttpGetArgument("expand", RestApiCallDocumentation::Type_String, | |
1799 "If present, retrieve detailed information about the individual DICOM modalities", false) | |
1800 .AddAnswerType(MimeType_Json, "JSON array containing either the identifiers of the modalities, or detailed information " | |
1801 "about the modalities (if `expand` argument is provided)"); | |
1802 return; | |
1803 } | |
1804 | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1805 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1806 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1807 OrthancRestApi::SetOfStrings modalities; |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1808 lock.GetConfiguration().GetListOfDicomModalities(modalities); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1809 |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1810 if (call.HasArgument("expand")) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1811 { |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1812 Json::Value result = Json::objectValue; |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1813 for (OrthancRestApi::SetOfStrings::const_iterator |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1814 it = modalities.begin(); it != modalities.end(); ++it) |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1815 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1816 const RemoteModalityParameters& remote = lock.GetConfiguration().GetModalityUsingSymbolicName(*it); |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1817 |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1818 Json::Value info; |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1819 remote.Serialize(info, true /* force advanced format */); |
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1820 result[*it] = info; |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1821 } |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1822 call.GetOutput().AnswerJson(result); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1823 } |
2441
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1824 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
|
1825 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1826 Json::Value result = Json::arrayValue; |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1827 for (OrthancRestApi::SetOfStrings::const_iterator |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1828 it = modalities.begin(); it != modalities.end(); ++it) |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1829 { |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1830 result.append(*it); |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1831 } |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1832 call.GetOutput().AnswerJson(result); |
67c01a6f151e
added ?expand argument to /peers and /modalities routes
amazy
parents:
2382
diff
changeset
|
1833 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1834 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1835 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1836 |
974 | 1837 static void ListModalityOperations(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1838 { |
4418 | 1839 if (call.IsDocumentation()) |
1840 { | |
1841 call.GetDocumentation() | |
1842 .SetTag("Networking") | |
1843 .SetSummary("List operations on modality") | |
1844 .SetDescription("List the operations that are available for a DICOM modality.") | |
4419 | 1845 .SetUriArgument("id", "Identifier of the DICOM modality of interest") |
4418 | 1846 .AddAnswerType(MimeType_Json, "List of the available operations"); |
1847 return; | |
1848 } | |
1849 | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1850 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1851 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1852 OrthancRestApi::SetOfStrings modalities; |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1853 lock.GetConfiguration().GetListOfDicomModalities(modalities); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1854 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1855 std::string id = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1856 if (IsExistingModality(modalities, id)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1857 { |
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
|
1858 RestApi::AutoListChildren(call); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1859 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1860 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1861 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1862 |
974 | 1863 static void UpdateModality(RestApiPutCall& call) |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1864 { |
4421 | 1865 if (call.IsDocumentation()) |
1866 { | |
1867 DocumentModalityParametersShared(call, true); | |
1868 call.GetDocumentation() | |
1869 .SetTag("Networking") | |
1870 .SetSummary("Update DICOM modality") | |
1871 .SetDescription("Define a new DICOM modality, or update an existing one. This change is permanent iff. " | |
1872 "`DicomModalitiesInDatabase` is `true`, otherwise it is lost at the next restart of Orthanc.") | |
1873 .SetUriArgument("id", "Identifier of the new/updated DICOM modality"); | |
1874 return; | |
1875 } | |
1876 | |
2801
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1877 ServerContext& context = OrthancRestApi::GetContext(call); |
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1878 |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1879 Json::Value json; |
3401 | 1880 if (call.ParseJsonRequest(json)) |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1881 { |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1882 RemoteModalityParameters modality; |
2871
6eebc2eb3168
refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2868
diff
changeset
|
1883 modality.Unserialize(json); |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1884 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1885 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1886 OrthancConfiguration::WriterLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1887 lock.GetConfiguration().UpdateModality(call.GetUriComponent("id", ""), modality); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1888 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1889 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1890 context.SignalUpdatedModalities(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1891 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1892 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1893 } |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
1894 else |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
1895 { |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
1896 throw OrthancException(ErrorCode_BadFileFormat); |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
1897 } |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1898 } |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1899 |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1900 |
974 | 1901 static void DeleteModality(RestApiDeleteCall& call) |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1902 { |
4418 | 1903 if (call.IsDocumentation()) |
1904 { | |
1905 call.GetDocumentation() | |
1906 .SetTag("Networking") | |
1907 .SetSummary("Delete DICOM modality") | |
1908 .SetDescription("Delete one DICOM modality. This change is permanent iff. `DicomModalitiesInDatabase` is `true`, " | |
1909 "otherwise it is lost at the next restart of Orthanc.") | |
4419 | 1910 .SetUriArgument("id", "Identifier of the DICOM modality of interest"); |
4418 | 1911 return; |
1912 } | |
1913 | |
2801
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1914 ServerContext& context = OrthancRestApi::GetContext(call); |
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1915 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1916 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1917 OrthancConfiguration::WriterLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1918 lock.GetConfiguration().RemoveModality(call.GetUriComponent("id", "")); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1919 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1920 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1921 context.SignalUpdatedModalities(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
1922 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1923 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1924 } |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1925 |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
1926 |
4338
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1927 static void GetModalityConfiguration(RestApiGetCall& call) |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1928 { |
4418 | 1929 if (call.IsDocumentation()) |
1930 { | |
1931 Json::Value sample; | |
1932 sample["AET"] = "ORTHANCTEST"; | |
1933 sample["AllowEcho"] = true; | |
1934 sample["AllowEventReport"] = true; | |
1935 sample["AllowFind"] = true; | |
1936 sample["AllowGet"] = true; | |
1937 sample["AllowMove"] = true; | |
1938 sample["AllowNAction"] = true; | |
1939 sample["AllowStore"] = true; | |
1940 sample["AllowTranscoding"] = true; | |
1941 sample["Host"] = "127.0.1.1"; | |
1942 sample["Manufacturer"] = "Generic"; | |
1943 sample["Port"] = 5001; | |
1944 call.GetDocumentation() | |
1945 .SetTag("Networking") | |
1946 .SetSummary("Get modality configuration") | |
4421 | 1947 .SetDescription("Get detailed information about the configuration of some DICOM modality") |
4419 | 1948 .SetUriArgument("id", "Identifier of the modality of interest") |
4418 | 1949 .AddAnswerType(MimeType_Json, "Configuration of the modality") |
1950 .SetSample(sample); | |
1951 return; | |
1952 } | |
1953 | |
4338
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1954 const std::string modality = call.GetUriComponent("id", ""); |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1955 |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1956 Json::Value answer; |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1957 |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1958 { |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1959 OrthancConfiguration::ReaderLock lock; |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1960 lock.GetConfiguration().GetModalityUsingSymbolicName(modality).Serialize(answer, true /* force advanced format */); |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1961 } |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1962 |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1963 call.GetOutput().AnswerJson(answer); |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1964 } |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1965 |
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
1966 |
974 | 1967 static void UpdatePeer(RestApiPutCall& call) |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1968 { |
4421 | 1969 if (call.IsDocumentation()) |
1970 { | |
1971 call.GetDocumentation() | |
1972 .SetTag("Networking") | |
1973 .SetSummary("Update Orthanc peer") | |
1974 .SetDescription("Define a new Orthanc peer, or update an existing one. This change is permanent iff. " | |
1975 "`OrthancPeersInDatabase` is `true`, otherwise it is lost at the next restart of Orthanc.") | |
1976 .SetUriArgument("id", "Identifier of the new/updated Orthanc peer") | |
1977 .SetRequestField("URL", RestApiCallDocumentation::Type_String, | |
1978 "URL of the root of the REST API of the remote Orthanc peer, for instance `http://localhost:8042/`", true) | |
1979 .SetRequestField("Username", RestApiCallDocumentation::Type_String, | |
1980 "Username for the credentials", false) | |
1981 .SetRequestField("Password", RestApiCallDocumentation::Type_String, | |
1982 "Password for the credentials", false) | |
1983 .SetRequestField("CertificateFile", RestApiCallDocumentation::Type_String, | |
1984 "SSL certificate for the HTTPS connections", false) | |
1985 .SetRequestField("CertificateKeyFile", RestApiCallDocumentation::Type_String, | |
1986 "Key file for the SSL certificate for the HTTPS connections", false) | |
1987 .SetRequestField("CertificateKeyPassword", RestApiCallDocumentation::Type_String, | |
1988 "Key password for the SSL certificate for the HTTPS connections", false) | |
1989 .SetRequestField("HttpHeaders", RestApiCallDocumentation::Type_JsonObject, | |
1990 "HTTP headers to be used for the connections to the remote peer", false); | |
1991 return; | |
1992 } | |
1993 | |
2801
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1994 ServerContext& context = OrthancRestApi::GetContext(call); |
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
1995 |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1996 Json::Value json; |
3401 | 1997 if (call.ParseJsonRequest(json)) |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
1998 { |
2020 | 1999 WebServiceParameters peer; |
2800
dc7330089736
"OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2799
diff
changeset
|
2000 peer.Unserialize(json); |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2001 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2002 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2003 OrthancConfiguration::WriterLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2004 lock.GetConfiguration().UpdatePeer(call.GetUriComponent("id", ""), peer); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2005 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2006 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2007 context.SignalUpdatedPeers(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2008 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2009 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2010 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2011 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2012 |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2013 |
974 | 2014 static void DeletePeer(RestApiDeleteCall& call) |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2015 { |
4418 | 2016 if (call.IsDocumentation()) |
2017 { | |
2018 call.GetDocumentation() | |
2019 .SetTag("Networking") | |
2020 .SetSummary("Delete Orthanc peer") | |
2021 .SetDescription("Delete one Orthanc peer. This change is permanent iff. `OrthancPeersInDatabase` is `true`, " | |
2022 "otherwise it is lost at the next restart of Orthanc.") | |
4419 | 2023 .SetUriArgument("id", "Identifier of the Orthanc peer of interest"); |
4418 | 2024 return; |
2025 } | |
2026 | |
2801
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
2027 ServerContext& context = OrthancRestApi::GetContext(call); |
3ee82c7313e7
New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2800
diff
changeset
|
2028 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2029 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2030 OrthancConfiguration::WriterLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2031 lock.GetConfiguration().RemovePeer(call.GetUriComponent("id", "")); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2032 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2033 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2034 context.SignalUpdatedPeers(); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2908
diff
changeset
|
2035 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2036 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2037 } |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2038 |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2039 |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2040 static void DicomFindWorklist(RestApiPostCall& call) |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2041 { |
4421 | 2042 if (call.IsDocumentation()) |
2043 { | |
2044 call.GetDocumentation() | |
2045 .SetTag("Networking") | |
2046 .SetSummary("C-FIND SCU for worklist") | |
2047 .SetDescription("Trigger C-FIND SCU command against the remote worklists of the DICOM modality " | |
2048 "whose identifier is provided in URL") | |
2049 .SetUriArgument("id", "Identifier of the modality of interest") | |
2050 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags") | |
2051 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching worklists"); | |
2052 return; | |
2053 } | |
2054 | |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2055 Json::Value json; |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2056 if (call.ParseJsonRequest(json)) |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2057 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3691
diff
changeset
|
2058 std::unique_ptr<ParsedDicomFile> query |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2059 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0), |
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3651
diff
changeset
|
2060 "" /* no private creator */)); |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2061 |
2059 | 2062 DicomFindAnswers answers(true); |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2063 |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2064 { |
3876
92ecaf877baf
improved code reuse in OrthancRestModalities, added missing timeout params
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
2065 DicomControlUserConnection connection(GetAssociationParameters(call, json)); |
2589
a3fdfb6979ed
getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2587
diff
changeset
|
2066 connection.FindWorklist(answers, *query); |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2067 } |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2068 |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2069 Json::Value result; |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2070 answers.ToJson(result, true); |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2071 call.GetOutput().AnswerJson(result); |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2072 } |
3345
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
2073 else |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
2074 { |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
2075 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); |
f687e11aeb13
more explicit HTTP errors
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3192
diff
changeset
|
2076 } |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2077 } |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2078 |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2079 |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2080 // Storage commitment SCU --------------------------------------------------- |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2081 |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2082 static void StorageCommitmentScu(RestApiPostCall& call) |
3611
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2083 { |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2084 static const char* const ORTHANC_RESOURCES = "Resources"; |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2085 static const char* const DICOM_INSTANCES = "DicomInstances"; |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2086 |
4423 | 2087 if (call.IsDocumentation()) |
2088 { | |
2089 call.GetDocumentation() | |
2090 .SetTag("Networking") | |
2091 .SetSummary("Trigger storage commitment request") | |
2092 .SetDescription("Trigger a storage commitment request to some remote DICOM modality whose identifier is provided " | |
2093 "in the URL: https://book.orthanc-server.com/users/storage-commitment.html#storage-commitment-scu") | |
2094 .SetRequestField(ORTHANC_RESOURCES, RestApiCallDocumentation::Type_JsonListOfStrings, | |
2095 "List of the Orthanc identifiers of the DICOM resources to be checked by storage commitment", true) | |
2096 .SetRequestField(DICOM_INSTANCES, RestApiCallDocumentation::Type_JsonListOfObjects, | |
2097 "List of DICOM resources that are not necessarily stored within Orthanc, but that must " | |
2098 "be checked by storage commitment. This is a list of JSON objects that must contain the " | |
2099 "`SOPClassUID` and `SOPInstanceUID` fields.", true) | |
2100 .SetAnswerField("ID", RestApiCallDocumentation::Type_JsonObject, | |
2101 "Identifier of the storage commitment report, to be used with `/storage-commitment/{id}`") | |
2102 .SetAnswerField("Path", RestApiCallDocumentation::Type_JsonObject, | |
2103 "Root path to the storage commitment report in the REST API") | |
2104 .SetUriArgument("id", "Identifier of the modality of interest"); | |
2105 return; | |
2106 } | |
2107 | |
3611
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2108 ServerContext& context = OrthancRestApi::GetContext(call); |
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2109 |
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2110 Json::Value json; |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2111 if (!call.ParseJsonRequest(json) || |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2112 json.type() != Json::objectValue) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2113 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2114 throw OrthancException(ErrorCode_BadFileFormat, |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2115 "Must provide a JSON object with a list of resources"); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2116 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2117 else if (!json.isMember(ORTHANC_RESOURCES) && |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2118 !json.isMember(DICOM_INSTANCES)) |
3611
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2119 { |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2120 throw OrthancException(ErrorCode_BadFileFormat, |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2121 "Empty storage commitment request, one of these fields is mandatory: \"" + |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2122 std::string(ORTHANC_RESOURCES) + "\" or \"" + std::string(DICOM_INSTANCES) + "\""); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2123 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2124 else |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2125 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2126 std::list<std::string> sopClassUids, sopInstanceUids; |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2127 |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2128 if (json.isMember(ORTHANC_RESOURCES)) |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2129 { |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2130 const Json::Value& resources = json[ORTHANC_RESOURCES]; |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2131 |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2132 if (resources.type() != Json::arrayValue) |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2133 { |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2134 throw OrthancException(ErrorCode_BadFileFormat, |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2135 "The \"" + std::string(ORTHANC_RESOURCES) + |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2136 "\" field must provide an array of Orthanc resources"); |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2137 } |
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2138 else |
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2139 { |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2140 for (Json::Value::ArrayIndex i = 0; i < resources.size(); i++) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2141 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2142 if (resources[i].type() != Json::stringValue) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2143 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2144 throw OrthancException(ErrorCode_BadFileFormat, |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2145 "The \"" + std::string(ORTHANC_RESOURCES) + |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2146 "\" field must provide an array of strings, found: " + resources[i].toStyledString()); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2147 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2148 |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2149 std::list<std::string> instances; |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2150 context.GetIndex().GetChildInstances(instances, resources[i].asString()); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2151 |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2152 for (std::list<std::string>::const_iterator |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2153 it = instances.begin(); it != instances.end(); ++it) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2154 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2155 std::string sopClassUid, sopInstanceUid; |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2156 DicomMap tags; |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2157 if (context.LookupOrReconstructMetadata(sopClassUid, *it, MetadataType_Instance_SopClassUid) && |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2158 context.GetIndex().GetAllMainDicomTags(tags, *it) && |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2159 tags.LookupStringValue(sopInstanceUid, DICOM_TAG_SOP_INSTANCE_UID, false)) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2160 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2161 sopClassUids.push_back(sopClassUid); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2162 sopInstanceUids.push_back(sopInstanceUid); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2163 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2164 else |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2165 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2166 throw OrthancException(ErrorCode_InternalError, |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2167 "Cannot retrieve SOP Class/Instance UID of Orthanc instance: " + *it); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2168 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2169 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2170 } |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2171 } |
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2172 } |
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2173 |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2174 if (json.isMember(DICOM_INSTANCES)) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2175 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2176 const Json::Value& instances = json[DICOM_INSTANCES]; |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2177 |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2178 if (instances.type() != Json::arrayValue) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2179 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2180 throw OrthancException(ErrorCode_BadFileFormat, |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2181 "The \"" + std::string(DICOM_INSTANCES) + |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2182 "\" field must provide an array of DICOM instances"); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2183 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2184 else |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2185 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2186 for (Json::Value::ArrayIndex i = 0; i < instances.size(); i++) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2187 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2188 if (instances[i].type() == Json::arrayValue) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2189 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2190 if (instances[i].size() != 2 || |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2191 instances[i][0].type() != Json::stringValue || |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2192 instances[i][1].type() != Json::stringValue) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2193 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2194 throw OrthancException(ErrorCode_BadFileFormat, |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2195 "An instance entry must provide an array with 2 strings: " |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2196 "SOP Class UID and SOP Instance UID"); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2197 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2198 else |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2199 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2200 sopClassUids.push_back(instances[i][0].asString()); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2201 sopInstanceUids.push_back(instances[i][1].asString()); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2202 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2203 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2204 else if (instances[i].type() == Json::objectValue) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2205 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2206 if (!instances[i].isMember(SOP_CLASS_UID) || |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2207 !instances[i].isMember(SOP_INSTANCE_UID) || |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2208 instances[i][SOP_CLASS_UID].type() != Json::stringValue || |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2209 instances[i][SOP_INSTANCE_UID].type() != Json::stringValue) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2210 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2211 throw OrthancException(ErrorCode_BadFileFormat, |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2212 "An instance entry must provide an object with 2 string fiels: " |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2213 "\"" + std::string(SOP_CLASS_UID) + "\" and \"" + |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2214 std::string(SOP_INSTANCE_UID)); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2215 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2216 else |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2217 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2218 sopClassUids.push_back(instances[i][SOP_CLASS_UID].asString()); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2219 sopInstanceUids.push_back(instances[i][SOP_INSTANCE_UID].asString()); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2220 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2221 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2222 else |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2223 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2224 throw OrthancException(ErrorCode_BadFileFormat, |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2225 "JSON array or object is expected to specify one " |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2226 "instance to be queried, found: " + instances[i].toStyledString()); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2227 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2228 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2229 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2230 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2231 |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2232 if (sopClassUids.size() != sopInstanceUids.size()) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2233 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2234 throw OrthancException(ErrorCode_InternalError); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2235 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2236 |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2237 const std::string transactionUid = Toolbox::GenerateDicomPrivateUniqueIdentifier(); |
3611
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2238 |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2239 if (sopClassUids.empty()) |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2240 { |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2241 LOG(WARNING) << "Issuing an outgoing storage commitment request that is empty: " << transactionUid; |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2242 } |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2243 |
3611
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2244 { |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2245 const RemoteModalityParameters remote = |
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2246 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
3611
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2247 |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2248 const std::string& remoteAet = remote.GetApplicationEntityTitle(); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2249 const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle(); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2250 |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2251 // Create a "pending" storage commitment report BEFORE the |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2252 // actual SCU call in order to avoid race conditions |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2253 context.GetStorageCommitmentReports().Store( |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2254 transactionUid, new StorageCommitmentReports::Report(remoteAet)); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2255 |
3830
447880856ce8
removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3808
diff
changeset
|
2256 DicomAssociationParameters parameters(localAet, remote); |
447880856ce8
removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3808
diff
changeset
|
2257 |
3740
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2258 std::vector<std::string> a(sopClassUids.begin(), sopClassUids.end()); |
e69c556f1913
storage commitment SCU against a list of Orthanc IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3738
diff
changeset
|
2259 std::vector<std::string> b(sopInstanceUids.begin(), sopInstanceUids.end()); |
3830
447880856ce8
removing deprecated DicomUserControl from OrthancRestModalities.cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3808
diff
changeset
|
2260 DicomAssociation::RequestStorageCommitment(parameters, transactionUid, a, b); |
3611
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2261 } |
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2262 |
3734
4fc24b69446a
triggering storage commitment scu from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
2263 Json::Value result = Json::objectValue; |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2264 result["ID"] = transactionUid; |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2265 result["Path"] = "/storage-commitment/" + transactionUid; |
3611
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2266 call.GetOutput().AnswerJson(result); |
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2267 } |
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2268 } |
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2269 |
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2270 |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2271 static void GetStorageCommitmentReport(RestApiGetCall& call) |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2272 { |
4423 | 2273 if (call.IsDocumentation()) |
2274 { | |
2275 call.GetDocumentation() | |
2276 .SetTag("Networking") | |
2277 .SetSummary("Get storage commitment report") | |
2278 .SetDescription("Get the storage commitment report whose identifier is provided in the URL: " | |
2279 "https://book.orthanc-server.com/users/storage-commitment.html#storage-commitment-scu") | |
2280 .SetAnswerField("Status", RestApiCallDocumentation::Type_String, | |
2281 "Can be `Success`, `Failure`, or `Pending` (the latter means that no report has been received yet)") | |
2282 .SetAnswerField("RemoteAET", RestApiCallDocumentation::Type_String, | |
2283 "AET of the remote DICOM modality") | |
2284 .SetAnswerField("Failures", RestApiCallDocumentation::Type_JsonListOfObjects, | |
2285 "List of failures that have been encountered during the storage commitment request") | |
2286 .SetAnswerField("Success", RestApiCallDocumentation::Type_JsonListOfObjects, | |
2287 "List of DICOM instances that have been acknowledged by the remote modality, " | |
2288 "each one is reported as a JSON object containing the `SOPClassUID` and " | |
2289 "`SOPInstanceUID` DICOM tags") | |
2290 .SetUriArgument("id", "Identifier of the storage commitment report"); | |
2291 return; | |
2292 } | |
2293 | |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2294 ServerContext& context = OrthancRestApi::GetContext(call); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2295 |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2296 const std::string& transactionUid = call.GetUriComponent("id", ""); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2297 |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2298 { |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2299 StorageCommitmentReports::Accessor accessor( |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2300 context.GetStorageCommitmentReports(), transactionUid); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2301 |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2302 if (accessor.IsValid()) |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2303 { |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2304 Json::Value json; |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2305 accessor.GetReport().Format(json); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2306 call.GetOutput().AnswerJson(json); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2307 } |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2308 else |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2309 { |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2310 throw OrthancException(ErrorCode_InexistentItem, |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2311 "No storage commitment transaction with UID: " + transactionUid); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2312 } |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2313 } |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2314 } |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2315 |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2316 |
3738
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2317 static void RemoveAfterStorageCommitment(RestApiPostCall& call) |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2318 { |
4423 | 2319 if (call.IsDocumentation()) |
2320 { | |
2321 call.GetDocumentation() | |
2322 .SetTag("Networking") | |
2323 .SetSummary("Remove after storage commitment") | |
2324 .SetDescription("Remove out of Orthanc, the DICOM instances that have been reported to have been properly " | |
2325 "received the storage commitment report whose identifier is provided in the URL. This is " | |
2326 "only possible if the `Status` of the storage commitment report is `Success`. " | |
2327 "https://book.orthanc-server.com/users/storage-commitment.html#removing-the-instances") | |
2328 .SetUriArgument("id", "Identifier of the storage commitment report"); | |
2329 return; | |
2330 } | |
2331 | |
3738
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2332 ServerContext& context = OrthancRestApi::GetContext(call); |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2333 |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2334 const std::string& transactionUid = call.GetUriComponent("id", ""); |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2335 |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2336 { |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2337 StorageCommitmentReports::Accessor accessor( |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2338 context.GetStorageCommitmentReports(), transactionUid); |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2339 |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2340 if (!accessor.IsValid()) |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2341 { |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2342 throw OrthancException(ErrorCode_InexistentItem, |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2343 "No storage commitment transaction with UID: " + transactionUid); |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2344 } |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2345 else if (accessor.GetReport().GetStatus() != StorageCommitmentReports::Report::Status_Success) |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2346 { |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2347 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2348 "Cannot remove DICOM instances after failure " |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2349 "in storage commitment transaction: " + transactionUid); |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2350 } |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2351 else |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2352 { |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2353 std::vector<std::string> sopInstanceUids; |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2354 accessor.GetReport().GetSuccessSopInstanceUids(sopInstanceUids); |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2355 |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2356 for (size_t i = 0; i < sopInstanceUids.size(); i++) |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2357 { |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2358 std::vector<std::string> orthancId; |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2359 context.GetIndex().LookupIdentifierExact( |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2360 orthancId, ResourceType_Instance, DICOM_TAG_SOP_INSTANCE_UID, sopInstanceUids[i]); |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2361 |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2362 for (size_t j = 0; j < orthancId.size(); j++) |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2363 { |
4294
0923247e69f6
log categories: rest -> http + added lua & jobs
Alain Mazy <alain@mazy.be>
parents:
4272
diff
changeset
|
2364 CLOG(INFO, HTTP) << "Storage commitment - Removing SOP instance UID / Orthanc ID: " |
4272 | 2365 << sopInstanceUids[i] << " / " << orthancId[j]; |
3738
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2366 |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2367 Json::Value tmp; |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2368 context.GetIndex().DeleteResource(tmp, orthancId[j], ResourceType_Instance); |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2369 } |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2370 } |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2371 |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2372 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2373 } |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2374 } |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2375 } |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2376 |
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2377 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2378 void OrthancRestApi::RegisterModalities() |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2379 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2380 Register("/modalities", ListModalities); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2381 Register("/modalities/{id}", ListModalityOperations); |
807
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
2382 Register("/modalities/{id}", UpdateModality); |
566a2fb3c1fb
update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
806
diff
changeset
|
2383 Register("/modalities/{id}", DeleteModality); |
1049
bd2cb95003da
C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1007
diff
changeset
|
2384 Register("/modalities/{id}/echo", DicomEcho); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2385 Register("/modalities/{id}/find-patient", DicomFindPatient); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2386 Register("/modalities/{id}/find-study", DicomFindStudy); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2387 Register("/modalities/{id}/find-series", DicomFindSeries); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2388 Register("/modalities/{id}/find-instance", DicomFindInstance); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2389 Register("/modalities/{id}/find", DicomFind); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2390 Register("/modalities/{id}/store", DicomStore); |
3808
7f083dfae62b
new REST route: /modalities/{id}/store-straight
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3740
diff
changeset
|
2391 Register("/modalities/{id}/store-straight", DicomStoreStraight); // New in 1.6.1 |
1998
9b61701c35f2
New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1997
diff
changeset
|
2392 Register("/modalities/{id}/move", DicomMove); |
4338
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
2393 Register("/modalities/{id}/configuration", GetModalityConfiguration); // New in 1.8.1 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2394 |
1368 | 2395 // For Query/Retrieve |
2396 Register("/modalities/{id}/query", DicomQuery); | |
2397 Register("/queries", ListQueries); | |
2398 Register("/queries/{id}", DeleteQuery); | |
2399 Register("/queries/{id}", ListQueryOperations); | |
2400 Register("/queries/{id}/answers", ListQueryAnswers); | |
2401 Register("/queries/{id}/answers/{index}", ListQueryAnswerOperations); | |
2402 Register("/queries/{id}/answers/{index}/content", GetQueryOneAnswer); | |
2403 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
|
2404 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
|
2405 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
|
2406 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
|
2407 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
|
2408 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
|
2409 QueryAnswerChildren<ResourceType_Study>); |
1368 | 2410 Register("/queries/{id}/level", GetQueryLevel); |
2411 Register("/queries/{id}/modality", GetQueryModality); | |
2412 Register("/queries/{id}/query", GetQueryArguments); | |
2413 Register("/queries/{id}/retrieve", RetrieveAllAnswers); | |
2414 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2415 Register("/peers", ListPeers); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2416 Register("/peers/{id}", ListPeerOperations); |
808
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2417 Register("/peers/{id}", UpdatePeer); |
2d9a000aa3a6
update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
2418 Register("/peers/{id}", DeletePeer); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2419 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
|
2420 Register("/peers/{id}/system", PeerSystem); |
4338
1263e727d048
give access to the configuration of one single peer or modality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4294
diff
changeset
|
2421 Register("/peers/{id}/configuration", GetPeerConfiguration); // New in 1.8.1 |
1819
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2422 |
84f0a118a72c
new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1787
diff
changeset
|
2423 Register("/modalities/{id}/find-worklist", DicomFindWorklist); |
3611
0ce9c1c6474f
test route in REST API for storage commitment
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3602
diff
changeset
|
2424 |
3738
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2425 // Storage commitment |
3737
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2426 Register("/modalities/{id}/storage-commitment", StorageCommitmentScu); |
f29843323daf
accessing storage commitment reports from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3734
diff
changeset
|
2427 Register("/storage-commitment/{id}", GetStorageCommitmentReport); |
3738
bff4da769f6f
new route: "/storage-commitment/{...}/remove"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3737
diff
changeset
|
2428 Register("/storage-commitment/{id}/remove", RemoveAfterStorageCommitment); |
4339
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
2429 |
fc5caed6f940
"/tools/dicom-echo": Execute C-Echo SCU to a modality that is not registered in "/modalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4338
diff
changeset
|
2430 Register("/tools/dicom-echo", DicomEchoTool); // New in 1.8.1 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2431 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2432 } |