annotate OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 3097:ac72032d69a2 db-changes

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 05 Jan 2019 18:51:36 +0100
parents d9eb978a1039
children 860aed8258c3
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
3060
4e43e67f8ecf preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2988
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
831
84513f2ee1f3 pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
34 #include "../PrecompiledHeadersServer.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "OrthancRestApi.h"
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
37 #include "../../Core/Cache/SharedArchive.h"
2602
c25f1a52acbc reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2589
diff changeset
38 #include "../../Core/DicomParsing/FromDcmtkBridge.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1446
diff changeset
39 #include "../../Core/Logging.h"
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
40 #include "../../Core/SerializationToolbox.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
41
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
42 #include "../OrthancConfiguration.h"
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
43 #include "../QueryRetrieveHandler.h"
3097
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3096
diff changeset
44 #include "../ServerContext.h"
2602
c25f1a52acbc reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2589
diff changeset
45 #include "../ServerJobs/DicomModalityStoreJob.h"
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
46 #include "../ServerJobs/DicomMoveScuJob.h"
2602
c25f1a52acbc reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2589
diff changeset
47 #include "../ServerJobs/OrthancPeerStoreJob.h"
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
48 #include "../ServerToolbox.h"
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
2573
3372c5255333 StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
50
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 namespace Orthanc
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
53 static const char* const KEY_LEVEL = "Level";
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
54 static const char* const KEY_QUERY = "Query";
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
55 static const char* const KEY_RESOURCES = "Resources";
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
56
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
57
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
58 static RemoteModalityParameters MyGetModalityUsingSymbolicName(const std::string& name)
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
59 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
60 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
61 return lock.GetConfiguration().GetModalityUsingSymbolicName(name);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
62 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
63
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
64
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
65 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
66 * DICOM C-Echo SCU
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
67 ***************************************************************************/
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
68
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
69 static void DicomEcho(RestApiPostCall& call)
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
70 {
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
71 ServerContext& context = OrthancRestApi::GetContext(call);
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
72
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
73 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
74 RemoteModalityParameters remote =
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
75 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
76
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
77 try
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
78 {
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
79 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
80 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
81
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
82 if (connection.Echo())
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
83 {
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
84 // Echo has succeeded
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
85 call.GetOutput().AnswerBuffer("{}", MimeType_Json);
1165
0561f2087cc9 Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1142
diff changeset
86 return;
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
87 }
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
88 }
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
89 catch (OrthancException&)
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
90 {
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
91 }
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
92
0561f2087cc9 Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1142
diff changeset
93 // 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
94 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
95 }
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
96
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
97
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
98
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 * DICOM C-Find SCU => DEPRECATED!
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
101 ***************************************************************************/
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
102
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
103 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
104 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
105 size_t postSize)
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 Json::Value query;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
108 Json::Reader reader;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
109
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
110 if (!reader.parse(postData, postData + postSize, query) ||
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
111 query.type() != Json::objectValue)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
112 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
113 return false;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
114 }
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 Json::Value::Members members = query.getMemberNames();
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
117 for (size_t i = 0; i < members.size(); i++)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
118 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
119 DicomTag t = FromDcmtkBridge::ParseTag(members[i]);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
120 result.SetValue(t, query[members[i]].asString(), false);
1368
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 return true;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
124 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
125
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 static void FindPatient(DicomFindAnswers& result,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
128 DicomUserConnection& connection,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
129 const DicomMap& fields)
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 // 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
132 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
133 fields.ExtractPatientInformation(s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
134 connection.Find(result, ResourceType_Patient, s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
135 }
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 FindStudy(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 study
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.ExtractStudyInformation(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_MODALITIES_IN_STUDY);
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_Study, 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 FindSeries(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 series
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.ExtractSeriesInformation(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
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
165 connection.Find(result, ResourceType_Series, s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
166 }
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 static void FindInstance(DicomFindAnswers& result,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
169 DicomUserConnection& connection,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
170 const DicomMap& fields)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
171 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
172 // 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
173 DicomMap s;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
174 fields.ExtractInstanceInformation(s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
175
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
176 s.CopyTagIfExists(fields, DICOM_TAG_PATIENT_ID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
177 s.CopyTagIfExists(fields, DICOM_TAG_ACCESSION_NUMBER);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
178 s.CopyTagIfExists(fields, DICOM_TAG_STUDY_INSTANCE_UID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
179 s.CopyTagIfExists(fields, DICOM_TAG_SERIES_INSTANCE_UID);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
180
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
181 connection.Find(result, ResourceType_Instance, s);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
182 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
183
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
184
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
185 static void DicomFindPatient(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
187 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
188 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
189
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
190 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
191 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
192 if (!MergeQueryAndTemplate(fields, call.GetBodyData(), call.GetBodySize()))
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 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
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
197 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
198 RemoteModalityParameters remote =
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
199 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
200
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
201 DicomFindAnswers answers(false);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
203 {
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
204 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
205 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
206 FindPatient(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
207 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 Json::Value result;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
210 answers.ToJson(result, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
214 static void DicomFindStudy(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
216 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
217 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
218
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
219 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
220 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
221 if (!MergeQueryAndTemplate(fields, call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
226 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
227 fields.GetValue(DICOM_TAG_PATIENT_ID).GetContent().size() <= 2)
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 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
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
232 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
233 RemoteModalityParameters remote =
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
234 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
235
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
236 DicomFindAnswers answers(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
237
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
238 {
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
239 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
240 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
241 FindStudy(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
242 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 Json::Value result;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
245 answers.ToJson(result, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
249 static void DicomFindSeries(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
251 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
252 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
253
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
254 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
255 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
256 if (!MergeQueryAndTemplate(fields, call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
261 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
262 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
263 fields.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).GetContent().size() <= 2)
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 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267
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
268 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
269 RemoteModalityParameters remote =
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
270 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
271
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
272 DicomFindAnswers answers(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
273
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
274 {
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
275 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
276 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
277 FindSeries(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
278 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 Json::Value result;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
281 answers.ToJson(result, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
285 static void DicomFindInstance(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
287 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
288 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
289
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
290 DicomMap fields;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
291 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
292 if (!MergeQueryAndTemplate(fields, call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296
1737
ec66a16aa398 removal of DicomStringValue and DicomNullValue
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
297 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
298 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
299 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
300 fields.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).GetContent().size() <= 2)
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 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304
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
305 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
306 RemoteModalityParameters remote =
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
307 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
308
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
309 DicomFindAnswers answers(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
310
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
311 {
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
312 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
313 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
314 FindInstance(answers, connection, fields);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
315 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 Json::Value result;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
318 answers.ToJson(result, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 }
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
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
323 static void CopyTagIfExists(DicomMap& target,
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
324 ParsedDicomFile& source,
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
325 const DicomTag& tag)
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
326 {
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
327 std::string tmp;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
328 if (source.GetTagValue(tmp, tag))
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
329 {
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1998
diff changeset
330 target.SetValue(tag, tmp, false);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
331 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
332 }
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
333
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
334
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
335 static void DicomFind(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 {
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
337 LOG(WARNING) << "This URI is deprecated: " << call.FlattenUri();
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
338 ServerContext& context = OrthancRestApi::GetContext(call);
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
339
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 DicomMap m;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 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
342 if (!MergeQueryAndTemplate(m, call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346
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
347 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
348 RemoteModalityParameters remote =
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
349 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
773
3bd0589af992 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 751
diff changeset
350
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
351 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
352 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
353
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
354 DicomFindAnswers patients(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
355 FindPatient(patients, connection, m);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 // Loop over the found patients
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 Json::Value result = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 for (size_t i = 0; i < patients.GetSize(); i++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
361 Json::Value patient;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
362 patients.ToJson(patient, i, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 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
365 if (!MergeQueryAndTemplate(m, call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
369
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
370 CopyTagIfExists(m, patients.GetAnswer(i), DICOM_TAG_PATIENT_ID);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
372 DicomFindAnswers studies(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
373 FindStudy(studies, connection, m);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 patient["Studies"] = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 // Loop over the found studies
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 for (size_t j = 0; j < studies.GetSize(); j++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
380 Json::Value study;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
381 studies.ToJson(study, j, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 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
384 if (!MergeQueryAndTemplate(m, call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 return;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 }
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
388
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
389 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_PATIENT_ID);
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
390 CopyTagIfExists(m, studies.GetAnswer(j), DICOM_TAG_STUDY_INSTANCE_UID);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
392 DicomFindAnswers series(false);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
393 FindSeries(series, connection, m);
751
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 // Loop over the found series
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 study["Series"] = Json::arrayValue;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 for (size_t k = 0; k < series.GetSize(); k++)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 {
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
399 Json::Value series2;
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
400 series.ToJson(series2, k, true);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 study["Series"].append(series2);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 patient["Studies"].append(study);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 result.append(patient);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 call.GetOutput().AnswerJson(result);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
414
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 * 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
417 ***************************************************************************/
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
418
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
419 static void AnswerQueryHandler(RestApiPostCall& call,
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
420 std::auto_ptr<QueryRetrieveHandler>& handler)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
421 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
422 ServerContext& context = OrthancRestApi::GetContext(call);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
423
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
424 if (handler.get() == NULL)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
425 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
426 throw OrthancException(ErrorCode_NullPointer);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
427 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
428
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
429 handler->Run();
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
430
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
431 std::string s = context.GetQueryRetrieveArchive().Add(handler.release());
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
432 Json::Value result = Json::objectValue;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
433 result["ID"] = s;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
434 result["Path"] = "/queries/" + s;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
435
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
436 call.GetOutput().AnswerJson(result);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
437 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
438
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
439
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
440 static void DicomQuery(RestApiPostCall& 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 Json::Value request;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
444
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
445 if (call.ParseJsonRequest(request) &&
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
446 request.type() == Json::objectValue &&
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
447 request.isMember(KEY_LEVEL) && request[KEY_LEVEL].type() == Json::stringValue &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
448 (!request.isMember(KEY_QUERY) || request[KEY_QUERY].type() == Json::objectValue))
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
449 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
450 std::auto_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context));
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
451
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
452 handler->SetModality(call.GetUriComponent("id", ""));
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
453 handler->SetLevel(StringToResourceType(request[KEY_LEVEL].asCString()));
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
454
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
455 if (request.isMember(KEY_QUERY))
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
456 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
457 std::map<DicomTag, std::string> query;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
458 SerializationToolbox::ReadMapOfTags(query, request, KEY_QUERY);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
459
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
460 for (std::map<DicomTag, std::string>::const_iterator
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
461 it = query.begin(); it != query.end(); ++it)
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
462 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
463 handler->SetQuery(it->first, it->second);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
464 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
465 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
466
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
467 AnswerQueryHandler(call, handler);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
468 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
469 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
470
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
471
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
472 static void ListQueries(RestApiGetCall& call)
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 ServerContext& context = OrthancRestApi::GetContext(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
475
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
476 std::list<std::string> queries;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
477 context.GetQueryRetrieveArchive().List(queries);
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 Json::Value result = Json::arrayValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
480 for (std::list<std::string>::const_iterator
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
481 it = queries.begin(); it != queries.end(); ++it)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
482 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
483 result.append(*it);
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
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
486 call.GetOutput().AnswerJson(result);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
487 }
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 namespace
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 class QueryAccessor
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 private:
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
495 ServerContext& context_;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
496 SharedArchive::Accessor accessor_;
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
497 QueryRetrieveHandler* handler_;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
498
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
499 public:
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
500 QueryAccessor(RestApiCall& call) :
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
501 context_(OrthancRestApi::GetContext(call)),
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
502 accessor_(context_.GetQueryRetrieveArchive(), call.GetUriComponent("id", "")),
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
503 handler_(NULL)
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
504 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
505 if (accessor_.IsValid())
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
506 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
507 handler_ = &dynamic_cast<QueryRetrieveHandler&>(accessor_.GetItem());
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
508 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
509 else
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
510 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
511 throw OrthancException(ErrorCode_UnknownResource);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
512 }
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
513 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
514
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
515 QueryRetrieveHandler& GetHandler() const
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
516 {
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
517 assert(handler_ != NULL);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
518 return *handler_;
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
519 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
520 };
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
521
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
522 static void AnswerDicomMap(RestApiCall& call,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
523 const DicomMap& value,
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
524 bool simplify)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
525 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
526 Json::Value full = Json::objectValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
527 FromDcmtkBridge::ToJson(full, value, simplify);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
528 call.GetOutput().AnswerJson(full);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
529 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
530 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
531
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
532
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
533 static void ListQueryAnswers(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
534 {
2948
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
535 const bool expand = call.HasArgument("expand");
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
536 const bool simplify = call.HasArgument("simplify");
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
537
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
538 QueryAccessor query(call);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
539 size_t count = query.GetHandler().GetAnswersCount();
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
540
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
541 Json::Value result = Json::arrayValue;
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
542 for (size_t i = 0; i < count; i++)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
543 {
2948
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
544 if (expand)
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
545 {
2988
9cc3d40e389b Orthanc 1.4.3 is now known as 1.5.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2986
diff changeset
546 // New in Orthanc 1.5.0
2948
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
547 DicomMap value;
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
548 query.GetHandler().GetAnswer(value, i);
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
549
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
550 Json::Value json = Json::objectValue;
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
551 FromDcmtkBridge::ToJson(json, value, simplify);
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
552
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
553 result.append(json);
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
554 }
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
555 else
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
556 {
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
557 result.append(boost::lexical_cast<std::string>(i));
d2e548e643af New options to URI "/queries/.../answers": "?expand" and "?limit"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2944
diff changeset
558 }
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
559 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
560
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
561 call.GetOutput().AnswerJson(result);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
562 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
563
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
564
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
565 static void GetQueryOneAnswer(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
566 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
567 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
568
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
569 QueryAccessor query(call);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
570
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
571 DicomMap map;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
572 query.GetHandler().GetAnswer(map, index);
1787
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
573
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
574 AnswerDicomMap(call, map, call.HasArgument("simplify"));
1368
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
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 static void SubmitRetrieveJob(RestApiPostCall& call,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
579 bool allAnswers,
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
580 size_t index)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
581 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
582 ServerContext& context = OrthancRestApi::GetContext(call);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
583
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
584 std::string targetAet;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
585
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
586 Json::Value body;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
587 if (call.ParseJsonRequest(body))
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
588 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
589 targetAet = SerializationToolbox::ReadString(body, "TargetAet");
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
590 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
591 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
592 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
593 body = Json::objectValue;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
594 call.BodyToString(targetAet);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
595 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
596
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
597 std::auto_ptr<DicomMoveScuJob> job(new DicomMoveScuJob(context));
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
598
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
599 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
600 QueryAccessor query(call);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
601 job->SetTargetAet(targetAet);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
602 job->SetLocalAet(query.GetHandler().GetLocalAet());
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
603 job->SetRemoteModality(query.GetHandler().GetRemoteModality());
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
604
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
605 LOG(WARNING) << "Driving C-Move SCU on remote modality "
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
606 << query.GetHandler().GetRemoteModality().GetApplicationEntityTitle()
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
607 << " to target modality " << targetAet;
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
608
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
609 if (allAnswers)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
610 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
611 for (size_t i = 0; i < query.GetHandler().GetAnswersCount(); i++)
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
612 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
613 job->AddFindAnswer(query.GetHandler(), i);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
614 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
615 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
616 else
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
617 {
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
618 job->AddFindAnswer(query.GetHandler(), index);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
619 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
620 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
621
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
622 OrthancRestApi::GetApi(call).SubmitCommandsJob
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
623 (call, job.release(), true /* synchronous by default */, body);
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
624 }
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
625
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
626
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
627 static void RetrieveOneAnswer(RestApiPostCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
628 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
629 size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", ""));
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
630 SubmitRetrieveJob(call, false, index);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
631 }
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 static void RetrieveAllAnswers(RestApiPostCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
635 {
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
636 SubmitRetrieveJob(call, true, 0);
1368
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
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 static void GetQueryArguments(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
641 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
642 QueryAccessor query(call);
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
643 AnswerDicomMap(call, query.GetHandler().GetQuery(), call.HasArgument("simplify"));
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
644 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
645
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
646
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
647 static void GetQueryLevel(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
648 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
649 QueryAccessor query(call);
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
650 call.GetOutput().AnswerBuffer(EnumerationToString(query.GetHandler().GetLevel()), MimeType_PlainText);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
651 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
652
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
653
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
654 static void GetQueryModality(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
655 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
656 QueryAccessor query(call);
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
657 call.GetOutput().AnswerBuffer(query.GetHandler().GetModalitySymbolicName(), MimeType_PlainText);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
658 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
659
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
660
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
661 static void DeleteQuery(RestApiDeleteCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
662 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
663 ServerContext& context = OrthancRestApi::GetContext(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
664 context.GetQueryRetrieveArchive().Remove(call.GetUriComponent("id", ""));
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
665 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
666 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
667
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
668
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
669 static void ListQueryOperations(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
670 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
671 // Ensure that the query of interest does exist
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
672 QueryAccessor query(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
673
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
674 RestApi::AutoListChildren(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
675 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
676
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
677
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
678 static void ListQueryAnswerOperations(RestApiGetCall& call)
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
679 {
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
680 // Ensure that the query of interest does exist
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
681 QueryAccessor query(call);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
682
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
683 // Ensure that the answer of interest does exist
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
684 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
685
1b1d5470233f refactoring of DicomFindAnswers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1737
diff changeset
686 DicomMap map;
2867
251614c2edac DicomMoveScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2843
diff changeset
687 query.GetHandler().GetAnswer(map, index);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
688
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
689 Json::Value answer = Json::arrayValue;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
690 answer.append("content");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
691 answer.append("retrieve");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
692
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
693 switch (query.GetHandler().GetLevel())
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
694 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
695 case ResourceType_Patient:
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
696 answer.append("query-study");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
697
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
698 case ResourceType_Study:
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
699 answer.append("query-series");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
700
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
701 case ResourceType_Series:
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
702 answer.append("query-instances");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
703 break;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
704
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
705 default:
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
706 break;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
707 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
708
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
709 call.GetOutput().AnswerJson(answer);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
710 }
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
711
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
712
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
713 template <ResourceType CHILDREN_LEVEL>
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
714 static void QueryAnswerChildren(RestApiPostCall& call)
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
715 {
2988
9cc3d40e389b Orthanc 1.4.3 is now known as 1.5.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2986
diff changeset
716 // New in Orthanc 1.5.0
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
717 assert(CHILDREN_LEVEL == ResourceType_Study ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
718 CHILDREN_LEVEL == ResourceType_Series ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
719 CHILDREN_LEVEL == ResourceType_Instance);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
720
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
721 ServerContext& context = OrthancRestApi::GetContext(call);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
722
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
723 std::auto_ptr<QueryRetrieveHandler> handler(new QueryRetrieveHandler(context));
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
724
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
725 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
726 const QueryAccessor parent(call);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
727 const ResourceType level = parent.GetHandler().GetLevel();
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
728
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
729 const size_t index = boost::lexical_cast<size_t>(call.GetUriComponent("index", ""));
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
730
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
731 Json::Value request;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
732
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
733 if (index >= parent.GetHandler().GetAnswersCount())
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
734 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
735 throw OrthancException(ErrorCode_ParameterOutOfRange);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
736 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
737 else if (CHILDREN_LEVEL == ResourceType_Study &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
738 level != ResourceType_Patient)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
739 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
740 throw OrthancException(ErrorCode_UnknownResource);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
741 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
742 else if (CHILDREN_LEVEL == ResourceType_Series &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
743 level != ResourceType_Patient &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
744 level != ResourceType_Study)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
745 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
746 throw OrthancException(ErrorCode_UnknownResource);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
747 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
748 else if (CHILDREN_LEVEL == ResourceType_Instance &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
749 level != ResourceType_Patient &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
750 level != ResourceType_Study &&
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
751 level != ResourceType_Series)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
752 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
753 throw OrthancException(ErrorCode_UnknownResource);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
754 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
755 else if (!call.ParseJsonRequest(request))
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
756 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
757 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object");
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
758 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
759 else
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
760 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
761 handler->SetModality(parent.GetHandler().GetModalitySymbolicName());
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
762 handler->SetLevel(CHILDREN_LEVEL);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
763
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
764 if (request.isMember(KEY_QUERY))
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
765 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
766 std::map<DicomTag, std::string> query;
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
767 SerializationToolbox::ReadMapOfTags(query, request, KEY_QUERY);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
768
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
769 for (std::map<DicomTag, std::string>::const_iterator
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
770 it = query.begin(); it != query.end(); ++it)
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
771 {
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
772 handler->SetQuery(it->first, it->second);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
773 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
774 }
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
775
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
776 DicomMap answer;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
777 parent.GetHandler().GetAnswer(answer, index);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
778
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
779 // This switch-case mimics "DicomUserConnection::Move()"
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
780 switch (parent.GetHandler().GetLevel())
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
781 {
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
782 case ResourceType_Patient:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
783 handler->CopyStringTag(answer, DICOM_TAG_PATIENT_ID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
784 break;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
785
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
786 case ResourceType_Study:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
787 handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
788 break;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
789
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
790 case ResourceType_Series:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
791 handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
792 handler->CopyStringTag(answer, DICOM_TAG_SERIES_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
793 break;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
794
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
795 case ResourceType_Instance:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
796 handler->CopyStringTag(answer, DICOM_TAG_STUDY_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
797 handler->CopyStringTag(answer, DICOM_TAG_SERIES_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
798 handler->CopyStringTag(answer, DICOM_TAG_SOP_INSTANCE_UID);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
799 break;
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
800
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
801 default:
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
802 throw OrthancException(ErrorCode_InternalError);
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
803 }
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
804 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
805 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
806
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
807 AnswerQueryHandler(call, handler);
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
808 }
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
809
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
810
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
811
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
812 /***************************************************************************
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
813 * DICOM C-Store SCU
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
814 ***************************************************************************/
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
815
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
816 static bool GetInstancesToExport(Json::Value& otherArguments,
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
817 SetOfInstancesJob& job,
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 const std::string& remote,
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
819 RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820 {
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
821 otherArguments = Json::objectValue;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
824 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
825 if (Toolbox::IsSHA1(call.GetBodyData(), call.GetBodySize()))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
826 {
1446
8dc80ba768aa refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1428
diff changeset
827 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
828 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
829
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 // This is for compatibility with Orthanc <= 0.5.1.
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
831 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
832 request.append(Toolbox::StripSpaces(s));
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834 else if (!call.ParseJsonRequest(request))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 // Bad JSON request
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
837 return false;
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
838 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
839
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840 if (request.isString())
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 {
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
842 std::string item = request.asString();
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
843 request = Json::arrayValue;
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
844 request.append(item);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846
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
847 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
848 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
849 {
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
850 resources = &request;
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852 else
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853 {
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
854 if (request.type() != Json::objectValue ||
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
855 !request.isMember(KEY_RESOURCES))
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
856 {
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
857 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
858 }
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
859
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
860 resources = &request[KEY_RESOURCES];
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
861 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
862 {
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
863 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
864 }
1428
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
865
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
866 // Copy the remaining arguments
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
867 Json::Value::Members members = request.getMemberNames();
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
868 for (Json::Value::ArrayIndex i = 0; i < members.size(); i++)
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
869 {
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
870 otherArguments[members[i]] = request[members[i]];
0a355eeeb351 optimization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1427
diff changeset
871 }
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
872 }
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
873
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
874 bool logExportedResources;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
875
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
876 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
877 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
878 logExportedResources = lock.GetConfiguration().GetBooleanParameter("LogExportedResources", false);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
879 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
880
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
881 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
882 {
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
883 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
884 {
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
885 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
886 }
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
887
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
888 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
889 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
890 {
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
891 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
892 }
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
893
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
894 if (logExportedResources)
1427
d710ea64f0fd Custom setting of the local AET during C-Store SCU (both in Lua and in the REST API)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1368
diff changeset
895 {
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
896 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
897 }
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
898
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
899 context.AddChildInstances(job, stripped);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 }
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 true;
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
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
906 static void DicomStore(RestApiPostCall& call)
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
907 {
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
908 ServerContext& context = OrthancRestApi::GetContext(call);
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
909
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
910 std::string remote = call.GetUriComponent("id", "");
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
911
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
912 Json::Value request;
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
913 std::auto_ptr<DicomModalityStoreJob> job(new DicomModalityStoreJob(context));
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
914
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
915 if (GetInstancesToExport(request, *job, remote, call))
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
916 {
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
917 std::string localAet = Toolbox::GetJsonStringField
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
918 (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle());
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
919 std::string moveOriginatorAET = Toolbox::GetJsonStringField
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
920 (request, "MoveOriginatorAet", context.GetDefaultLocalApplicationEntityTitle());
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
921 int moveOriginatorID = Toolbox::GetJsonIntegerField
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
922 (request, "MoveOriginatorID", 0 /* By default, not a C-MOVE */);
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
923
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
924 job->SetLocalAet(localAet);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
925 job->SetRemoteModality(MyGetModalityUsingSymbolicName(remote));
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
926
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
927 if (moveOriginatorID != 0)
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
928 {
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
929 job->SetMoveOriginator(moveOriginatorAET, moveOriginatorID);
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
930 }
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
931
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2867
diff changeset
932 OrthancRestApi::GetApi(call).SubmitCommandsJob
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2867
diff changeset
933 (call, job.release(), true /* synchronous by default */, request);
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
934 }
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
935 }
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
936
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
937
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
938 /***************************************************************************
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
939 * 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
940 ***************************************************************************/
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
941
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
942 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
943 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
944 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
945
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
946 Json::Value request;
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
947
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
948 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
949 request.type() != Json::objectValue ||
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
950 !request.isMember(KEY_RESOURCES) ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
951 !request.isMember(KEY_LEVEL) ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
952 request[KEY_RESOURCES].type() != Json::arrayValue ||
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
953 request[KEY_LEVEL].type() != Json::stringValue)
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
954 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
955 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
956 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
957
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
958 ResourceType level = StringToResourceType(request[KEY_LEVEL].asCString());
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
959
2584
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
960 std::string localAet = Toolbox::GetJsonStringField
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
961 (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle());
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
962 std::string targetAet = Toolbox::GetJsonStringField
38b5045f2bff refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2583
diff changeset
963 (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
964
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
965 const RemoteModalityParameters source =
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
966 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
967
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
968 DicomUserConnection connection(localAet, source);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
969 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
970
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
971 for (Json::Value::ArrayIndex i = 0; i < request[KEY_RESOURCES].size(); i++)
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
972 {
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
973 DicomMap resource;
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
974 FromDcmtkBridge::FromJson(resource, request[KEY_RESOURCES][i]);
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
975
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
976 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
977 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
978
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
979 // Move has succeeded
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
980 call.GetOutput().AnswerBuffer("{}", MimeType_Json);
1998
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
981 }
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
982
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
983
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
984
9b61701c35f2 New URI "/modalities/.../move" to issue C-Move SCU requests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1997
diff changeset
985 /***************************************************************************
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
986 * Orthanc Peers => Store client
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
987 ***************************************************************************/
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
988
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
989 static bool IsExistingPeer(const OrthancRestApi::SetOfStrings& peers,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
990 const std::string& id)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
991 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
992 return peers.find(id) != peers.end();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
993 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
994
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
995 static void ListPeers(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
996 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
997 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
998
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
999 OrthancRestApi::SetOfStrings peers;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1000 lock.GetConfiguration().GetListOfOrthancPeers(peers);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1001
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1002 if (call.HasArgument("expand"))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1003 {
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1004 Json::Value result = Json::objectValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1005 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1006 it = peers.begin(); it != peers.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1007 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1008 WebServiceParameters peer;
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1009
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
1010 if (lock.GetConfiguration().LookupOrthancPeer(peer, *it))
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1011 {
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1012 Json::Value jsonPeer = Json::objectValue;
2871
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1013 // only return the minimum information to identify the
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1014 // destination, do not include "security" information like
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1015 // passwords
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1016 jsonPeer["Url"] = peer.GetUrl();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1017 if (!peer.GetUsername().empty())
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1018 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1019 jsonPeer["Username"] = peer.GetUsername();
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1020 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1021 result[*it] = jsonPeer;
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1022 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1023 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1024 call.GetOutput().AnswerJson(result);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 }
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1026 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
1027 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1028 Json::Value result = Json::arrayValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1029 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1030 it = peers.begin(); it != peers.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1031 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1032 result.append(*it);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1033 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1035 call.GetOutput().AnswerJson(result);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1036 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1039 static void ListPeerOperations(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1041 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1042
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1043 OrthancRestApi::SetOfStrings peers;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1044 lock.GetConfiguration().GetListOfOrthancPeers(peers);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1045
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1046 std::string id = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1047 if (IsExistingPeer(peers, id))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1048 {
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
1049 RestApi::AutoListChildren(call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1050 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1051 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1053 static void PeerStore(RestApiPostCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1055 ServerContext& context = OrthancRestApi::GetContext(call);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1056
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1057 std::string remote = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1058
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
1059 Json::Value request;
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
1060 std::auto_ptr<OrthancPeerStoreJob> job(new OrthancPeerStoreJob(context));
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
1062 if (GetInstancesToExport(request, *job, remote, call))
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
1063 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1064 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1065
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
1066 WebServiceParameters peer;
2944
f395460af74d simplifying OrthancConfiguration for modalities/peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2940
diff changeset
1067 if (lock.GetConfiguration().LookupOrthancPeer(peer, remote))
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1068 {
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1069 job->SetPeer(peer);
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2867
diff changeset
1070 OrthancRestApi::GetApi(call).SubmitCommandsJob
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2867
diff changeset
1071 (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
1072 }
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1073 else
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1074 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2948
diff changeset
1075 throw OrthancException(ErrorCode_UnknownResource,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2948
diff changeset
1076 "No peer with symbolic name: " + remote);
2799
6e3a60b85da6 New primitives to access Orthanc peers from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2685
diff changeset
1077 }
2626
e09021ddc00d cleanup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2624
diff changeset
1078 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1079 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1080
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1081
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1082 // DICOM bridge -------------------------------------------------------------
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1083
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1084 static bool IsExistingModality(const OrthancRestApi::SetOfStrings& modalities,
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1085 const std::string& id)
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1086 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1087 return modalities.find(id) != modalities.end();
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1088 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1089
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1090 static void ListModalities(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1092 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1093
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1094 OrthancRestApi::SetOfStrings modalities;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1095 lock.GetConfiguration().GetListOfDicomModalities(modalities);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1096
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1097 if (call.HasArgument("expand"))
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1098 {
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1099 Json::Value result = Json::objectValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1100 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1101 it = modalities.begin(); it != modalities.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1102 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1103 const RemoteModalityParameters& remote = lock.GetConfiguration().GetModalityUsingSymbolicName(*it);
2871
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1104
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1105 Json::Value info;
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1106 remote.Serialize(info, true /* force advanced format */);
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1107 result[*it] = info;
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1108 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1109 call.GetOutput().AnswerJson(result);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1110 }
2441
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1111 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
1112 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1113 Json::Value result = Json::arrayValue;
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1114 for (OrthancRestApi::SetOfStrings::const_iterator
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1115 it = modalities.begin(); it != modalities.end(); ++it)
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1116 {
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1117 result.append(*it);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1118 }
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1119 call.GetOutput().AnswerJson(result);
67c01a6f151e added ?expand argument to /peers and /modalities routes
amazy
parents: 2382
diff changeset
1120 }
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1121 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1122
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1123
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1124 static void ListModalityOperations(RestApiGetCall& call)
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1125 {
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1126 OrthancConfiguration::ReaderLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1127
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1128 OrthancRestApi::SetOfStrings modalities;
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1129 lock.GetConfiguration().GetListOfDicomModalities(modalities);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1130
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1131 std::string id = call.GetUriComponent("id", "");
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1132 if (IsExistingModality(modalities, id))
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1133 {
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
1134 RestApi::AutoListChildren(call);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1135 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1136 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1137
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1138
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1139 static void UpdateModality(RestApiPutCall& call)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1140 {
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1141 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1142
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1143 Json::Value json;
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1144 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
1145 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
1146 {
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1147 RemoteModalityParameters modality;
2871
6eebc2eb3168 refactoring serialization of RemoteModalityParameters
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
1148 modality.Unserialize(json);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1149
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1150 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1151 OrthancConfiguration::WriterLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1152 lock.GetConfiguration().UpdateModality(call.GetUriComponent("id", ""), modality);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1153 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1154
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1155 context.SignalUpdatedModalities();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1156
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1157 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1158 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1159 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1160
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1161
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1162 static void DeleteModality(RestApiDeleteCall& call)
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1163 {
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1164 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1165
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1166 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1167 OrthancConfiguration::WriterLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1168 lock.GetConfiguration().RemoveModality(call.GetUriComponent("id", ""));
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1169 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1170
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1171 context.SignalUpdatedModalities();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1172
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1173 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1174 }
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1175
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1176
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1177 static void UpdatePeer(RestApiPutCall& call)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1178 {
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1179 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1180
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1181 Json::Value json;
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1182 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
1183 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
1184 {
2020
a0bd8cd55da7 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
1185 WebServiceParameters peer;
2800
dc7330089736 "OrthancPeers" configuration option now allows to specify HTTP headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2799
diff changeset
1186 peer.Unserialize(json);
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1187
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1188 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1189 OrthancConfiguration::WriterLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1190 lock.GetConfiguration().UpdatePeer(call.GetUriComponent("id", ""), peer);
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1191 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1192
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1193 context.SignalUpdatedPeers();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1194
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1195 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1196 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1197 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1198
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1199
974
83622b0f544c refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 831
diff changeset
1200 static void DeletePeer(RestApiDeleteCall& call)
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1201 {
2801
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1202 ServerContext& context = OrthancRestApi::GetContext(call);
3ee82c7313e7 New events in change callbacks: "UpdatedPeers" and "UpdatedModalities"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2800
diff changeset
1203
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1204 {
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1205 OrthancConfiguration::WriterLock lock;
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1206 lock.GetConfiguration().RemovePeer(call.GetUriComponent("id", ""));
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1207 }
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1208
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1209 context.SignalUpdatedPeers();
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1210
2908
9d277f8ad698 new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2905
diff changeset
1211 call.GetOutput().AnswerBuffer("", MimeType_PlainText);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1212 }
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1213
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1214
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1215 static void DicomFindWorklist(RestApiPostCall& call)
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1216 {
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1217 ServerContext& context = OrthancRestApi::GetContext(call);
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1218
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1219 Json::Value json;
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1220 if (call.ParseJsonRequest(json))
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1221 {
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1222 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
1223 RemoteModalityParameters remote =
2940
4767d36679ed refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2908
diff changeset
1224 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1225
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1226 std::auto_ptr<ParsedDicomFile> query
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1227 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0)));
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1228
2059
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2020
diff changeset
1229 DicomFindAnswers answers(true);
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1230
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1231 {
2589
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1232 DicomUserConnection connection(localAet, remote);
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1233 connection.Open();
a3fdfb6979ed getting rid of ReusableDicomConnection in REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2587
diff changeset
1234 connection.FindWorklist(answers, *query);
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1235 }
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1236
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1237 Json::Value result;
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1238 answers.ToJson(result, true);
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1239 call.GetOutput().AnswerJson(result);
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1240 }
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1241 }
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1242
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1243
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1244 void OrthancRestApi::RegisterModalities()
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1245 {
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1246 Register("/modalities", ListModalities);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1247 Register("/modalities/{id}", ListModalityOperations);
807
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1248 Register("/modalities/{id}", UpdateModality);
566a2fb3c1fb update/delete modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 806
diff changeset
1249 Register("/modalities/{id}", DeleteModality);
1049
bd2cb95003da C-Echo SCU in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1007
diff changeset
1250 Register("/modalities/{id}/echo", DicomEcho);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1251 Register("/modalities/{id}/find-patient", DicomFindPatient);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1252 Register("/modalities/{id}/find-study", DicomFindStudy);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1253 Register("/modalities/{id}/find-series", DicomFindSeries);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1254 Register("/modalities/{id}/find-instance", DicomFindInstance);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1255 Register("/modalities/{id}/find", DicomFind);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1256 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
1257 Register("/modalities/{id}/move", DicomMove);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1258
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1259 // For Query/Retrieve
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1260 Register("/modalities/{id}/query", DicomQuery);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1261 Register("/queries", ListQueries);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1262 Register("/queries/{id}", DeleteQuery);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1263 Register("/queries/{id}", ListQueryOperations);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1264 Register("/queries/{id}/answers", ListQueryAnswers);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1265 Register("/queries/{id}/answers/{index}", ListQueryAnswerOperations);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1266 Register("/queries/{id}/answers/{index}/content", GetQueryOneAnswer);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1267 Register("/queries/{id}/answers/{index}/retrieve", RetrieveOneAnswer);
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1268 Register("/queries/{id}/answers/{index}/query-instances",
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1269 QueryAnswerChildren<ResourceType_Instance>);
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1270 Register("/queries/{id}/answers/{index}/query-series",
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1271 QueryAnswerChildren<ResourceType_Series>);
2982
94c8222c52b7 New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2955
diff changeset
1272 Register("/queries/{id}/answers/{index}/query-studies",
2986
b1ba0a8311b5 exploring hierarchy of C-FIND answers finished
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2982
diff changeset
1273 QueryAnswerChildren<ResourceType_Study>);
1368
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1274 Register("/queries/{id}/level", GetQueryLevel);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1275 Register("/queries/{id}/modality", GetQueryModality);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1276 Register("/queries/{id}/query", GetQueryArguments);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1277 Register("/queries/{id}/retrieve", RetrieveAllAnswers);
b22ba8c5edbe query retrieve
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
1278
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1279 Register("/peers", ListPeers);
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1280 Register("/peers/{id}", ListPeerOperations);
808
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1281 Register("/peers/{id}", UpdatePeer);
2d9a000aa3a6 update/delete peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 807
diff changeset
1282 Register("/peers/{id}", DeletePeer);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1283 Register("/peers/{id}/store", PeerStore);
1819
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1284
84f0a118a72c new URI: /modalities/{id}/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1787
diff changeset
1285 Register("/modalities/{id}/find-worklist", DicomFindWorklist);
751
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1286 }
5197fd35333c refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1287 }