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