annotate OrthancServer/OrthancRestApi2.cpp @ 215:c07170f3f4f7

refactoring of access to images in REST
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2012 11:25:29 +0100
parents 03817919169b
children e5d5d4a9a326
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
210
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Belgium
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "OrthancRestApi2.h"
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "OrthancInitialization.h"
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "FromDcmtkBridge.h"
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "../Core/Uuid.h"
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 #include "../Core/HttpServer/FilesystemHttpSender.h"
213
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
39 #include "ServerToolbox.h"
210
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include <dcmtk/dcmdata/dcistrmb.h>
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <dcmtk/dcmdata/dcfilefo.h>
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #include <boost/lexical_cast.hpp>
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 #define RETRIEVE_CONTEXT(call) \
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 OrthancRestApi2& context = dynamic_cast<OrthancRestApi2&>(call.GetContext())
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 namespace Orthanc
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 // System information -------------------------------------------------------
211
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
53
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
54 static void ServeRoot(RestApi::GetCall& call)
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
55 {
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
56 call.GetOutput().Redirect("app/explorer.html");
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
57 }
210
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 static void GetSystemInformation(RestApi::GetCall& call)
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 RETRIEVE_CONTEXT(call);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 Json::Value result = Json::objectValue;
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 result["Version"] = ORTHANC_VERSION;
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 result["Name"] = GetGlobalStringParameter("Name", "");
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 result["TotalCompressedSize"] = boost::lexical_cast<std::string>(context.GetIndex().GetTotalCompressedSize());
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 result["TotalUncompressedSize"] = boost::lexical_cast<std::string>(context.GetIndex().GetTotalUncompressedSize());
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 call.GetOutput().AnswerJson(result);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
211
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
72 // List all the patients, studies, series or instances ----------------------
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
73
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
74 template <enum ResourceType resourceType>
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
75 static void ListResources(RestApi::GetCall& call)
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
76 {
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
77 RETRIEVE_CONTEXT(call);
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
78
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
79 Json::Value result;
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
80 context.GetIndex().GetAllUuids(result, resourceType);
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
81 call.GetOutput().AnswerJson(result);
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
82 }
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
83
212
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
84 template <enum ResourceType resourceType>
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
85 static void GetSingleResource(RestApi::GetCall& call)
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
86 {
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
87 RETRIEVE_CONTEXT(call);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
88
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
89 Json::Value result;
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
90 if (context.GetIndex().LookupResource(result, call.GetUriComponent("id", ""), resourceType))
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
91 {
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
92 call.GetOutput().AnswerJson(result);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
93 }
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
94 }
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
95
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
96 template <enum ResourceType resourceType>
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
97 static void DeleteSingleResource(RestApi::DeleteCall& call)
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
98 {
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
99 RETRIEVE_CONTEXT(call);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
100
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
101 Json::Value result;
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
102 if (context.GetIndex().DeleteResource(result, call.GetUriComponent("id", ""), resourceType))
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
103 {
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
104 call.GetOutput().AnswerJson(result);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
105 }
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
106 }
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
107
211
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
108
210
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 // Changes API --------------------------------------------------------------
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 static void GetChanges(RestApi::GetCall& call)
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 RETRIEVE_CONTEXT(call);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 static const unsigned int MAX_RESULTS = 100;
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 ServerIndex& index = context.GetIndex();
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 //std::string filter = GetArgument(getArguments, "filter", "");
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 int64_t since;
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 unsigned int limit;
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 try
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 since = boost::lexical_cast<int64_t>(call.GetArgument("since", "0"));
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 limit = boost::lexical_cast<unsigned int>(call.GetArgument("limit", "0"));
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 catch (boost::bad_lexical_cast)
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 return;
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 }
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 if (limit == 0 || limit > MAX_RESULTS)
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 limit = MAX_RESULTS;
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 Json::Value result;
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 if (index.GetChanges(result, since, limit))
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 call.GetOutput().AnswerJson(result);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
213
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
145 // Get information about a single instance ----------------------------------
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
146
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
147 static void GetInstanceFile(RestApi::GetCall& call)
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
148 {
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
149 RETRIEVE_CONTEXT(call);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
150
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
151 CompressionType compressionType;
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
152 std::string fileUuid;
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
153 std::string publicId = call.GetUriComponent("id", "");
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
154
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
155 if (context.GetIndex().GetFile(fileUuid, compressionType, publicId, AttachedFileType_Dicom))
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
156 {
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
157 assert(compressionType == CompressionType_None);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
158
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
159 FilesystemHttpSender sender(context.GetFileStorage(), fileUuid);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
160 sender.SetFilename(fileUuid + ".dcm");
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
161 sender.SetContentType("application/dicom");
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
162 call.GetOutput().AnswerFile(sender);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
163 }
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
164 }
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
165
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
166
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
167 template <bool simplify>
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
168 static void GetInstanceTags(RestApi::GetCall& call)
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
169 {
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
170 RETRIEVE_CONTEXT(call);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
171
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
172 CompressionType compressionType;
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
173 std::string fileUuid;
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
174 std::string publicId = call.GetUriComponent("id", "");
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
175
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
176 if (context.GetIndex().GetFile(fileUuid, compressionType, publicId, AttachedFileType_Json))
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
177 {
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
178 assert(compressionType == CompressionType_None);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
179
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
180 Json::Value full;
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
181 ReadJson(full, context.GetFileStorage(), fileUuid);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
182
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
183 if (simplify)
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
184 {
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
185 Json::Value simplified;
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
186 SimplifyTags(simplified, full);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
187 call.GetOutput().AnswerJson(simplified);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
188 }
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
189 else
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
190 {
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
191 call.GetOutput().AnswerJson(full);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
192 }
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
193 }
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
194 }
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
195
214
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
196
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
197 static void ListFrames(RestApi::GetCall& call)
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
198 {
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
199 RETRIEVE_CONTEXT(call);
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
200
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
201 Json::Value instance;
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
202 if (context.GetIndex().LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance))
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
203 {
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
204 unsigned int numberOfFrames = 1;
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
205
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
206 try
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
207 {
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
208 Json::Value tmp = instance["MainDicomTags"]["NumberOfFrames"];
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
209 numberOfFrames = boost::lexical_cast<unsigned int>(tmp.asString());
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
210 }
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
211 catch (...)
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
212 {
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
213 }
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
214
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
215 Json::Value result = Json::arrayValue;
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
216 for (unsigned int i = 0; i < numberOfFrames; i++)
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
217 {
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
218 result.append(i);
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
219 }
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
220
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
221 call.GetOutput().AnswerJson(result);
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
222 }
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
223 }
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
224
213
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
225
215
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
226 template <enum ImageExtractionMode mode>
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
227 static void GetImage(RestApi::GetCall& call)
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
228 {
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
229 RETRIEVE_CONTEXT(call);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
230
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
231 CompressionType compressionType;
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
232 std::string fileUuid;
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
233 std::string publicId = call.GetUriComponent("id", "");
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
234 std::string frameId = call.GetUriComponent("frame", "0");
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
235
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
236 unsigned int frame;
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
237 try
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
238 {
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
239 frame = boost::lexical_cast<unsigned int>(frameId);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
240 }
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
241 catch (boost::bad_lexical_cast)
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
242 {
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
243 return;
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
244 }
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
245
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
246 if (context.GetIndex().GetFile(fileUuid, compressionType, publicId, AttachedFileType_Dicom))
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
247 {
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
248 assert(compressionType == CompressionType_None);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
249
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
250 std::string dicomContent, png;
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
251 context.GetFileStorage().ReadFile(dicomContent, fileUuid);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
252
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
253 try
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
254 {
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
255 FromDcmtkBridge::ExtractPngImage(png, dicomContent, frame, mode);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
256 call.GetOutput().AnswerBuffer(png, "image/png");
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
257 }
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
258 catch (OrthancException&)
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
259 {
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
260 std::string root = "";
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
261 for (size_t i = 1; i < call.GetFullUri().size(); i++)
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
262 {
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
263 root += "../";
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
264 }
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
265
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
266 call.GetOutput().Redirect(root + "app/images/unsupported.png");
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
267 }
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
268 }
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
269 }
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
270
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
271
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
272
210
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 // DICOM bridge -------------------------------------------------------------
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 static void ListModalities(RestApi::GetCall& call)
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 RETRIEVE_CONTEXT(call);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 Json::Value result = Json::arrayValue;
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 for (OrthancRestApi2::Modalities::const_iterator
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 it = context.GetModalities().begin();
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 it != context.GetModalities().end(); it++)
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 result.append(*it);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 }
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 call.GetOutput().AnswerJson(result);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 }
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292
213
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
293
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
294 // Registration of the various REST handlers --------------------------------
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
295
210
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 OrthancRestApi2::OrthancRestApi2(ServerIndex& index,
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 const std::string& path) :
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 index_(index),
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 storage_(path)
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 {
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 GetListOfDicomModalities(modalities_);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302
211
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
303 Register("/", ServeRoot);
210
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 Register("/system", GetSystemInformation);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 Register("/changes", GetChanges);
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 Register("/modalities", ListModalities);
211
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
307
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
308 Register("/instances", ListResources<ResourceType_Instance>);
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
309 Register("/patients", ListResources<ResourceType_Patient>);
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
310 Register("/series", ListResources<ResourceType_Series>);
b7aea293b965 list of resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 210
diff changeset
311 Register("/studies", ListResources<ResourceType_Study>);
212
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
312
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
313 Register("/instances/{id}", DeleteSingleResource<ResourceType_Instance>);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
314 Register("/instances/{id}", GetSingleResource<ResourceType_Instance>);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
315 Register("/patients/{id}", DeleteSingleResource<ResourceType_Patient>);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
316 Register("/patients/{id}", GetSingleResource<ResourceType_Patient>);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
317 Register("/series/{id}", DeleteSingleResource<ResourceType_Series>);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
318 Register("/series/{id}", GetSingleResource<ResourceType_Series>);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
319 Register("/studies/{id}", DeleteSingleResource<ResourceType_Study>);
f276b175dcaf delete resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 211
diff changeset
320 Register("/studies/{id}", GetSingleResource<ResourceType_Study>);
213
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
321
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
322 Register("/instances/{id}/file", GetInstanceFile);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
323 Register("/instances/{id}/tags", GetInstanceTags<false>);
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
324 Register("/instances/{id}/simplified-tags", GetInstanceTags<true>);
214
03817919169b list of frames
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 213
diff changeset
325 Register("/instances/{id}/frames", ListFrames);
213
4ce7fdcc8879 access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
326
215
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
327 Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
328 Register("/instances/{id}/frames/{frame}/image-uint8", GetImage<ImageExtractionMode_UInt8>);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
329 Register("/instances/{id}/frames/{frame}/image-uint16", GetImage<ImageExtractionMode_UInt16>);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
330 Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
331 Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
332 Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>);
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
333
c07170f3f4f7 refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 214
diff changeset
334 // TODO : "content"
210
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 }
96b7918a6a18 start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 }