Mercurial > hg > orthanc
annotate OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 3125:8296f0f75716 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 15 Jan 2019 21:11:44 +0100 |
parents | 61da3c9b4121 |
children | cf91b6f22278 |
rev | line source |
---|---|
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1281
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3060
4e43e67f8ecf
preparing for 2019
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3048
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 |
2408
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
37 #include "../../Core/Compression/GzipCompressor.h" |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
38 #include "../../Core/DicomParsing/FromDcmtkBridge.h" |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
39 #include "../../Core/DicomParsing/Internals/DicomImageDecoder.h" |
2131 | 40 #include "../../Core/HttpServer/HttpContentNegociation.h" |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1446
diff
changeset
|
41 #include "../../Core/Logging.h" |
3048
8b331be57606
fix build without plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3021
diff
changeset
|
42 #include "../DefaultDicomImageDecoder.h" |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
43 #include "../OrthancConfiguration.h" |
3094
61da3c9b4121
cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
44 #include "../Search/DatabaseLookup.h" |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1385
diff
changeset
|
45 #include "../ServerContext.h" |
2131 | 46 #include "../ServerToolbox.h" |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
47 #include "../SliceOrdering.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
3085 | 49 #include "../../Plugins/Engine/OrthancPlugins.h" |
50 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 namespace Orthanc |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
54 static void AnswerDicomAsJson(RestApiCall& call, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
55 const Json::Value& dicom, |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
56 DicomToJsonFormat mode) |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
57 { |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
58 if (mode != DicomToJsonFormat_Full) |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
59 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
60 Json::Value simplified; |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
61 ServerToolbox::SimplifyTags(simplified, dicom, mode); |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
62 call.GetOutput().AnswerJson(simplified); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
63 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
64 else |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
65 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
66 call.GetOutput().AnswerJson(dicom); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
67 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
68 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
69 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
70 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
71 static DicomToJsonFormat GetDicomFormat(const RestApiGetCall& call) |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
72 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
73 if (call.HasArgument("simplify")) |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
74 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
75 return DicomToJsonFormat_Human; |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
76 } |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
77 else if (call.HasArgument("short")) |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
78 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
79 return DicomToJsonFormat_Short; |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
80 } |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
81 else |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
82 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
83 return DicomToJsonFormat_Full; |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
84 } |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
85 } |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
86 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
87 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
88 static void AnswerDicomAsJson(RestApiGetCall& call, |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
89 const Json::Value& dicom) |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
90 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
91 AnswerDicomAsJson(call, dicom, GetDicomFormat(call)); |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
92 } |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
93 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
94 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
95 static void ParseSetOfTags(std::set<DicomTag>& target, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
96 const RestApiGetCall& call, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
97 const std::string& argument) |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
98 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
99 target.clear(); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
100 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
101 if (call.HasArgument(argument)) |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
102 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
103 std::vector<std::string> tags; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
104 Toolbox::TokenizeString(tags, call.GetArgument(argument, ""), ','); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
105 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
106 for (size_t i = 0; i < tags.size(); i++) |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
107 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
108 target.insert(FromDcmtkBridge::ParseTag(tags[i])); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
109 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
110 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
111 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
112 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
113 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 // List all the patients, studies, series or instances ---------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
1354 | 116 static void AnswerListOfResources(RestApiOutput& output, |
117 ServerIndex& index, | |
118 const std::list<std::string>& resources, | |
119 ResourceType level, | |
120 bool expand) | |
121 { | |
122 Json::Value answer = Json::arrayValue; | |
123 | |
124 for (std::list<std::string>::const_iterator | |
1384 | 125 resource = resources.begin(); resource != resources.end(); ++resource) |
1354 | 126 { |
127 if (expand) | |
128 { | |
129 Json::Value item; | |
130 if (index.LookupResource(item, *resource, level)) | |
131 { | |
132 answer.append(item); | |
133 } | |
134 } | |
135 else | |
136 { | |
137 answer.append(*resource); | |
138 } | |
139 } | |
140 | |
141 output.AnswerJson(answer); | |
142 } | |
143 | |
144 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 template <enum ResourceType resourceType> |
974 | 146 static void ListResources(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 { |
1342
9ec7ac03152d
"?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1303
diff
changeset
|
148 ServerIndex& index = OrthancRestApi::GetIndex(call); |
9ec7ac03152d
"?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1303
diff
changeset
|
149 |
1354 | 150 std::list<std::string> result; |
1509
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
151 |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
152 if (call.HasArgument("limit") || |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
153 call.HasArgument("since")) |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
154 { |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
155 if (!call.HasArgument("limit")) |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
156 { |
2955 | 157 throw OrthancException(ErrorCode_BadRequest, |
158 "Missing \"limit\" argument for GET request against: " + | |
159 call.FlattenUri()); | |
1509
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
160 } |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
161 |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
162 if (!call.HasArgument("since")) |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
163 { |
2955 | 164 throw OrthancException(ErrorCode_BadRequest, |
165 "Missing \"since\" argument for GET request against: " + | |
166 call.FlattenUri()); | |
1509
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
167 } |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
168 |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
169 size_t since = boost::lexical_cast<size_t>(call.GetArgument("since", "")); |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
170 size_t limit = boost::lexical_cast<size_t>(call.GetArgument("limit", "")); |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
171 index.GetAllUuids(result, resourceType, since, limit); |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
172 } |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
173 else |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
174 { |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
175 index.GetAllUuids(result, resourceType); |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
176 } |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
177 |
1342
9ec7ac03152d
"?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1303
diff
changeset
|
178 |
1354 | 179 AnswerListOfResources(call.GetOutput(), index, result, resourceType, call.HasArgument("expand")); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 template <enum ResourceType resourceType> |
974 | 183 static void GetSingleResource(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 Json::Value result; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 if (OrthancRestApi::GetIndex(call).LookupResource(result, call.GetUriComponent("id", ""), resourceType)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 template <enum ResourceType resourceType> |
974 | 193 static void DeleteSingleResource(RestApiDeleteCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 Json::Value result; |
1145
0479d02c6778
Plugins can retrieve the path to Orthanc and to its configuration file
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1140
diff
changeset
|
196 if (OrthancRestApi::GetContext(call).DeleteResource(result, call.GetUriComponent("id", ""), resourceType)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
200 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 // Get information about a single patient ----------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 |
974 | 205 static void IsProtectedPatient(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 bool isProtected = OrthancRestApi::GetIndex(call).IsProtectedPatient(publicId); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
209 call.GetOutput().AnswerBuffer(isProtected ? "1" : "0", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 |
974 | 213 static void SetPatientProtection(RestApiPutCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
219 std::string body; |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
220 call.BodyToString(body); |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
221 body = Toolbox::StripSpaces(body); |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
222 |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
223 if (body == "0") |
751
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 context.GetIndex().SetProtectedPatient(publicId, false); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
226 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 } |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
228 else if (body == "1") |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 context.GetIndex().SetProtectedPatient(publicId, true); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
231 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 // Bad request |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 // Get information about a single instance ---------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 |
974 | 242 static void GetInstanceFile(RestApiGetCall& call) |
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 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 std::string publicId = call.GetUriComponent("id", ""); |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
247 context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_Dicom); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 |
974 | 251 static void ExportInstanceFile(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 std::string dicom; |
2124 | 258 context.ReadDicom(dicom, publicId); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
260 std::string target; |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
261 call.BodyToString(target); |
2140 | 262 SystemToolbox::WriteFile(dicom, target); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
264 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 } |
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 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
268 template <DicomToJsonFormat format> |
974 | 269 static void GetInstanceTags(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 std::string publicId = call.GetUriComponent("id", ""); |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
274 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
275 std::set<DicomTag> ignoreTagLength; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
276 ParseSetOfTags(ignoreTagLength, call, "ignore-length"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
278 if (format != DicomToJsonFormat_Full || |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
279 !ignoreTagLength.empty()) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 { |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
281 Json::Value full; |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
282 context.ReadDicomAsJson(full, publicId, ignoreTagLength); |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
283 AnswerDicomAsJson(call, full, format); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
287 // This path allows to avoid the JSON decoding if no |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
288 // simplification is asked, and if no "ignore-length" argument |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
289 // is present |
2127 | 290 std::string full; |
291 context.ReadDicomAsJson(full, publicId); | |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
292 call.GetOutput().AnswerBuffer(full, MimeType_Json); |
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 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
296 |
974 | 297 static void GetInstanceTagsBis(RestApiGetCall& call) |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
298 { |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
299 switch (GetDicomFormat(call)) |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
300 { |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
301 case DicomToJsonFormat_Human: |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
302 GetInstanceTags<DicomToJsonFormat_Human>(call); |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
303 break; |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
304 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
305 case DicomToJsonFormat_Short: |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
306 GetInstanceTags<DicomToJsonFormat_Short>(call); |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
307 break; |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
308 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
309 case DicomToJsonFormat_Full: |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
310 GetInstanceTags<DicomToJsonFormat_Full>(call); |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
311 break; |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
312 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
313 default: |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
314 throw OrthancException(ErrorCode_InternalError); |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
315 } |
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
316 } |
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
317 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 |
974 | 319 static void ListFrames(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 { |
1950
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
321 std::string publicId = call.GetUriComponent("id", ""); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 |
1950
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
323 unsigned int numberOfFrames; |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
324 |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
325 { |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
326 ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), publicId); |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
327 numberOfFrames = locker.GetDicom().GetFramesCount(); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 } |
1950
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
329 |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
330 Json::Value result = Json::arrayValue; |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
331 for (unsigned int i = 0; i < numberOfFrames; i++) |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
332 { |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
333 result.append(i); |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
334 } |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
335 |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
336 call.GetOutput().AnswerJson(result); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
340 namespace |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
341 { |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
342 class ImageToEncode |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
343 { |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
344 private: |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
345 std::auto_ptr<ImageAccessor>& image_; |
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
346 ImageExtractionMode mode_; |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
347 bool invert_; |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
348 MimeType format_; |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
349 std::string answer_; |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
350 |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
351 public: |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
352 ImageToEncode(std::auto_ptr<ImageAccessor>& image, |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
353 ImageExtractionMode mode, |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
354 bool invert) : |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
355 image_(image), |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
356 mode_(mode), |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
357 invert_(invert) |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
358 { |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
359 } |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
360 |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
361 void Answer(RestApiOutput& output) |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
362 { |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
363 output.AnswerBuffer(answer_, format_); |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
364 } |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
365 |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
366 void EncodeUsingPng() |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
367 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
368 format_ = MimeType_Png; |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
369 DicomImageDecoder::ExtractPngImage(answer_, image_, mode_, invert_); |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
370 } |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
371 |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
372 void EncodeUsingPam() |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
373 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
374 format_ = MimeType_Pam; |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
375 DicomImageDecoder::ExtractPamImage(answer_, image_, mode_, invert_); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
376 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
377 |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
378 void EncodeUsingJpeg(uint8_t quality) |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
379 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
380 format_ = MimeType_Jpeg; |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
381 DicomImageDecoder::ExtractJpegImage(answer_, image_, mode_, invert_, quality); |
1824
b530c3dfe2a6
refactoring image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1784
diff
changeset
|
382 } |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
383 }; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
384 |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
385 class EncodePng : public HttpContentNegociation::IHandler |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
386 { |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
387 private: |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
388 ImageToEncode& image_; |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
389 |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
390 public: |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
391 EncodePng(ImageToEncode& image) : image_(image) |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
392 { |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
393 } |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
394 |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
395 virtual void Handle(const std::string& type, |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
396 const std::string& subtype) |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
397 { |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
398 assert(type == "image"); |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
399 assert(subtype == "png"); |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
400 image_.EncodeUsingPng(); |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
401 } |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
402 }; |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
403 |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
404 class EncodePam : public HttpContentNegociation::IHandler |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
405 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
406 private: |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
407 ImageToEncode& image_; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
408 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
409 public: |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
410 EncodePam(ImageToEncode& image) : image_(image) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
411 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
412 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
413 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
414 virtual void Handle(const std::string& type, |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
415 const std::string& subtype) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
416 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
417 assert(type == "image"); |
2780 | 418 assert(subtype == "x-portable-arbitrarymap"); |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
419 image_.EncodeUsingPam(); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
420 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
421 }; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
422 |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
423 class EncodeJpeg : public HttpContentNegociation::IHandler |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
424 { |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
425 private: |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
426 ImageToEncode& image_; |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
427 unsigned int quality_; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
428 |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
429 public: |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
430 EncodeJpeg(ImageToEncode& image, |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
431 const RestApiGetCall& call) : |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
432 image_(image) |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
433 { |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
434 std::string v = call.GetArgument("quality", "90" /* default JPEG quality */); |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
435 bool ok = false; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
436 |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
437 try |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
438 { |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
439 quality_ = boost::lexical_cast<unsigned int>(v); |
1847 | 440 ok = (quality_ >= 1 && quality_ <= 100); |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
441 } |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
442 catch (boost::bad_lexical_cast&) |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
443 { |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
444 } |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
445 |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
446 if (!ok) |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
447 { |
2955 | 448 throw OrthancException( |
449 ErrorCode_BadRequest, | |
450 "Bad quality for a JPEG encoding (must be a number between 0 and 100): " + v); | |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
451 } |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
452 } |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
453 |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
454 virtual void Handle(const std::string& type, |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
455 const std::string& subtype) |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
456 { |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
457 assert(type == "image"); |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
458 assert(subtype == "jpeg"); |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
459 image_.EncodeUsingJpeg(quality_); |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
460 } |
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
461 }; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
462 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
463 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
464 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
465 template <enum ImageExtractionMode mode> |
974 | 466 static void GetImage(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 std::string frameId = call.GetUriComponent("frame", "0"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
471 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
472 unsigned int frame; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 try |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 frame = boost::lexical_cast<unsigned int>(frameId); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 } |
2836
7133ad478eea
fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2804
diff
changeset
|
477 catch (boost::bad_lexical_cast&) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
482 bool invert = false; |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
483 std::auto_ptr<ImageAccessor> decoded; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 try |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 { |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
487 std::string publicId = call.GetUriComponent("id", ""); |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
488 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
489 #if ORTHANC_ENABLE_PLUGINS == 1 |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
490 if (context.GetPlugins().HasCustomImageDecoder()) |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
491 { |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
492 // TODO create a cache of file |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
493 std::string dicomContent; |
2124 | 494 context.ReadDicom(dicomContent, publicId); |
2012
50b9bc19dc62
More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
495 decoded.reset(context.GetPlugins().DecodeUnsafe(dicomContent.c_str(), dicomContent.size(), frame)); |
50b9bc19dc62
More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
496 |
50b9bc19dc62
More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
497 /** |
50b9bc19dc62
More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
498 * Note that we call "DecodeUnsafe()": We do not fallback to |
50b9bc19dc62
More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
499 * the builtin decoder if no installed decoder plugin is able |
50b9bc19dc62
More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
500 * to decode the image. This allows us to take advantage of |
50b9bc19dc62
More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
501 * the cache below. |
50b9bc19dc62
More than one custom image decoder can be installed (e.g. to handle different transfer syntaxes)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2007
diff
changeset
|
502 **/ |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
503 |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
504 if (mode == ImageExtractionMode_Preview && |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
505 decoded.get() != NULL) |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
506 { |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
507 // TODO Optimize this lookup for photometric interpretation: |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
508 // It should be implemented by the plugin to avoid parsing |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
509 // twice the DICOM file |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
510 ParsedDicomFile parsed(dicomContent); |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
511 |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
512 PhotometricInterpretation photometric; |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
513 if (parsed.LookupPhotometricInterpretation(photometric)) |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
514 { |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
515 invert = (photometric == PhotometricInterpretation_Monochrome1); |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
516 } |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
517 } |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
518 } |
1826
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
519 #endif |
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
520 |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
521 if (decoded.get() == NULL) |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
522 { |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
523 // Use Orthanc's built-in decoder, using the cache to speed-up |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
524 // things on multi-frame images |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
525 ServerContext::DicomCacheLocker locker(context, publicId); |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
526 decoded.reset(DicomImageDecoder::Decode(locker.GetDicom(), frame)); |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
527 |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
528 PhotometricInterpretation photometric; |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
529 if (mode == ImageExtractionMode_Preview && |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
530 locker.GetDicom().LookupPhotometricInterpretation(photometric)) |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
531 { |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
532 invert = (photometric == PhotometricInterpretation_Monochrome1); |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
533 } |
1784
2dbf25006f88
".../preview" and ".../image-uint8" can return JPEG images if the HTTP Accept Header asks so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1781
diff
changeset
|
534 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 catch (OrthancException& e) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 { |
2935
aeeb40a35ce1
/image-uint16: return 404 instead of unsupported.png when instance is not found
am@osimis.io
parents:
2908
diff
changeset
|
538 if (e.GetErrorCode() == ErrorCode_ParameterOutOfRange || e.GetErrorCode() == ErrorCode_UnknownResource) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 // The frame number is out of the range for this DICOM |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 // instance, the resource is not existent |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 std::string root = ""; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 for (size_t i = 1; i < call.GetFullUri().size(); i++) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
547 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 root += "../"; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 call.GetOutput().Redirect(root + "app/images/unsupported.png"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
552 } |
2935
aeeb40a35ce1
/image-uint16: return 404 instead of unsupported.png when instance is not found
am@osimis.io
parents:
2908
diff
changeset
|
553 return; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 } |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
555 |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
556 ImageToEncode image(decoded, mode, invert); |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
557 |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
558 HttpContentNegociation negociation; |
2704
b71c59312bae
fix MIME type for PAM images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2699
diff
changeset
|
559 EncodePng png(image); |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2876
diff
changeset
|
560 negociation.Register(MIME_PNG, png); |
2704
b71c59312bae
fix MIME type for PAM images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2699
diff
changeset
|
561 |
b71c59312bae
fix MIME type for PAM images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2699
diff
changeset
|
562 EncodeJpeg jpeg(image, call); |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2876
diff
changeset
|
563 negociation.Register(MIME_JPEG, jpeg); |
2704
b71c59312bae
fix MIME type for PAM images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2699
diff
changeset
|
564 |
b71c59312bae
fix MIME type for PAM images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2699
diff
changeset
|
565 EncodePam pam(image); |
2905
ae20fccdd867
refactoring mime types
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2876
diff
changeset
|
566 negociation.Register(MIME_PAM, pam); |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
567 |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
568 if (negociation.Apply(call.GetHttpHeaders())) |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
569 { |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
570 image.Answer(call.GetOutput()); |
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
571 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 |
974 | 575 static void GetMatlabImage(RestApiGetCall& call) |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
576 { |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
577 ServerContext& context = OrthancRestApi::GetContext(call); |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
578 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
579 std::string frameId = call.GetUriComponent("frame", "0"); |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
580 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
581 unsigned int frame; |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
582 try |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
583 { |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
584 frame = boost::lexical_cast<unsigned int>(frameId); |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
585 } |
2836
7133ad478eea
fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2804
diff
changeset
|
586 catch (boost::bad_lexical_cast&) |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
587 { |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
588 return; |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
589 } |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
590 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
591 std::string publicId = call.GetUriComponent("id", ""); |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
592 std::string dicomContent; |
2124 | 593 context.ReadDicom(dicomContent, publicId); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
594 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
595 #if ORTHANC_ENABLE_PLUGINS == 1 |
1826
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
596 IDicomImageDecoder& decoder = context.GetPlugins(); |
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
597 #else |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
598 DefaultDicomImageDecoder decoder; // This is Orthanc's built-in decoder |
1826
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
599 #endif |
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
600 |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
601 std::auto_ptr<ImageAccessor> decoded(decoder.Decode(dicomContent.c_str(), dicomContent.size(), frame)); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
602 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
603 std::string result; |
1826
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
604 decoded->ToMatlabString(result); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
605 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
606 call.GetOutput().AnswerBuffer(result, MimeType_PlainText); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
607 } |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
608 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
609 |
2408
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
610 template <bool GzipCompression> |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
611 static void GetRawFrame(RestApiGetCall& call) |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
612 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
613 std::string frameId = call.GetUriComponent("frame", "0"); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
614 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
615 unsigned int frame; |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
616 try |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
617 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
618 frame = boost::lexical_cast<unsigned int>(frameId); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
619 } |
2836
7133ad478eea
fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2804
diff
changeset
|
620 catch (boost::bad_lexical_cast&) |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
621 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
622 return; |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
623 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
624 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
625 std::string publicId = call.GetUriComponent("id", ""); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
626 std::string raw; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
627 MimeType mime; |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
628 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
629 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
630 ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), publicId); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
631 locker.GetDicom().GetRawFrame(raw, mime, frame); |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
632 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
633 |
2408
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
634 if (GzipCompression) |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
635 { |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
636 GzipCompressor gzip; |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
637 std::string compressed; |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
638 gzip.Compress(compressed, raw.empty() ? NULL : raw.c_str(), raw.size()); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
639 call.GetOutput().AnswerBuffer(compressed, MimeType_Gzip); |
2408
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
640 } |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
641 else |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
642 { |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
643 call.GetOutput().AnswerBuffer(raw, mime); |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
644 } |
1924
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
645 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
646 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
647 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
648 |
974 | 649 static void GetResourceStatistics(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 Json::Value result; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 OrthancRestApi::GetIndex(call).GetStatistics(result, publicId); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
655 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
656 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
657 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
658 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 // Handling of metadata ----------------------------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 |
974 | 661 static void CheckValidResourceType(RestApiCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
662 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
663 std::string resourceType = call.GetUriComponent("resourceType", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
664 StringToResourceType(resourceType.c_str()); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
665 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
666 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
667 |
974 | 668 static void ListMetadata(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
669 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
671 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
672 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
673 std::list<MetadataType> metadata; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
675 OrthancRestApi::GetIndex(call).ListAvailableMetadata(metadata, publicId); |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
676 |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
677 Json::Value result; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
678 |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
679 if (call.HasArgument("expand")) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
680 { |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
681 result = Json::objectValue; |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
682 |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
683 for (std::list<MetadataType>::const_iterator |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
684 it = metadata.begin(); it != metadata.end(); ++it) |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
685 { |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
686 std::string value; |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
687 if (OrthancRestApi::GetIndex(call).LookupMetadata(value, publicId, *it)) |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
688 { |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
689 std::string key = EnumerationToString(*it); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
690 result[key] = value; |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
691 } |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
692 } |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
693 } |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
694 else |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
695 { |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
696 result = Json::arrayValue; |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
697 |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
698 for (std::list<MetadataType>::const_iterator |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
699 it = metadata.begin(); it != metadata.end(); ++it) |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
700 { |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
701 result.append(EnumerationToString(*it)); |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
702 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
703 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
704 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
705 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
706 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
707 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
708 |
974 | 709 static void GetMetadata(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
710 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
711 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
712 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
714 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 MetadataType metadata = StringToMetadata(name); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
716 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
717 std::string value; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
718 if (OrthancRestApi::GetIndex(call).LookupMetadata(value, publicId, metadata)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
719 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
720 call.GetOutput().AnswerBuffer(value, MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
721 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
722 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
723 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
724 |
974 | 725 static void DeleteMetadata(RestApiDeleteCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
726 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
727 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
728 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
729 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
730 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
731 MetadataType metadata = StringToMetadata(name); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
732 |
1773
613df4362575
New UpdatedAttachment and UpdatedMetadata events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1759
diff
changeset
|
733 if (IsUserMetadata(metadata)) // It is forbidden to modify internal metadata |
613df4362575
New UpdatedAttachment and UpdatedMetadata events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1759
diff
changeset
|
734 { |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 OrthancRestApi::GetIndex(call).DeleteMetadata(publicId, metadata); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
736 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
737 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
738 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
739 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
740 call.GetOutput().SignalError(HttpStatus_403_Forbidden); |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
741 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
742 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
743 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
744 |
974 | 745 static void SetMetadata(RestApiPutCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
746 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
747 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
748 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
749 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
750 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
751 MetadataType metadata = StringToMetadata(name); |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
752 |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
753 std::string value; |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
754 call.BodyToString(value); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
755 |
1773
613df4362575
New UpdatedAttachment and UpdatedMetadata events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1759
diff
changeset
|
756 if (IsUserMetadata(metadata)) // It is forbidden to modify internal metadata |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
757 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
758 // It is forbidden to modify internal metadata |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
759 OrthancRestApi::GetIndex(call).SetMetadata(publicId, metadata, value); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
760 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
761 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
762 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
763 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
764 call.GetOutput().SignalError(HttpStatus_403_Forbidden); |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
765 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
766 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
767 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
768 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
769 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
770 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
771 // Handling of attached files ----------------------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
772 |
974 | 773 static void ListAttachments(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
774 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
775 std::string resourceType = call.GetUriComponent("resourceType", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
776 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 std::list<FileContentType> attachments; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 OrthancRestApi::GetIndex(call).ListAvailableAttachments(attachments, publicId, StringToResourceType(resourceType.c_str())); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 Json::Value result = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
781 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
782 for (std::list<FileContentType>::const_iterator |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
783 it = attachments.begin(); it != attachments.end(); ++it) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
784 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
785 result.append(EnumerationToString(*it)); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
787 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
790 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
791 |
974 | 792 static bool GetAttachmentInfo(FileInfo& info, RestApiCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
793 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
794 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
795 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
797 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
798 FileContentType contentType = StringToContentType(name); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 return OrthancRestApi::GetIndex(call).LookupAttachment(info, publicId, contentType); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 |
974 | 804 static void GetAttachmentOperations(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
805 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 if (GetAttachmentInfo(info, call)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
808 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
809 Json::Value operations = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
810 |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
811 operations.append("compress"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
812 operations.append("compressed-data"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
813 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
814 if (info.GetCompressedMD5() != "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
816 operations.append("compressed-md5"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
818 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
819 operations.append("compressed-size"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
820 operations.append("data"); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
821 operations.append("is-compressed"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
822 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
823 if (info.GetUncompressedMD5() != "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
824 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
825 operations.append("md5"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
826 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
827 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
828 operations.append("size"); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
829 operations.append("uncompress"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
830 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
831 if (info.GetCompressedMD5() != "" && |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
832 info.GetUncompressedMD5() != "") |
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 operations.append("verify-md5"); |
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 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
837 call.GetOutput().AnswerJson(operations); |
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 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
841 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
842 template <int uncompress> |
974 | 843 static void GetAttachmentData(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
844 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
845 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
846 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
847 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
848 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
849 std::string publicId = call.GetUriComponent("id", ""); |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
850 FileContentType type = StringToContentType(call.GetUriComponent("name", "")); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
851 |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
852 if (uncompress) |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
853 { |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
854 context.AnswerAttachment(call.GetOutput(), publicId, type); |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
855 } |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
856 else |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
857 { |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
858 // Return the raw data (possibly compressed), as stored on the filesystem |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
859 std::string content; |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
860 context.ReadAttachment(content, publicId, type, false); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
861 call.GetOutput().AnswerBuffer(content, MimeType_Binary); |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
862 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
863 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
864 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
865 |
974 | 866 static void GetAttachmentSize(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
867 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
868 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
869 if (GetAttachmentInfo(info, call)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
870 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
871 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetUncompressedSize()), MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
872 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
873 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
874 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
875 |
974 | 876 static void GetAttachmentCompressedSize(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
877 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
878 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
879 if (GetAttachmentInfo(info, call)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
880 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
881 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetCompressedSize()), MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
882 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
883 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
884 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
885 |
974 | 886 static void GetAttachmentMD5(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
887 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
888 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
889 if (GetAttachmentInfo(info, call) && |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
890 info.GetUncompressedMD5() != "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
891 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
892 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetUncompressedMD5()), MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
893 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
894 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
895 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
896 |
974 | 897 static void GetAttachmentCompressedMD5(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
898 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
899 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
900 if (GetAttachmentInfo(info, call) && |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
901 info.GetCompressedMD5() != "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
902 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
903 call.GetOutput().AnswerBuffer(boost::lexical_cast<std::string>(info.GetCompressedMD5()), MimeType_PlainText); |
751
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 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
906 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 |
974 | 908 static void VerifyAttachment(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
909 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
910 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
911 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
912 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
913 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
914 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
915 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
916 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
917 if (!GetAttachmentInfo(info, call) || |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
918 info.GetCompressedMD5() == "" || |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 info.GetUncompressedMD5() == "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
920 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
921 // Inexistent resource, or no MD5 available |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
924 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
925 bool ok = false; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
926 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
927 // First check whether the compressed data is correctly stored in the disk |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
928 std::string data; |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
929 context.ReadAttachment(data, publicId, StringToContentType(name), false); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
930 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
931 std::string actualMD5; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
932 Toolbox::ComputeMD5(actualMD5, data); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
933 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
934 if (actualMD5 == info.GetCompressedMD5()) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
935 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
936 // The compressed data is OK. If a compression algorithm was |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
937 // applied to it, now check the MD5 of the uncompressed data. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
938 if (info.GetCompressionType() == CompressionType_None) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
939 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
940 ok = true; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
941 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
942 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
943 { |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
944 context.ReadAttachment(data, publicId, StringToContentType(name), true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
945 Toolbox::ComputeMD5(actualMD5, data); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
946 ok = (actualMD5 == info.GetUncompressedMD5()); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
947 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
948 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
949 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
950 if (ok) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
951 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
952 LOG(INFO) << "The attachment " << name << " of resource " << publicId << " has the right MD5"; |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
953 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
954 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
955 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
956 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
957 LOG(INFO) << "The attachment " << name << " of resource " << publicId << " has bad MD5!"; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
958 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
959 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
960 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
961 |
974 | 962 static void UploadAttachment(RestApiPutCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
963 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
964 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
965 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
966 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
967 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
968 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
969 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
970 FileContentType contentType = StringToContentType(name); |
1773
613df4362575
New UpdatedAttachment and UpdatedMetadata events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1759
diff
changeset
|
971 if (IsUserContentType(contentType) && // It is forbidden to modify internal attachments |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
972 context.AddAttachment(publicId, StringToContentType(name), call.GetBodyData(), call.GetBodySize())) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
973 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
974 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
975 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
976 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
977 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
978 call.GetOutput().SignalError(HttpStatus_403_Forbidden); |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
979 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
980 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
981 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
982 |
974 | 983 static void DeleteAttachment(RestApiDeleteCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
984 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
985 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
986 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
987 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
988 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
989 FileContentType contentType = StringToContentType(name); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
990 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
991 bool allowed; |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
992 if (IsUserContentType(contentType)) |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
993 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
994 allowed = true; |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
995 } |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
996 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
997 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
998 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
999 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1000 if (lock.GetConfiguration().GetBooleanParameter("StoreDicom", true) && |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1001 contentType == FileContentType_DicomAsJson) |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1002 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1003 allowed = true; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1004 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1005 else |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1006 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1007 // It is forbidden to delete internal attachments, except for |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1008 // the "DICOM as JSON" summary as of Orthanc 1.2.0 (this summary |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1009 // would be automatically reconstructed on the next GET call) |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1010 allowed = false; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1011 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1012 } |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1013 |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1014 if (allowed) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1015 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1016 OrthancRestApi::GetIndex(call).DeleteAttachment(publicId, contentType); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1017 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1018 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1019 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1020 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1021 call.GetOutput().SignalError(HttpStatus_403_Forbidden); |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1022 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1023 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1024 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1025 |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1026 template <enum CompressionType compression> |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1027 static void ChangeAttachmentCompression(RestApiPostCall& call) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1028 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1029 CheckValidResourceType(call); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1030 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1031 std::string publicId = call.GetUriComponent("id", ""); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1032 std::string name = call.GetUriComponent("name", ""); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1033 FileContentType contentType = StringToContentType(name); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1034 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1035 OrthancRestApi::GetContext(call).ChangeAttachmentCompression(publicId, contentType, compression); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1036 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1037 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1038 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1039 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1040 static void IsAttachmentCompressed(RestApiGetCall& call) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1041 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1042 FileInfo info; |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1043 if (GetAttachmentInfo(info, call)) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1044 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1045 std::string answer = (info.GetCompressionType() == CompressionType_None) ? "0" : "1"; |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1046 call.GetOutput().AnswerBuffer(answer, MimeType_PlainText); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1047 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1048 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1049 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1050 |
782 | 1051 // Raw access to the DICOM tags of an instance ------------------------------ |
1052 | |
974 | 1053 static void GetRawContent(RestApiGetCall& call) |
782 | 1054 { |
1055 std::string id = call.GetUriComponent("id", ""); | |
1056 | |
1057 ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id); | |
1058 | |
1059 locker.GetDicom().SendPathValue(call.GetOutput(), call.GetTrailingUri()); | |
1060 } | |
1061 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1062 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1063 |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1064 static bool ExtractSharedTags(Json::Value& shared, |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1065 ServerContext& context, |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1066 const std::string& publicId) |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1067 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1068 // Retrieve all the instances of this patient/study/series |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1069 typedef std::list<std::string> Instances; |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1070 Instances instances; |
959
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1071 context.GetIndex().GetChildInstances(instances, publicId); // (*) |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1072 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1073 // Loop over the instances |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1074 bool isFirst = true; |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1075 shared = Json::objectValue; |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1076 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1077 for (Instances::const_iterator it = instances.begin(); |
1303 | 1078 it != instances.end(); ++it) |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1079 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1080 // Get the tags of the current instance, in the simplified format |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1081 Json::Value tags; |
959
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1082 |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1083 try |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1084 { |
2124 | 1085 context.ReadDicomAsJson(tags, *it); |
959
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1086 } |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1087 catch (OrthancException&) |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1088 { |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1089 // Race condition: This instance has been removed since |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1090 // (*). Ignore this instance. |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1091 continue; |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1092 } |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1093 |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1094 if (tags.type() != Json::objectValue) |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1095 { |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1096 return false; // Error |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1097 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1098 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1099 // Only keep the tags that are mapped to a string |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1100 Json::Value::Members members = tags.getMemberNames(); |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1101 for (size_t i = 0; i < members.size(); i++) |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1102 { |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1103 const Json::Value& tag = tags[members[i]]; |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1104 if (tag.type() != Json::objectValue || |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1105 tag["Type"].type() != Json::stringValue || |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1106 tag["Type"].asString() != "String") |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1107 { |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1108 tags.removeMember(members[i]); |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1109 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1110 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1111 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1112 if (isFirst) |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1113 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1114 // This is the first instance, keep its tags as such |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1115 shared = tags; |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1116 isFirst = false; |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1117 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1118 else |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1119 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1120 // Loop over all the members of the shared tags extracted so |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1121 // far. If the value of one of these tags does not match its |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1122 // value in the current instance, remove it. |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1123 members = shared.getMemberNames(); |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1124 for (size_t i = 0; i < members.size(); i++) |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1125 { |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1126 if (!tags.isMember(members[i]) || |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1127 tags[members[i]]["Value"].asString() != shared[members[i]]["Value"].asString()) |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1128 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1129 shared.removeMember(members[i]); |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1130 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1131 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1132 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1133 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1134 |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1135 return true; |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1136 } |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1137 |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1138 |
974 | 1139 static void GetSharedTags(RestApiGetCall& call) |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1140 { |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1141 ServerContext& context = OrthancRestApi::GetContext(call); |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1142 std::string publicId = call.GetUriComponent("id", ""); |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1143 |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1144 Json::Value sharedTags; |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1145 if (ExtractSharedTags(sharedTags, context, publicId)) |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1146 { |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1147 // Success: Send the value of the shared tags |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1148 AnswerDicomAsJson(call, sharedTags); |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1149 } |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1150 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1151 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1152 |
1054
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1153 static void GetModuleInternal(RestApiGetCall& call, |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1154 ResourceType resourceType, |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1155 DicomModule module) |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1156 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1157 if (!((resourceType == ResourceType_Patient && module == DicomModule_Patient) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1158 (resourceType == ResourceType_Study && module == DicomModule_Patient) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1159 (resourceType == ResourceType_Study && module == DicomModule_Study) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1160 (resourceType == ResourceType_Series && module == DicomModule_Series) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1161 (resourceType == ResourceType_Instance && module == DicomModule_Instance) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1162 (resourceType == ResourceType_Instance && module == DicomModule_Image))) |
1054
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1163 { |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1164 throw OrthancException(ErrorCode_NotImplemented); |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1165 } |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1166 |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1167 ServerContext& context = OrthancRestApi::GetContext(call); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1168 std::string publicId = call.GetUriComponent("id", ""); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1169 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1170 std::set<DicomTag> ignoreTagLength; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1171 ParseSetOfTags(ignoreTagLength, call, "ignore-length"); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1172 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1173 typedef std::set<DicomTag> ModuleTags; |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1174 ModuleTags moduleTags; |
1368 | 1175 DicomTag::AddTagsForModule(moduleTags, module); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1176 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1177 Json::Value tags; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1178 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1179 if (resourceType != ResourceType_Instance) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1180 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1181 // Retrieve all the instances of this patient/study/series |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1182 typedef std::list<std::string> Instances; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1183 Instances instances; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1184 context.GetIndex().GetChildInstances(instances, publicId); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1185 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1186 if (instances.empty()) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1187 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1188 return; // Error: No instance (should never happen) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1189 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1190 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1191 // Select one child instance |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1192 publicId = instances.front(); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1193 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1194 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1195 context.ReadDicomAsJson(tags, publicId, ignoreTagLength); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1196 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1197 // Filter the tags of the instance according to the module |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1198 Json::Value result = Json::objectValue; |
1303 | 1199 for (ModuleTags::const_iterator tag = moduleTags.begin(); tag != moduleTags.end(); ++tag) |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1200 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1201 std::string s = tag->Format(); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1202 if (tags.isMember(s)) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1203 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1204 result[s] = tags[s]; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1205 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1206 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1207 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1208 AnswerDicomAsJson(call, result); |
1054
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1209 } |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1210 |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1211 |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1212 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1213 template <enum ResourceType resourceType, |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1214 enum DicomModule module> |
1054
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1215 static void GetModule(RestApiGetCall& call) |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1216 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1217 GetModuleInternal(call, resourceType, module); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1218 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1219 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1220 |
1722 | 1221 namespace |
1222 { | |
1223 typedef std::list< std::pair<ResourceType, std::string> > LookupResults; | |
1224 } | |
1225 | |
1226 | |
1227 static void AccumulateLookupResults(LookupResults& result, | |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1228 ServerIndex& index, |
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1229 const DicomTag& tag, |
1719
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1230 const std::string& value, |
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1231 ResourceType level) |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1232 { |
3034
54e422fe31ce
moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3033
diff
changeset
|
1233 std::vector<std::string> tmp; |
1728
4941494b5dd8
rename LookupIdentifier as LookupIdentifierExact
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1727
diff
changeset
|
1234 index.LookupIdentifierExact(tmp, level, tag, value); |
1719
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1235 |
3034
54e422fe31ce
moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3033
diff
changeset
|
1236 for (size_t i = 0; i < tmp.size(); i++) |
1719
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1237 { |
3034
54e422fe31ce
moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3033
diff
changeset
|
1238 result.push_back(std::make_pair(level, tmp[i])); |
1719
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1239 } |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1240 } |
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1241 |
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1242 |
1139
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1243 static void Lookup(RestApiPostCall& call) |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1244 { |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
1245 std::string tag; |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
1246 call.BodyToString(tag); |
1139
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1247 |
1722 | 1248 LookupResults resources; |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1249 ServerIndex& index = OrthancRestApi::GetIndex(call); |
1719
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1250 AccumulateLookupResults(resources, index, DICOM_TAG_PATIENT_ID, tag, ResourceType_Patient); |
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1251 AccumulateLookupResults(resources, index, DICOM_TAG_STUDY_INSTANCE_UID, tag, ResourceType_Study); |
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1252 AccumulateLookupResults(resources, index, DICOM_TAG_SERIES_INSTANCE_UID, tag, ResourceType_Series); |
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1253 AccumulateLookupResults(resources, index, DICOM_TAG_SOP_INSTANCE_UID, tag, ResourceType_Instance); |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1254 |
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1255 Json::Value result = Json::arrayValue; |
1722 | 1256 for (LookupResults::const_iterator |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1257 it = resources.begin(); it != resources.end(); ++it) |
1139
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1258 { |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1259 ResourceType type = it->first; |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1260 const std::string& id = it->second; |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1261 |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1262 Json::Value item = Json::objectValue; |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1263 item["Type"] = EnumerationToString(type); |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1264 item["ID"] = id; |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1265 item["Path"] = GetBasePath(type, id); |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1266 |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1267 result.append(item); |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1268 } |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1269 |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1270 call.GetOutput().AnswerJson(result); |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1271 } |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1272 |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1273 |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1274 namespace |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1275 { |
3021
2cbafb5d5a62
renamed LookupResource::IVisitor as ServerContext::ILookupVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1276 class FindVisitor : public ServerContext::ILookupVisitor |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1277 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1278 private: |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1279 bool isComplete_; |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1280 std::list<std::string> resources_; |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1281 |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1282 public: |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1283 FindVisitor() : |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1284 isComplete_(false) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1285 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1286 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1287 |
3012
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3003
diff
changeset
|
1288 virtual bool IsDicomAsJsonNeeded() const |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3003
diff
changeset
|
1289 { |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3003
diff
changeset
|
1290 return false; // (*) |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3003
diff
changeset
|
1291 } |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3003
diff
changeset
|
1292 |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1293 virtual void MarkAsComplete() |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1294 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1295 isComplete_ = true; // Unused information as of Orthanc 1.5.0 |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1296 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1297 |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1298 virtual void Visit(const std::string& publicId, |
3012
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3003
diff
changeset
|
1299 const std::string& instanceId /* unused */, |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3003
diff
changeset
|
1300 const DicomMap& mainDicomTags /* unused */, |
af1530b45290
Optimization: On finds, do not read JSON (disk) if main DICOM tags (DB) are sufficient
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3003
diff
changeset
|
1301 const Json::Value* dicomAsJson /* unused (*) */) |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1302 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1303 resources_.push_back(publicId); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1304 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1305 |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1306 void Answer(RestApiOutput& output, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1307 ServerIndex& index, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1308 ResourceType level, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1309 bool expand) const |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1310 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1311 AnswerListOfResources(output, index, resources_, level, expand); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1312 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1313 }; |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1314 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1315 |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1316 |
1354 | 1317 static void Find(RestApiPostCall& call) |
1318 { | |
2998 | 1319 static const char* const KEY_CASE_SENSITIVE = "CaseSensitive"; |
1320 static const char* const KEY_EXPAND = "Expand"; | |
1321 static const char* const KEY_LEVEL = "Level"; | |
1322 static const char* const KEY_LIMIT = "Limit"; | |
1323 static const char* const KEY_QUERY = "Query"; | |
1324 static const char* const KEY_SINCE = "Since"; | |
1325 | |
1358 | 1326 ServerContext& context = OrthancRestApi::GetContext(call); |
1354 | 1327 |
1328 Json::Value request; | |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1329 if (!call.ParseJsonRequest(request) || |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1330 request.type() != Json::objectValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1331 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1332 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1333 "The body must contain a JSON object"); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1334 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1335 else if (!request.isMember(KEY_LEVEL) || |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1336 request[KEY_LEVEL].type() != Json::stringValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1337 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1338 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1339 "Field \"" + std::string(KEY_LEVEL) + "\" is missing, or should be a string"); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1340 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1341 else if (!request.isMember(KEY_QUERY) && |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1342 request[KEY_QUERY].type() != Json::objectValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1343 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1344 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1345 "Field \"" + std::string(KEY_QUERY) + "\" is missing, or should be a JSON object"); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1346 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1347 else if (request.isMember(KEY_CASE_SENSITIVE) && |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1348 request[KEY_CASE_SENSITIVE].type() != Json::booleanValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1349 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1350 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1351 "Field \"" + std::string(KEY_CASE_SENSITIVE) + "\" should be a Boolean"); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1352 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1353 else if (request.isMember(KEY_LIMIT) && |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1354 request[KEY_LIMIT].type() != Json::intValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1355 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1356 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1357 "Field \"" + std::string(KEY_LIMIT) + "\" should be an integer"); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1358 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1359 else if (request.isMember(KEY_SINCE) && |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1360 request[KEY_SINCE].type() != Json::intValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1361 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1362 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1363 "Field \"" + std::string(KEY_SINCE) + "\" should be an integer"); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1364 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1365 else |
1354 | 1366 { |
1367 bool expand = false; | |
2998 | 1368 if (request.isMember(KEY_EXPAND)) |
1354 | 1369 { |
2998 | 1370 expand = request[KEY_EXPAND].asBool(); |
1354 | 1371 } |
1372 | |
1374
a1745d9be6e9
CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
1373 bool caseSensitive = false; |
2998 | 1374 if (request.isMember(KEY_CASE_SENSITIVE)) |
1374
a1745d9be6e9
CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
1375 { |
2998 | 1376 caseSensitive = request[KEY_CASE_SENSITIVE].asBool(); |
1374
a1745d9be6e9
CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
1377 } |
a1745d9be6e9
CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
1378 |
1758 | 1379 size_t limit = 0; |
2998 | 1380 if (request.isMember(KEY_LIMIT)) |
1758 | 1381 { |
2998 | 1382 int tmp = request[KEY_LIMIT].asInt(); |
1847 | 1383 if (tmp < 0) |
1758 | 1384 { |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1385 throw OrthancException(ErrorCode_ParameterOutOfRange, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1386 "Field \"" + std::string(KEY_LIMIT) + "\" should be a positive integer"); |
1758 | 1387 } |
1847 | 1388 |
1389 limit = static_cast<size_t>(tmp); | |
1758 | 1390 } |
1391 | |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1392 size_t since = 0; |
2998 | 1393 if (request.isMember(KEY_SINCE)) |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1394 { |
2998 | 1395 int tmp = request[KEY_SINCE].asInt(); |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1396 if (tmp < 0) |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1397 { |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1398 throw OrthancException(ErrorCode_ParameterOutOfRange, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1399 "Field \"" + std::string(KEY_SINCE) + "\" should be a positive integer"); |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1400 } |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1401 |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1402 since = static_cast<size_t>(tmp); |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1403 } |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1404 |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1405 ResourceType level = StringToResourceType(request[KEY_LEVEL].asCString()); |
1360 | 1406 |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1407 DatabaseLookup query; |
1358 | 1408 |
2998 | 1409 Json::Value::Members members = request[KEY_QUERY].getMemberNames(); |
1354 | 1410 for (size_t i = 0; i < members.size(); i++) |
1411 { | |
2998 | 1412 if (request[KEY_QUERY][members[i]].type() != Json::stringValue) |
1354 | 1413 { |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1414 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1415 "Tag \"" + members[i] + "\" should be associated with a string"); |
1354 | 1416 } |
1417 | |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1418 query.AddRestConstraint(FromDcmtkBridge::ParseTag(members[i]), |
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1419 request[KEY_QUERY][members[i]].asString(), |
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1420 caseSensitive, true); |
1361
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
1421 } |
2876 | 1422 |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1423 FindVisitor visitor; |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1424 context.Apply(visitor, query, level, since, limit); |
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1425 visitor.Answer(call.GetOutput(), context.GetIndex(), level, expand); |
1354 | 1426 } |
1427 } | |
1428 | |
1429 | |
1140
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1430 template <enum ResourceType start, |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1431 enum ResourceType end> |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1432 static void GetChildResources(RestApiGetCall& call) |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1433 { |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1434 ServerIndex& index = OrthancRestApi::GetIndex(call); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1435 |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1436 std::list<std::string> a, b, c; |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1437 a.push_back(call.GetUriComponent("id", "")); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1438 |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1439 ResourceType type = start; |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1440 while (type != end) |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1441 { |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1442 b.clear(); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1443 |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1444 for (std::list<std::string>::const_iterator |
1303 | 1445 it = a.begin(); it != a.end(); ++it) |
1140
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1446 { |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1447 index.GetChildren(c, *it); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1448 b.splice(b.begin(), c); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1449 } |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1450 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1451 type = GetChildResourceType(type); |
1140
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1452 |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1453 a.clear(); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1454 a.splice(a.begin(), b); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1455 } |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1456 |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1457 Json::Value result = Json::arrayValue; |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1458 |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1459 for (std::list<std::string>::const_iterator |
1303 | 1460 it = a.begin(); it != a.end(); ++it) |
1140
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1461 { |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1462 Json::Value item; |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1463 |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1464 if (OrthancRestApi::GetIndex(call).LookupResource(item, *it, end)) |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1465 { |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1466 result.append(item); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1467 } |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1468 } |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1469 |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1470 call.GetOutput().AnswerJson(result); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1471 } |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1472 |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1473 |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1474 static void GetChildInstancesTags(RestApiGetCall& call) |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1475 { |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1476 ServerContext& context = OrthancRestApi::GetContext(call); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1477 std::string publicId = call.GetUriComponent("id", ""); |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1478 DicomToJsonFormat format = GetDicomFormat(call); |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1479 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1480 std::set<DicomTag> ignoreTagLength; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1481 ParseSetOfTags(ignoreTagLength, call, "ignore-length"); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1482 |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1483 // Retrieve all the instances of this patient/study/series |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1484 typedef std::list<std::string> Instances; |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1485 Instances instances; |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1486 |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1487 context.GetIndex().GetChildInstances(instances, publicId); // (*) |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1488 |
1201
09aa7c126be9
URIs 'instance-tags' now indexed by the instance IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1172
diff
changeset
|
1489 Json::Value result = Json::objectValue; |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1490 |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1491 for (Instances::const_iterator it = instances.begin(); |
1303 | 1492 it != instances.end(); ++it) |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1493 { |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1494 Json::Value full; |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1495 context.ReadDicomAsJson(full, *it, ignoreTagLength); |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1496 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1497 if (format != DicomToJsonFormat_Full) |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1498 { |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1499 Json::Value simplified; |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1500 ServerToolbox::SimplifyTags(simplified, full, format); |
1201
09aa7c126be9
URIs 'instance-tags' now indexed by the instance IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1172
diff
changeset
|
1501 result[*it] = simplified; |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1502 } |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1503 else |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1504 { |
1201
09aa7c126be9
URIs 'instance-tags' now indexed by the instance IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1172
diff
changeset
|
1505 result[*it] = full; |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1506 } |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1507 } |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1508 |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1509 call.GetOutput().AnswerJson(result); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1510 } |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1511 |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1512 |
1140
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1513 |
1281
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1514 template <enum ResourceType start, |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1515 enum ResourceType end> |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1516 static void GetParentResource(RestApiGetCall& call) |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1517 { |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1518 assert(start > end); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1519 |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1520 ServerIndex& index = OrthancRestApi::GetIndex(call); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1521 |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1522 std::string current = call.GetUriComponent("id", ""); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1523 ResourceType currentType = start; |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1524 while (currentType > end) |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1525 { |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1526 std::string parent; |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1527 if (!index.LookupParent(parent, current)) |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1528 { |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1529 // Error that could happen if the resource gets deleted by |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1530 // another concurrent call |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1531 return; |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1532 } |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1533 |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1534 current = parent; |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1535 currentType = GetParentResourceType(currentType); |
1281
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1536 } |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1537 |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1538 assert(currentType == end); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1539 |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1540 Json::Value result; |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1541 if (index.LookupResource(result, current, end)) |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1542 { |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1543 call.GetOutput().AnswerJson(result); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1544 } |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1545 } |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1546 |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1547 |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1548 static void ExtractPdf(RestApiGetCall& call) |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1549 { |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1550 const std::string id = call.GetUriComponent("id", ""); |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1551 |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1552 std::string pdf; |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1553 ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id); |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1554 |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1555 if (locker.GetDicom().ExtractPdf(pdf)) |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1556 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1557 call.GetOutput().AnswerBuffer(pdf, MimeType_Pdf); |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1558 return; |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1559 } |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1560 } |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1561 |
1281
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1562 |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1563 static void OrderSlices(RestApiGetCall& call) |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1564 { |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1565 const std::string id = call.GetUriComponent("id", ""); |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1566 |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1567 ServerIndex& index = OrthancRestApi::GetIndex(call); |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1568 SliceOrdering ordering(index, id); |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1569 |
1703
b80e76dd1d56
ordered-slices continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1702
diff
changeset
|
1570 Json::Value result; |
b80e76dd1d56
ordered-slices continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1702
diff
changeset
|
1571 ordering.Format(result); |
b80e76dd1d56
ordered-slices continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1702
diff
changeset
|
1572 call.GetOutput().AnswerJson(result); |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1573 } |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1574 |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1575 |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1576 static void GetInstanceHeader(RestApiGetCall& call) |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1577 { |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1578 ServerContext& context = OrthancRestApi::GetContext(call); |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1579 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1580 std::string publicId = call.GetUriComponent("id", ""); |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1581 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1582 std::string dicomContent; |
2124 | 1583 context.ReadDicom(dicomContent, publicId); |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1584 |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2003
diff
changeset
|
1585 // TODO Consider using "DicomMap::ParseDicomMetaInformation()" to |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2003
diff
changeset
|
1586 // speed up things here |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2003
diff
changeset
|
1587 |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1588 ParsedDicomFile dicom(dicomContent); |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1589 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1590 Json::Value header; |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1591 dicom.HeaderToJson(header, DicomToJsonFormat_Full); |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1592 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1593 AnswerDicomAsJson(call, header); |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1594 } |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1595 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1596 |
2129
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1597 static void InvalidateTags(RestApiPostCall& call) |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1598 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1599 ServerIndex& index = OrthancRestApi::GetIndex(call); |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1600 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1601 // Loop over the instances, grouping them by parent studies so as |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1602 // to avoid large memory consumption |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1603 std::list<std::string> studies; |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1604 index.GetAllUuids(studies, ResourceType_Study); |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1605 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1606 for (std::list<std::string>::const_iterator |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1607 study = studies.begin(); study != studies.end(); ++study) |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1608 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1609 std::list<std::string> instances; |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1610 index.GetChildInstances(instances, *study); |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1611 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1612 for (std::list<std::string>::const_iterator |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1613 instance = instances.begin(); instance != instances.end(); ++instance) |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1614 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1615 index.DeleteAttachment(*instance, FileContentType_DicomAsJson); |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1616 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1617 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1618 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1619 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
2129
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1620 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1621 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1622 |
2209
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1623 template <enum ResourceType type> |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1624 static void ReconstructResource(RestApiPostCall& call) |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1625 { |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1626 ServerContext& context = OrthancRestApi::GetContext(call); |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1627 ServerToolbox::ReconstructResource(context, call.GetUriComponent("id", "")); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1628 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
2209
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1629 } |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1630 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1631 |
2804
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1632 static void ReconstructAllResources(RestApiPostCall& call) |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1633 { |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1634 ServerContext& context = OrthancRestApi::GetContext(call); |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1635 |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1636 std::list<std::string> studies; |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1637 context.GetIndex().GetAllUuids(studies, ResourceType_Study); |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1638 |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1639 for (std::list<std::string>::const_iterator |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1640 study = studies.begin(); study != studies.end(); ++study) |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1641 { |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1642 ServerToolbox::ReconstructResource(context, *study); |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1643 } |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1644 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1645 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
2804
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1646 } |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1647 |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1648 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1649 void OrthancRestApi::RegisterResources() |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1650 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1651 Register("/instances", ListResources<ResourceType_Instance>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1652 Register("/patients", ListResources<ResourceType_Patient>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1653 Register("/series", ListResources<ResourceType_Series>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1654 Register("/studies", ListResources<ResourceType_Study>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1655 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1656 Register("/instances/{id}", DeleteSingleResource<ResourceType_Instance>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1657 Register("/instances/{id}", GetSingleResource<ResourceType_Instance>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1658 Register("/patients/{id}", DeleteSingleResource<ResourceType_Patient>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1659 Register("/patients/{id}", GetSingleResource<ResourceType_Patient>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1660 Register("/series/{id}", DeleteSingleResource<ResourceType_Series>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1661 Register("/series/{id}", GetSingleResource<ResourceType_Series>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1662 Register("/studies/{id}", DeleteSingleResource<ResourceType_Study>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1663 Register("/studies/{id}", GetSingleResource<ResourceType_Study>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1664 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1665 Register("/instances/{id}/statistics", GetResourceStatistics); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1666 Register("/patients/{id}/statistics", GetResourceStatistics); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1667 Register("/studies/{id}/statistics", GetResourceStatistics); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1668 Register("/series/{id}/statistics", GetResourceStatistics); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1669 |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
1670 Register("/patients/{id}/shared-tags", GetSharedTags); |
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
1671 Register("/series/{id}/shared-tags", GetSharedTags); |
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
1672 Register("/studies/{id}/shared-tags", GetSharedTags); |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1673 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1674 Register("/instances/{id}/module", GetModule<ResourceType_Instance, DicomModule_Instance>); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1675 Register("/patients/{id}/module", GetModule<ResourceType_Patient, DicomModule_Patient>); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1676 Register("/series/{id}/module", GetModule<ResourceType_Series, DicomModule_Series>); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1677 Register("/studies/{id}/module", GetModule<ResourceType_Study, DicomModule_Study>); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1678 Register("/studies/{id}/module-patient", GetModule<ResourceType_Study, DicomModule_Patient>); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1679 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1680 Register("/instances/{id}/file", GetInstanceFile); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1681 Register("/instances/{id}/export", ExportInstanceFile); |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
1682 Register("/instances/{id}/tags", GetInstanceTagsBis); |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1683 Register("/instances/{id}/simplified-tags", GetInstanceTags<DicomToJsonFormat_Human>); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1684 Register("/instances/{id}/frames", ListFrames); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1685 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1686 Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1687 Register("/instances/{id}/frames/{frame}/image-uint8", GetImage<ImageExtractionMode_UInt8>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1688 Register("/instances/{id}/frames/{frame}/image-uint16", GetImage<ImageExtractionMode_UInt16>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1689 Register("/instances/{id}/frames/{frame}/image-int16", GetImage<ImageExtractionMode_Int16>); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
1690 Register("/instances/{id}/frames/{frame}/matlab", GetMatlabImage); |
2408
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1691 Register("/instances/{id}/frames/{frame}/raw", GetRawFrame<false>); |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1692 Register("/instances/{id}/frames/{frame}/raw.gz", GetRawFrame<true>); |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1693 Register("/instances/{id}/pdf", ExtractPdf); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1694 Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1695 Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1696 Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1697 Register("/instances/{id}/image-int16", GetImage<ImageExtractionMode_Int16>); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
1698 Register("/instances/{id}/matlab", GetMatlabImage); |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1699 Register("/instances/{id}/header", GetInstanceHeader); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1700 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1701 Register("/patients/{id}/protected", IsProtectedPatient); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1702 Register("/patients/{id}/protected", SetPatientProtection); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1703 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1704 Register("/{resourceType}/{id}/metadata", ListMetadata); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1705 Register("/{resourceType}/{id}/metadata/{name}", DeleteMetadata); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1706 Register("/{resourceType}/{id}/metadata/{name}", GetMetadata); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1707 Register("/{resourceType}/{id}/metadata/{name}", SetMetadata); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1708 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1709 Register("/{resourceType}/{id}/attachments", ListAttachments); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1710 Register("/{resourceType}/{id}/attachments/{name}", DeleteAttachment); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1711 Register("/{resourceType}/{id}/attachments/{name}", GetAttachmentOperations); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1712 Register("/{resourceType}/{id}/attachments/{name}", UploadAttachment); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1713 Register("/{resourceType}/{id}/attachments/{name}/compress", ChangeAttachmentCompression<CompressionType_ZlibWithSize>); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1714 Register("/{resourceType}/{id}/attachments/{name}/compressed-data", GetAttachmentData<0>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1715 Register("/{resourceType}/{id}/attachments/{name}/compressed-md5", GetAttachmentCompressedMD5); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1716 Register("/{resourceType}/{id}/attachments/{name}/compressed-size", GetAttachmentCompressedSize); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1717 Register("/{resourceType}/{id}/attachments/{name}/data", GetAttachmentData<1>); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1718 Register("/{resourceType}/{id}/attachments/{name}/is-compressed", IsAttachmentCompressed); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1719 Register("/{resourceType}/{id}/attachments/{name}/md5", GetAttachmentMD5); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1720 Register("/{resourceType}/{id}/attachments/{name}/size", GetAttachmentSize); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1721 Register("/{resourceType}/{id}/attachments/{name}/uncompress", ChangeAttachmentCompression<CompressionType_None>); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1722 Register("/{resourceType}/{id}/attachments/{name}/verify-md5", VerifyAttachment); |
782 | 1723 |
2129
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
1724 Register("/tools/invalidate-tags", InvalidateTags); |
1139
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1725 Register("/tools/lookup", Lookup); |
1354 | 1726 Register("/tools/find", Find); |
1139
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1727 |
1140
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1728 Register("/patients/{id}/studies", GetChildResources<ResourceType_Patient, ResourceType_Study>); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1729 Register("/patients/{id}/series", GetChildResources<ResourceType_Patient, ResourceType_Series>); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1730 Register("/patients/{id}/instances", GetChildResources<ResourceType_Patient, ResourceType_Instance>); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1731 Register("/studies/{id}/series", GetChildResources<ResourceType_Study, ResourceType_Series>); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1732 Register("/studies/{id}/instances", GetChildResources<ResourceType_Study, ResourceType_Instance>); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1733 Register("/series/{id}/instances", GetChildResources<ResourceType_Series, ResourceType_Instance>); |
94c5f6623b3a
URIs to get all the children of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1139
diff
changeset
|
1734 |
1281
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1735 Register("/studies/{id}/patient", GetParentResource<ResourceType_Study, ResourceType_Patient>); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1736 Register("/series/{id}/patient", GetParentResource<ResourceType_Series, ResourceType_Patient>); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1737 Register("/series/{id}/study", GetParentResource<ResourceType_Series, ResourceType_Study>); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1738 Register("/instances/{id}/patient", GetParentResource<ResourceType_Instance, ResourceType_Patient>); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1739 Register("/instances/{id}/study", GetParentResource<ResourceType_Instance, ResourceType_Study>); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1740 Register("/instances/{id}/series", GetParentResource<ResourceType_Instance, ResourceType_Series>); |
8dac11c78d71
URIs to get all the parents of a given resource in a single REST call
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1276
diff
changeset
|
1741 |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1742 Register("/patients/{id}/instances-tags", GetChildInstancesTags); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1743 Register("/studies/{id}/instances-tags", GetChildInstancesTags); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1744 Register("/series/{id}/instances-tags", GetChildInstancesTags); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1745 |
782 | 1746 Register("/instances/{id}/content/*", GetRawContent); |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1747 |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1748 Register("/series/{id}/ordered-slices", OrderSlices); |
2209
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1749 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1750 Register("/patients/{id}/reconstruct", ReconstructResource<ResourceType_Patient>); |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1751 Register("/studies/{id}/reconstruct", ReconstructResource<ResourceType_Study>); |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1752 Register("/series/{id}/reconstruct", ReconstructResource<ResourceType_Series>); |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
1753 Register("/instances/{id}/reconstruct", ReconstructResource<ResourceType_Instance>); |
2804
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
1754 Register("/tools/reconstruct", ReconstructAllResources); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1755 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1756 } |