annotate OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 2894:a27b0e9a3fd9 db-changes

refactoring DicomInstanceToStore
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 18 Oct 2018 10:35:09 +0200
parents 6eebc2eb3168
children ae20fccdd867
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1819
diff changeset
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
2447
878b59270859 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2441
diff changeset
5 * Copyright (C) 2017-2018 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
2602
c25f1a52acbc reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2589
diff changeset
37 #include "../../Core/DicomParsing/FromDcmtkBridge.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
38 #include "../../Core/Logging.h"
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
39 #include "../../Core/SerializationToolbox.h"
2602
c25f1a52acbc reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2589
diff changeset
40 #include "../OrthancInitialization.h"
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
41 #include "../QueryRetrieveHandler.h"
2602
c25f1a52acbc reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2589
diff changeset
42 #include "../ServerJobs/DicomModalityStoreJob.h"
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
43 #include "../ServerJobs/DicomMoveScuJob.h"
2602
c25f1a52acbc reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2589
diff changeset
44 #include "../ServerJobs/OrthancPeerStoreJob.h"
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
45 #include "../ServerToolbox.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
2573
3372c5255333 StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
47
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 namespace Orthanc
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
50 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
51 * DICOM C-Echo SCU
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
52 ***************************************************************************/
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
53
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
54 static void DicomEcho(RestApiPostCall& call)
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
55 {
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
56 ServerContext& context = OrthancRestApi::GetContext(call);
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
57
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
58 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
59 RemoteModalityParameters remote =
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
60 Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
61
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
62 try
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
63 {
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
64 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
65 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
66
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
67 if (connection.Echo())
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
68 {
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
69 // Echo has succeeded
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
70 call.GetOutput().AnswerBuffer("{}", "application/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
71 return;
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
72 }
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
73 }
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
74 catch (OrthancException&)
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
75 {
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
76 }
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
77
0561f2087cc9 Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1142
diff changeset
78 // 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
79 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
80 }
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
81
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
82
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
83
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
84 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
85 * DICOM C-Find SCU => DEPRECATED!
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
86 ***************************************************************************/
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
87
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
88 static bool MergeQueryAndTemplate(DicomMap& result,
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
89 const char* postData,
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
90 size_t postSize)
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
91 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
92 Json::Value query;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
93 Json::Reader reader;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
94
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
95 if (!reader.parse(postData, postData + postSize, query) ||
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
96 query.type() != Json::objectValue)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
97 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
98 return false;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
99 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
100
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
101 Json::Value::Members members = query.getMemberNames();
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
102 for (size_t i = 0; i < members.size(); i++)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
103 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
104 DicomTag t = FromDcmtkBridge::ParseTag(members[i]);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
105 result.SetValue(t, query[members[i]].asString(), false);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
106 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
107
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
108 return true;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
109 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
110
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
111
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
112 static void FindPatient(DicomFindAnswers& result,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
113 DicomUserConnection& connection,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
114 const DicomMap& fields)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
115 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
116 // Only keep the filters from "fields" that are related to the patient
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
117 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
118 fields.ExtractPatientInformation(s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
119 connection.Find(result, ResourceType_Patient, s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
120 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
121
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
122
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
123 static void FindStudy(DicomFindAnswers& result,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
124 DicomUserConnection& connection,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
125 const DicomMap& fields)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
126 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
127 // Only keep the filters from "fields" that are related to the study
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
128 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
129 fields.ExtractStudyInformation(s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
130
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
131 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
132 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
133 s.CopyTagIfExists(fields, DICOM_TAG_MODALITIES_IN_STUDY);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
134
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
135 connection.Find(result, ResourceType_Study, s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
136 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
137
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
138 static void FindSeries(DicomFindAnswers& result,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
139 DicomUserConnection& connection,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
140 const DicomMap& fields)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
141 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
142 // Only keep the filters from "fields" that are related to the series
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
143 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
144 fields.ExtractSeriesInformation(s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
145
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
146 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
147 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
148 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
149
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
150 connection.Find(result, ResourceType_Series, s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
151 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
152
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
153 static void FindInstance(DicomFindAnswers& result,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
154 DicomUserConnection& connection,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
155 const DicomMap& fields)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
156 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
157 // Only keep the filters from "fields" that are related to the instance
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
158 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
159 fields.ExtractInstanceInformation(s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
160
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
161 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
162 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
163 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
164 s.CopyTagIfExists(fields, DICOM_TAG_SERIES_INSTANCE_UID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
165
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
166 connection.Find(result, ResourceType_Instance, s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
167 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
168
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
169
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
170 static void DicomFindPatient(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
172 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
173 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
174
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
175 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
176 DicomMap::SetupFindPatientTemplate(fields);
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
177 if (!MergeQueryAndTemplate(fields, call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181
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
182 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
183 RemoteModalityParameters remote =
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
184 Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
185
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
186 DicomFindAnswers answers(false);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
188 {
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
189 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
190 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
191 FindPatient(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
192 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 Json::Value result;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
195 answers.ToJson(result, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
199 static void DicomFindStudy(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
201 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
202 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
203
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
204 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
205 DicomMap::SetupFindStudyTemplate(fields);
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
206 if (!MergeQueryAndTemplate(fields, call.GetBodyData(), call.GetBodySize()))
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
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
211 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
212 fields.GetValue(DICOM_TAG_PATIENT_ID).GetContent().size() <= 2)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
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
217 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
218 RemoteModalityParameters remote =
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
219 Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
220
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
221 DicomFindAnswers answers(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
222
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
223 {
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
224 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
225 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
226 FindStudy(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
227 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 Json::Value result;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
230 answers.ToJson(result, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
234 static void DicomFindSeries(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
236 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
237 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
238
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
239 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
240 DicomMap::SetupFindSeriesTemplate(fields);
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
241 if (!MergeQueryAndTemplate(fields, call.GetBodyData(), call.GetBodySize()))
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
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
246 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
247 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
248 fields.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).GetContent().size() <= 2)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252
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
253 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
254 RemoteModalityParameters remote =
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
255 Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
256
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
257 DicomFindAnswers answers(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
258
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
259 {
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
260 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
261 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
262 FindSeries(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
263 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 Json::Value result;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
266 answers.ToJson(result, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
270 static void DicomFindInstance(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
272 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
273 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
274
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
275 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
276 DicomMap::SetupFindInstanceTemplate(fields);
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
277 if (!MergeQueryAndTemplate(fields, call.GetBodyData(), call.GetBodySize()))
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
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
282 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
283 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
284 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
285 fields.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).GetContent().size() <= 2)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289
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
290 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
291 RemoteModalityParameters remote =
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
292 Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
293
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
294 DicomFindAnswers answers(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
295
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
296 {
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
297 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
298 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
299 FindInstance(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
300 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 Json::Value result;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
303 answers.ToJson(result, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
307
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
308 static void CopyTagIfExists(DicomMap& target,
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
309 ParsedDicomFile& source,
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
310 const DicomTag& tag)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
311 {
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
312 std::string tmp;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
313 if (source.GetTagValue(tmp, tag))
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
314 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
315 target.SetValue(tag, tmp, false);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
316 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
317 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
318
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
319
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
320 static void DicomFind(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
322 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
323 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
324
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 DicomMap m;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 DicomMap::SetupFindPatientTemplate(m);
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
327 if (!MergeQueryAndTemplate(m, call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 return;
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
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
332 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
333 RemoteModalityParameters remote =
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
334 Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
335
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
336 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
337 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
338
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
339 DicomFindAnswers patients(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
340 FindPatient(patients, connection, m);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 // Loop over the found patients
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 Json::Value result = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 for (size_t i = 0; i < patients.GetSize(); i++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
346 Json::Value patient;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
347 patients.ToJson(patient, i, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 DicomMap::SetupFindStudyTemplate(m);
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
350 if (!MergeQueryAndTemplate(m, call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
354
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
355 CopyTagIfExists(m, patients.GetAnswer(i), DICOM_TAG_PATIENT_ID);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
357 DicomFindAnswers studies(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
358 FindStudy(studies, connection, m);
751
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 patient["Studies"] = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 // Loop over the found studies
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 for (size_t j = 0; j < studies.GetSize(); j++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
365 Json::Value study;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
366 studies.ToJson(study, j, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 DicomMap::SetupFindSeriesTemplate(m);
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
369 if (!MergeQueryAndTemplate(m, call.GetBodyData(), call.GetBodySize()))
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 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
373
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
374 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_PATIENT_ID);
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
375 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_STUDY_INSTANCE_UID);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
377 DicomFindAnswers series(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
378 FindSeries(series, connection, m);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 // Loop over the found series
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 study["Series"] = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 for (size_t k = 0; k < series.GetSize(); k++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
384 Json::Value series2;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
385 series.ToJson(series2, k, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 study["Series"].append(series2);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 patient["Studies"].append(study);
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 result.append(patient);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
399
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
400 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
401 * DICOM C-Find and C-Move SCU => Recommended since Orthanc 0.9.0
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
402 ***************************************************************************/
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
403
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
404 static void DicomQuery(RestApiPostCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
405 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
406 ServerContext& context = OrthancRestApi::GetContext(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
407 Json::Value request;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
408
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
409 if (call.ParseJsonRequest(request) &&
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
410 request.type() == Json::objectValue &&
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
411 request.isMember("Level") && request["Level"].type() == Json::stringValue &&
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
412 (!request.isMember("Query") || request["Query"].type() == Json::objectValue))
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
413 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
414 std::auto_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context));
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
415
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
416 handler->SetModality(call.GetUriComponent("id", ""));
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
417 handler->SetLevel(StringToResourceType(request["Level"].asCString()));
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
418
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
419 if (request.isMember("Query"))
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
420 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
421 Json::Value::Members tags = request["Query"].getMemberNames();
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
422 for (size_t i = 0; i < tags.size(); i++)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
423 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
424 handler->SetQuery(FromDcmtkBridge::ParseTag(tags[i].c_str()),
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
425 request["Query"][tags[i]].asString());
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
426 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
427 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
428
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
429 handler->Run();
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
430
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
431 std::string s = context.GetQueryRetrieveArchive().Add(handler.release());
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
432 Json::Value result = Json::objectValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
433 result["ID"] = s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
434 result["Path"] = "/queries/" + s;
2843
4ee3a759afea Fix: Closing DICOM associations after running query/retrieve from REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2801
diff changeset
435 call.GetOutput().AnswerJson(result);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
436 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
437 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
438
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
439
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
440 static void ListQueries(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
441 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
442 ServerContext& context = OrthancRestApi::GetContext(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
443
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
444 std::list<std::string> queries;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
445 context.GetQueryRetrieveArchive().List(queries);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
446
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
447 Json::Value result = Json::arrayValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
448 for (std::list<std::string>::const_iterator
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
449 it = queries.begin(); it != queries.end(); ++it)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
450 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
451 result.append(*it);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
452 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
453
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
454 call.GetOutput().AnswerJson(result);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
455 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
456
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
457
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
458 namespace
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
459 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
460 class QueryAccessor
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
461 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
462 private:
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
463 ServerContext& context_;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
464 SharedArchive::Accessor accessor_;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
465 QueryRetrieveHandler& handler_;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
466
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
467 public:
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
468 QueryAccessor(RestApiCall& call) :
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
469 context_(OrthancRestApi::GetContext(call)),
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
470 accessor_(context_.GetQueryRetrieveArchive(), call.GetUriComponent("id", "")),
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
471 handler_(dynamic_cast<QueryRetrieveHandler&>(accessor_.GetItem()))
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
472 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
473 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
474
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
475 QueryRetrieveHandler& GetHandler() const
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
476 {
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
477 return handler_;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
478 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
479 };
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
480
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
481 static void AnswerDicomMap(RestApiCall& call,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
482 const DicomMap& value,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
483 bool simplify)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
484 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
485 Json::Value full = Json::objectValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
486 FromDcmtkBridge::ToJson(full, value, simplify);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
487 call.GetOutput().AnswerJson(full);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
488 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
489 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
490
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
491
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
492 static void ListQueryAnswers(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
493 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
494 QueryAccessor query(call);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
495 size_t count = query.GetHandler().GetAnswersCount();
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
496
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
497 Json::Value result = Json::arrayValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
498 for (size_t i = 0; i < count; i++)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
499 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
500 result.append(boost::lexical_cast<std::string>(i));
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
501 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
502
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
503 call.GetOutput().AnswerJson(result);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
504 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
505
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
506
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
507 static void GetQueryOneAnswer(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
508 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
509 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
510
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
511 QueryAccessor query(call);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
512
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
513 DicomMap map;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
514 query.GetHandler().GetAnswer(map, index);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
515
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
516 AnswerDicomMap(call, map, call.HasArgument("simplify"));
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
517 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
518
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
519
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
520 static void SubmitRetrieveJob(RestApiPostCall& call,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
521 bool allAnswers,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
522 size_t index)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
523 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
524 ServerContext& context = OrthancRestApi::GetContext(call);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
525
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
526 std::string targetAet;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
527
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
528 Json::Value body;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
529 if (call.ParseJsonRequest(body))
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
530 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
531 targetAet = SerializationToolbox::ReadString(body, "TargetAet");
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
532 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
533 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
534 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
535 body = Json::objectValue;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
536 call.BodyToString(targetAet);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
537 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
538
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
539 std::auto_ptr<DicomMoveScuJob> job(new DicomMoveScuJob(context));
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
540
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
541 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
542 QueryAccessor query(call);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
543 job->SetTargetAet(targetAet);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
544 job->SetLocalAet(query.GetHandler().GetLocalAet());
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
545 job->SetRemoteModality(query.GetHandler().GetRemoteModality());
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
546
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
547 LOG(WARNING) << "Driving C-Move SCU on remote modality "
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
548 << query.GetHandler().GetRemoteModality().GetApplicationEntityTitle()
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
549 << " to target modality " << targetAet;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
550
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
551 if (allAnswers)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
552 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
553 for (size_t i = 0; i < query.GetHandler().GetAnswersCount(); i++)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
554 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
555 job->AddFindAnswer(query.GetHandler(), i);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
556 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
557 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
558 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
559 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
560 job->AddFindAnswer(query.GetHandler(), index);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
561 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
562 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
563
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
564 OrthancRestApi::GetApi(call).SubmitCommandsJob
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
565 (call, job.release(), true /* synchronous by default */, body);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
566 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
567
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
568
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
569 static void RetrieveOneAnswer(RestApiPostCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
570 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
571 size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", ""));
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
572 SubmitRetrieveJob(call, false, index);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
573 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
574
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
575
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
576 static void RetrieveAllAnswers(RestApiPostCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
577 {
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
578 SubmitRetrieveJob(call, true, 0);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
579 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
580
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
581
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
582 static void GetQueryArguments(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
583 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
584 QueryAccessor query(call);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
585 AnswerDicomMap(call, query.GetHandler().GetQuery(), call.HasArgument("simplify"));
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
586 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
587
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
588
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
589 static void GetQueryLevel(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
590 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
591 QueryAccessor query(call);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
592 call.GetOutput().AnswerBuffer(EnumerationToString(query.GetHandler().GetLevel()), "text/plain");
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
593 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
594
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
595
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
596 static void GetQueryModality(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
597 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
598 QueryAccessor query(call);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
599 call.GetOutput().AnswerBuffer(query.GetHandler().GetModalitySymbolicName(), "text/plain");
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
600 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
601
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
602
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
603 static void DeleteQuery(RestApiDeleteCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
604 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
605 ServerContext& context = OrthancRestApi::GetContext(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
606 context.GetQueryRetrieveArchive().Remove(call.GetUriComponent("id", ""));
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
607 call.GetOutput().AnswerBuffer("", "text/plain");
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
608 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
609
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
610
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
611 static void ListQueryOperations(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
612 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
613 // Ensure that the query of interest does exist
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
614 QueryAccessor query(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
615
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
616 RestApi::AutoListChildren(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
617 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
618
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
619
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
620 static void ListQueryAnswerOperations(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
621 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
622 // Ensure that the query of interest does exist
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
623 QueryAccessor query(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
624
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
625 // Ensure that the answer of interest does exist
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
626 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
627
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
628 DicomMap map;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
629 query.GetHandler().GetAnswer(map, index);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
630
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
631 RestApi::AutoListChildren(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
632 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
633
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
634
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
635
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
636
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
637 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
638 * DICOM C-Store SCU
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
639 ***************************************************************************/
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
640
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
641 static bool GetInstancesToExport(Json::Value& otherArguments,
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
642 SetOfInstancesJob& job,
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 const std::string& remote,
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
644 RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645 {
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
646 otherArguments = Json::objectValue;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
649 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
650 if (Toolbox::IsSHA1(call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651 {
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
652 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
653 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
654
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655 // This is for compatibility with Orthanc <= 0.5.1.
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
656 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
657 request.append(Toolbox::StripSpaces(s));
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659 else if (!call.ParseJsonRequest(request))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
660 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661 // Bad JSON request
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
662 return false;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 if (request.isString())
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666 {
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
667 std::string item = request.asString();
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
668 request = Json::arrayValue;
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
669 request.append(item);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671
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
672 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
673 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
674 {
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
675 resources = &request;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 {
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
679 if (request.type() != Json::objectValue ||
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
680 !request.isMember("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
681 {
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
682 return false;
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
683 }
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
684
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
685 resources = &request["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
686 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
687 {
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
688 return false;
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
689 }
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
690
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
691 // Copy the remaining arguments
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
692 Json::Value::Members members = request.getMemberNames();
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
693 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++)
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
694 {
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
695 otherArguments[members[i]] = request[members[i]];
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
696 }
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
697 }
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
698
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
699 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
700 {
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
701 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
702 {
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
703 return false;
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
704 }
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
705
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
706 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
707 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
708 {
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
709 return false;
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
710 }
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
711
2685
6801f99bbc2f Configuration option "LogExportedResources" is now "false" by default
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2675
diff changeset
712 if (Configuration::GetGlobalBoolParameter("LogExportedResources", false))
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
713 {
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
714 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
715 }
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
716
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
717 context.AddChildInstances(job, stripped);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 return true;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
724 static void DicomStore(RestApiPostCall& call)
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
725 {
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
726 ServerContext& context = OrthancRestApi::GetContext(call);
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
727
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
728 std::string remote = call.GetUriComponent("id", "");
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
729
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
730 Json::Value request;
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
731 std::auto_ptr<DicomModalityStoreJob> job(new DicomModalityStoreJob(context));
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
732
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
733 if (GetInstancesToExport(request, *job, remote, call))
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
734 {
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
735 std::string localAet = Toolbox::GetJsonStringField
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
736 (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle());
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
737 std::string moveOriginatorAET = Toolbox::GetJsonStringField
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
738 (request, "MoveOriginatorAet", context.GetDefaultLocalApplicationEntityTitle());
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
739 int moveOriginatorID = Toolbox::GetJsonIntegerField
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
740 (request, "MoveOriginatorID", 0 /* By default, not a C-MOVE */);
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
741
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
742 job->SetLocalAet(localAet);
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2867
diff changeset
743 job->SetRemoteModality(Configuration::GetModalityUsingSymbolicName(remote));
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
744
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
745 if (moveOriginatorID != 0)
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
746 {
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
747 job->SetMoveOriginator(moveOriginatorAET, moveOriginatorID);
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
748 }
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
749
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2867
diff changeset
750 OrthancRestApi::GetApi(call).SubmitCommandsJob
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2867
diff changeset
751 (call, job.release(), true /* synchronous by default */, request);
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
752 }
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
753 }
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
754
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
755
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
756 /***************************************************************************
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
757 * 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
758 ***************************************************************************/
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
759
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
760 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
761 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
762 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
763
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
764 Json::Value request;
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
765
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
766 static const char* RESOURCES = "Resources";
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
767 static const char* LEVEL = "Level";
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
768
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
769 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
770 request.type() != Json::objectValue ||
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
771 !request.isMember(RESOURCES) ||
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
772 !request.isMember(LEVEL) ||
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
773 request[RESOURCES].type() != Json::arrayValue ||
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
774 request[LEVEL].type() != Json::stringValue)
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
775 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
776 throw OrthancException(ErrorCode_BadFileFormat);
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
777 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
778
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
779 ResourceType level = StringToResourceType(request["Level"].asCString());
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
780
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
781 std::string localAet = Toolbox::GetJsonStringField
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
782 (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle());
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
783 std::string targetAet = Toolbox::GetJsonStringField
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
784 (request, "TargetAet", context.GetDefaultLocalApplicationEntityTitle());
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
785
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
786 const RemoteModalityParameters source =
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
787 Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
788
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
789 DicomUserConnection connection(localAet, source);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
790 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
791
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
792 for (Json::Value::ArrayIndex i = 0; i < request[RESOURCES].size(); i++)
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
793 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
794 DicomMap resource;
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
795 FromDcmtkBridge::FromJson(resource, request[RESOURCES][i]);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
796
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
797 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
798 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
799
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
800 // Move has succeeded
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
801 call.GetOutput().AnswerBuffer("{}", "application/json");
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
802 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
803
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
804
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
805
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
806 /***************************************************************************
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
807 * Orthanc Peers => Store client
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
808 ***************************************************************************/
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810 static bool IsExistingPeer(const OrthancRestApi::SetOfStrings& peers,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 const std::string& id)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813 return peers.find(id) != peers.end();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
816 static void ListPeers(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 OrthancRestApi::SetOfStrings peers;
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
819 Configuration::GetListOfOrthancPeers(peers);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
821 if (call.HasArgument("expand"))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822 {
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
823 Json::Value result = Json::objectValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
824 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
825 it = peers.begin(); it != peers.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
826 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
827 WebServiceParameters peer;
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
828
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
829 if (Configuration::GetOrthancPeer(peer, *it))
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
830 {
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
831 Json::Value jsonPeer = Json::objectValue;
2871
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
832 // only return the minimum information to identify the
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
833 // destination, do not include "security" information like
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
834 // passwords
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
835 jsonPeer["Url"] = peer.GetUrl();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
836 if (!peer.GetUsername().empty())
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
837 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
838 jsonPeer["Username"] = peer.GetUsername();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
839 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
840 result[*it] = jsonPeer;
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
841 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
842 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
843 call.GetOutput().AnswerJson(result);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 }
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
845 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
846 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
847 Json::Value result = Json::arrayValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
848 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
849 it = peers.begin(); it != peers.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
850 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
851 result.append(*it);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
852 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
854 call.GetOutput().AnswerJson(result);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
855 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
858 static void ListPeerOperations(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860 OrthancRestApi::SetOfStrings peers;
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
861 Configuration::GetListOfOrthancPeers(peers);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
863 std::string id = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
864 if (IsExistingPeer(peers, id))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865 {
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
866 RestApi::AutoListChildren(call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
868 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
869
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
870 static void PeerStore(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
871 {
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
874 std::string remote = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875
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
876 Json::Value request;
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
877 std::auto_ptr<OrthancPeerStoreJob> job(new OrthancPeerStoreJob(context));
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
879 if (GetInstancesToExport(request, *job, remote, call))
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
880 {
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
881 WebServiceParameters peer;
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
882 if (Configuration::GetOrthancPeer(peer, remote))
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
883 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
884 job->SetPeer(peer);
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2867
diff changeset
885 OrthancRestApi::GetApi(call).SubmitCommandsJob
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2867
diff changeset
886 (call, job.release(), true /* synchronous by default */, request);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
887 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
888 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
889 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
890 LOG(ERROR) << "No peer with symbolic name: " << remote;
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
891 throw OrthancException(ErrorCode_UnknownResource);
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
892 }
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
893 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 // DICOM bridge -------------------------------------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899 static bool IsExistingModality(const OrthancRestApi::SetOfStrings& modalities,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 const std::string& id)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
902 return modalities.find(id) != modalities.end();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
903 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
904
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
905 static void ListModalities(RestApiGetCall& call)
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 OrthancRestApi::SetOfStrings modalities;
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
908 Configuration::GetListOfDicomModalities(modalities);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
909
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
910 if (call.HasArgument("expand"))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911 {
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
912 Json::Value result = Json::objectValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
913 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
914 it = modalities.begin(); it != modalities.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
915 {
2871
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
916 const RemoteModalityParameters& remote = Configuration::GetModalityUsingSymbolicName(*it);
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
917
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
918 Json::Value info;
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
919 remote.Serialize(info, true /* force advanced format */);
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
920 result[*it] = info;
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
921 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
922 call.GetOutput().AnswerJson(result);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
923 }
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
924 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
925 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
926 Json::Value result = Json::arrayValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
927 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
928 it = modalities.begin(); it != modalities.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
929 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
930 result.append(*it);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
931 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
932 call.GetOutput().AnswerJson(result);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
933 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
937 static void ListModalityOperations(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
938 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
939 OrthancRestApi::SetOfStrings modalities;
810
401a9633e492 configuration into a namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 808
diff changeset
940 Configuration::GetListOfDicomModalities(modalities);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942 std::string id = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943 if (IsExistingModality(modalities, id))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944 {
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
945 RestApi::AutoListChildren(call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
948
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
950 static void UpdateModality(RestApiPutCall& call)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
951 {
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
952 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
953
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
954 Json::Value json;
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
955 Json::Reader reader;
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
956 if (reader.parse(call.GetBodyData(), call.GetBodyData() + call.GetBodySize(), json))
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
957 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
958 RemoteModalityParameters modality;
2871
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
959 modality.Unserialize(json);
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
960 Configuration::UpdateModality(context, call.GetUriComponent("id", ""), modality);
813
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 812
diff changeset
961 call.GetOutput().AnswerBuffer("", "text/plain");
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
962 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
963 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
964
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
965
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
966 static void DeleteModality(RestApiDeleteCall& call)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
967 {
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
968 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
969
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
970 Configuration::RemoveModality(context, call.GetUriComponent("id", ""));
813
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 812
diff changeset
971 call.GetOutput().AnswerBuffer("", "text/plain");
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
972 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
973
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
974
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
975 static void UpdatePeer(RestApiPutCall& call)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
976 {
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
977 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
978
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
979 Json::Value json;
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
980 Json::Reader reader;
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
981 if (reader.parse(call.GetBodyData(), call.GetBodyData() + call.GetBodySize(), json))
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
982 {
2020
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
983 WebServiceParameters peer;
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
984 peer.Unserialize(json);
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
985 Configuration::UpdatePeer(context, call.GetUriComponent("id", ""), peer);
813
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 812
diff changeset
986 call.GetOutput().AnswerBuffer("", "text/plain");
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
987 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
988 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
989
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
990
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
991 static void DeletePeer(RestApiDeleteCall& call)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
992 {
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
993 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
994
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
995 Configuration::RemovePeer(context, call.GetUriComponent("id", ""));
813
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 812
diff changeset
996 call.GetOutput().AnswerBuffer("", "text/plain");
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
997 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
998
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
999
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1000 static void DicomFindWorklist(RestApiPostCall& call)
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1001 {
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1002 ServerContext& context = OrthancRestApi::GetContext(call);
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1003
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1004 Json::Value json;
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1005 if (call.ParseJsonRequest(json))
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1006 {
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1007 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
1008 RemoteModalityParameters remote =
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1009 Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1010
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1011 std::auto_ptr<ParsedDicomFile> query(ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0)));
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1012
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
1013 DicomFindAnswers answers(true);
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1014
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1015 {
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1016 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1017 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1018 connection.FindWorklist(answers, *query);
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1019 }
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1020
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1021 Json::Value result;
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1022 answers.ToJson(result, true);
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1023 call.GetOutput().AnswerJson(result);
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1024 }
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1025 }
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1026
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1027
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028 void OrthancRestApi::RegisterModalities()
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1029 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1030 Register("/modalities", ListModalities);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1031 Register("/modalities/{id}", ListModalityOperations);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1032 Register("/modalities/{id}", UpdateModality);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1033 Register("/modalities/{id}", DeleteModality);
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
1034 Register("/modalities/{id}/echo", DicomEcho);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1035 Register("/modalities/{id}/find-patient", DicomFindPatient);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 Register("/modalities/{id}/find-study", DicomFindStudy);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037 Register("/modalities/{id}/find-series", DicomFindSeries);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038 Register("/modalities/{id}/find-instance", DicomFindInstance);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039 Register("/modalities/{id}/find", DicomFind);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040 Register("/modalities/{id}/store", DicomStore);
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
1041 Register("/modalities/{id}/move", DicomMove);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1042
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1043 // For Query/Retrieve
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1044 Register("/modalities/{id}/query", DicomQuery);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1045 Register("/queries", ListQueries);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1046 Register("/queries/{id}", DeleteQuery);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1047 Register("/queries/{id}", ListQueryOperations);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1048 Register("/queries/{id}/answers", ListQueryAnswers);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1049 Register("/queries/{id}/answers/{index}", ListQueryAnswerOperations);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1050 Register("/queries/{id}/answers/{index}/content", GetQueryOneAnswer);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1051 Register("/queries/{id}/answers/{index}/retrieve", RetrieveOneAnswer);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1052 Register("/queries/{id}/level", GetQueryLevel);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1053 Register("/queries/{id}/modality", GetQueryModality);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1054 Register("/queries/{id}/query", GetQueryArguments);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1055 Register("/queries/{id}/retrieve", RetrieveAllAnswers);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1056
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1057 Register("/peers", ListPeers);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1058 Register("/peers/{id}", ListPeerOperations);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1059 Register("/peers/{id}", UpdatePeer);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1060 Register("/peers/{id}", DeletePeer);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061 Register("/peers/{id}/store", PeerStore);
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1062
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1063 Register("/modalities/{id}/find-worklist", DicomFindWorklist);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 }