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