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