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