Mercurial > hg > orthanc
annotate OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 3851:6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 20 Apr 2020 16:46:44 +0200 |
parents | 09f091b6b569 |
children | 2910b0d30fe0 |
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 |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3601
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU General Public License as |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * published by the Free Software Foundation, either version 3 of the |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * License, or (at your option) any later version. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * program give permission to link the code of its release with the |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * in the program, then also delete it here. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * This program is distributed in the hope that it will be useful, but |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * General Public License for more details. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * You should have received a copy of the GNU General Public License |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 **/ |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
34 #include "../PrecompiledHeadersServer.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 #include "OrthancRestApi.h" |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
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" |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
38 #include "../../Core/DicomFormat/DicomImageInformation.h" |
3203
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
39 #include "../../Core/DicomParsing/DicomWebJsonVisitor.h" |
2408
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
40 #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
|
41 #include "../../Core/DicomParsing/Internals/DicomImageDecoder.h" |
2131 | 42 #include "../../Core/HttpServer/HttpContentNegociation.h" |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
43 #include "../../Core/Images/Image.h" |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
44 #include "../../Core/Images/ImageProcessing.h" |
1486
f967bdf8534e
refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1446
diff
changeset
|
45 #include "../../Core/Logging.h" |
3048
8b331be57606
fix build without plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3021
diff
changeset
|
46 #include "../DefaultDicomImageDecoder.h" |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
47 #include "../OrthancConfiguration.h" |
3094
61da3c9b4121
cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
48 #include "../Search/DatabaseLookup.h" |
1437
02f5a3f5c0a0
access to the REST API from Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1385
diff
changeset
|
49 #include "../ServerContext.h" |
2131 | 50 #include "../ServerToolbox.h" |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
51 #include "../SliceOrdering.h" |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
3085 | 53 #include "../../Plugins/Engine/OrthancPlugins.h" |
54 | |
3687 | 55 // This "include" is mandatory for Release builds using Linux Standard Base |
56 #include <boost/math/special_functions/round.hpp> | |
57 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 namespace Orthanc |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
61 static void AnswerDicomAsJson(RestApiCall& call, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
62 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
|
63 DicomToJsonFormat mode) |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
64 { |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
65 if (mode != DicomToJsonFormat_Full) |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
66 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
67 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
|
68 ServerToolbox::SimplifyTags(simplified, dicom, mode); |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
69 call.GetOutput().AnswerJson(simplified); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
70 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
71 else |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
72 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
73 call.GetOutput().AnswerJson(dicom); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
74 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
75 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
76 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
77 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
78 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
|
79 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
80 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
|
81 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
82 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
|
83 } |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
84 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
|
85 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
86 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
|
87 } |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
88 else |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
89 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
90 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
|
91 } |
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 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
95 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
|
96 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
|
97 { |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
98 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
|
99 } |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
100 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
101 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
102 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
|
103 const RestApiGetCall& call, |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
104 const std::string& 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 target.clear(); |
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 if (call.HasArgument(argument)) |
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 std::vector<std::string> tags; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
111 Toolbox::TokenizeString(tags, call.GetArgument(argument, ""), ','); |
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 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
|
114 { |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
115 target.insert(FromDcmtkBridge::ParseTag(tags[i])); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
116 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
117 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
118 } |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
119 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
120 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 // List all the patients, studies, series or instances ---------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 |
1354 | 123 static void AnswerListOfResources(RestApiOutput& output, |
124 ServerIndex& index, | |
125 const std::list<std::string>& resources, | |
126 ResourceType level, | |
127 bool expand) | |
128 { | |
129 Json::Value answer = Json::arrayValue; | |
130 | |
131 for (std::list<std::string>::const_iterator | |
1384 | 132 resource = resources.begin(); resource != resources.end(); ++resource) |
1354 | 133 { |
134 if (expand) | |
135 { | |
136 Json::Value item; | |
137 if (index.LookupResource(item, *resource, level)) | |
138 { | |
139 answer.append(item); | |
140 } | |
141 } | |
142 else | |
143 { | |
144 answer.append(*resource); | |
145 } | |
146 } | |
147 | |
148 output.AnswerJson(answer); | |
149 } | |
150 | |
151 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 template <enum ResourceType resourceType> |
974 | 153 static void ListResources(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 { |
1342
9ec7ac03152d
"?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1303
diff
changeset
|
155 ServerIndex& index = OrthancRestApi::GetIndex(call); |
9ec7ac03152d
"?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1303
diff
changeset
|
156 |
1354 | 157 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
|
158 |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
159 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
|
160 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
|
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("limit")) |
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 \"limit\" 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 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
|
170 { |
2955 | 171 throw OrthancException(ErrorCode_BadRequest, |
172 "Missing \"since\" argument for GET request against: " + | |
173 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
|
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 |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
176 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
|
177 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
|
178 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
|
179 } |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
180 else |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
181 { |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
182 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
|
183 } |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
184 |
1342
9ec7ac03152d
"?expand" flag for URIs "/patients", "/studies" and "/series"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1303
diff
changeset
|
185 |
1354 | 186 AnswerListOfResources(call.GetOutput(), index, result, resourceType, call.HasArgument("expand")); |
751
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 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 template <enum ResourceType resourceType> |
974 | 190 static void GetSingleResource(RestApiGetCall& call) |
751
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 Json::Value result; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 if (OrthancRestApi::GetIndex(call).LookupResource(result, call.GetUriComponent("id", ""), resourceType)) |
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 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 } |
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 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 template <enum ResourceType resourceType> |
974 | 200 static void DeleteSingleResource(RestApiDeleteCall& call) |
751
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 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
|
203 if (OrthancRestApi::GetContext(call).DeleteResource(result, call.GetUriComponent("id", ""), resourceType)) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
204 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 call.GetOutput().AnswerJson(result); |
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 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 // Get information about a single patient ----------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 |
974 | 212 static void IsProtectedPatient(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 bool isProtected = OrthancRestApi::GetIndex(call).IsProtectedPatient(publicId); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
216 call.GetOutput().AnswerBuffer(isProtected ? "1" : "0", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 |
974 | 220 static void SetPatientProtection(RestApiPutCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
226 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
|
227 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
|
228 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
|
229 |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
230 if (body == "0") |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 context.GetIndex().SetProtectedPatient(publicId, false); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
233 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 } |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
235 else if (body == "1") |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 context.GetIndex().SetProtectedPatient(publicId, true); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
238 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
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 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 // Bad request |
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 } |
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 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 // Get information about a single instance ---------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 |
974 | 249 static void GetInstanceFile(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 ServerContext& context = OrthancRestApi::GetContext(call); |
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 std::string publicId = call.GetUriComponent("id", ""); |
3203
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
254 |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
255 IHttpHandler::Arguments::const_iterator accept = call.GetHttpHeaders().find("accept"); |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
256 if (accept != call.GetHttpHeaders().end()) |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
257 { |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
258 // New in Orthanc 1.5.4 |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
259 try |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
260 { |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
261 MimeType mime = StringToMimeType(accept->second.c_str()); |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
262 |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
263 if (mime == MimeType_DicomWebJson || |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
264 mime == MimeType_DicomWebXml) |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
265 { |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
266 DicomWebJsonVisitor visitor; |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
267 |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
268 { |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
269 ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), publicId); |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
270 locker.GetDicom().Apply(visitor); |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
271 } |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
272 |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
273 if (mime == MimeType_DicomWebJson) |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
274 { |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
275 std::string s = visitor.GetResult().toStyledString(); |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
276 call.GetOutput().AnswerBuffer(s, MimeType_DicomWebJson); |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
277 } |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
278 else |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
279 { |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
280 std::string xml; |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
281 visitor.FormatXml(xml); |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
282 call.GetOutput().AnswerBuffer(xml, MimeType_DicomWebXml); |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
283 } |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
284 |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
285 return; |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
286 } |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
287 } |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
288 catch (OrthancException&) |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
289 { |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
290 } |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
291 } |
810772486249
URI "/instances/.../file" can return DICOMweb JSON or XML, depending on Accept header
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
292 |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
293 context.AnswerAttachment(call.GetOutput(), publicId, FileContentType_Dicom); |
751
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 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 |
974 | 297 static void ExportInstanceFile(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 std::string dicom; |
2124 | 304 context.ReadDicom(dicom, publicId); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
306 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
|
307 call.BodyToString(target); |
2140 | 308 SystemToolbox::WriteFile(dicom, target); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
310 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
314 template <DicomToJsonFormat format> |
974 | 315 static void GetInstanceTags(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 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
|
320 |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
321 std::set<DicomTag> ignoreTagLength; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
322 ParseSetOfTags(ignoreTagLength, call, "ignore-length"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
324 if (format != DicomToJsonFormat_Full || |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
325 !ignoreTagLength.empty()) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 { |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
327 Json::Value full; |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
328 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
|
329 AnswerDicomAsJson(call, full, format); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 { |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
333 // 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
|
334 // 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
|
335 // is present |
2127 | 336 std::string full; |
337 context.ReadDicomAsJson(full, publicId); | |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
338 call.GetOutput().AnswerBuffer(full, MimeType_Json); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
342 |
974 | 343 static void GetInstanceTagsBis(RestApiGetCall& call) |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
344 { |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
345 switch (GetDicomFormat(call)) |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
346 { |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
347 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
|
348 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
|
349 break; |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
350 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
351 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
|
352 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
|
353 break; |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
354 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
355 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
|
356 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
|
357 break; |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
358 |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
359 default: |
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
360 throw OrthancException(ErrorCode_InternalError); |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
361 } |
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
362 } |
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
363 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 |
974 | 365 static void ListFrames(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 { |
1950
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
367 std::string publicId = call.GetUriComponent("id", ""); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 |
1950
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
369 unsigned int numberOfFrames; |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
370 |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
371 { |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
372 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
|
373 numberOfFrames = locker.GetDicom().GetFramesCount(); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 } |
1950
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
375 |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
376 Json::Value result = Json::arrayValue; |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
377 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
|
378 { |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
379 result.append(i); |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
380 } |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
381 |
533ff46e944b
return a single raw frame from DICOM videos
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1929
diff
changeset
|
382 call.GetOutput().AnswerJson(result); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 |
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
|
386 namespace |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
387 { |
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
|
388 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
|
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 private: |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
391 std::unique_ptr<ImageAccessor>& image_; |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
392 ImageExtractionMode mode_; |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
393 bool invert_; |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
394 MimeType format_; |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
395 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
|
396 |
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 public: |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
398 ImageToEncode(std::unique_ptr<ImageAccessor>& image, |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
399 ImageExtractionMode mode, |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
400 bool invert) : |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
401 image_(image), |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
402 mode_(mode), |
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
403 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
|
404 { |
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
|
405 } |
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
|
406 |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
407 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
|
408 { |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
409 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
|
410 } |
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
|
411 |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
412 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
|
413 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
414 format_ = MimeType_Png; |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
415 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
|
416 } |
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
|
417 |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
418 void EncodeUsingPam() |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
419 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
420 format_ = MimeType_Pam; |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
421 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
|
422 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
423 |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
424 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
|
425 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
426 format_ = MimeType_Jpeg; |
2281
e002430baa41
Fix issue #44 (Bad interpretation of photometric interpretation MONOCHROME1)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
427 DicomImageDecoder::ExtractJpegImage(answer_, image_, mode_, invert_, quality); |
1824
b530c3dfe2a6
refactoring image decoding
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1784
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 }; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
430 |
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
|
431 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
|
432 { |
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 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
|
434 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
|
435 |
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
|
436 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
|
437 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
|
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 } |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
440 |
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 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
|
442 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
|
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 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
|
445 assert(subtype == "png"); |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
446 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
|
447 } |
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
|
448 }; |
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
|
449 |
2699
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
450 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
|
451 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
452 private: |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
453 ImageToEncode& image_; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
454 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
455 public: |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
456 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
|
457 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
458 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
459 |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
460 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
|
461 const std::string& subtype) |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
462 { |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
463 assert(type == "image"); |
2780 | 464 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
|
465 image_.EncodeUsingPam(); |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
466 } |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
467 }; |
52217dc47a4e
new image/pam MIME TYPE supported in /instances/../frames/../image-uint8... routes
am@osimis.io
parents:
2622
diff
changeset
|
468 |
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
|
469 class EncodeJpeg : public HttpContentNegociation::IHandler |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
470 { |
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
|
471 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
|
472 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
|
473 unsigned int quality_; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
474 |
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
|
475 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
|
476 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
|
477 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
|
478 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
|
479 { |
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
|
480 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
|
481 bool ok = false; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
482 |
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
|
483 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
|
484 { |
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
|
485 quality_ = boost::lexical_cast<unsigned int>(v); |
1847 | 486 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
|
487 } |
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
|
488 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
|
489 { |
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
|
490 } |
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
|
491 |
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
|
492 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
|
493 { |
2955 | 494 throw OrthancException( |
495 ErrorCode_BadRequest, | |
496 "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
|
497 } |
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
|
498 } |
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
|
499 |
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
|
500 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
|
501 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
|
502 { |
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
|
503 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
|
504 assert(subtype == "jpeg"); |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
505 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
|
506 } |
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
|
507 }; |
1781
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
508 } |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
509 |
5ad4e4d92ecb
AcceptMediaDispatcher bootstrap
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1773
diff
changeset
|
510 |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
511 namespace |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3203
diff
changeset
|
512 { |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
513 class IDecodedFrameHandler : public boost::noncopyable |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
514 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
515 public: |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
516 virtual ~IDecodedFrameHandler() |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
517 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
518 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
519 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
520 virtual void Handle(RestApiGetCall& call, |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
521 std::unique_ptr<ImageAccessor>& decoded, |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
522 const DicomMap& dicom) = 0; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
523 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
524 virtual bool RequiresDicomTags() const = 0; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
525 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
526 static void Apply(RestApiGetCall& call, |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
527 IDecodedFrameHandler& handler) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
528 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
529 ServerContext& context = OrthancRestApi::GetContext(call); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
530 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
531 std::string frameId = call.GetUriComponent("frame", "0"); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
532 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
533 unsigned int frame; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
534 try |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
535 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
536 frame = boost::lexical_cast<unsigned int>(frameId); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
537 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
538 catch (boost::bad_lexical_cast&) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
539 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
540 return; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
541 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
542 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
543 DicomMap dicom; |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
544 std::unique_ptr<ImageAccessor> decoded; |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
545 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
546 try |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
547 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
548 std::string publicId = call.GetUriComponent("id", ""); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
549 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
550 #if ORTHANC_ENABLE_PLUGINS == 1 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
551 if (context.GetPlugins().HasCustomImageDecoder()) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
552 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
553 // TODO create a cache of file |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
554 std::string dicomContent; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
555 context.ReadDicom(dicomContent, publicId); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
556 decoded.reset(context.GetPlugins().DecodeUnsafe(dicomContent.c_str(), dicomContent.size(), frame)); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
557 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
558 /** |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
559 * Note that we call "DecodeUnsafe()": We do not fallback to |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
560 * the builtin decoder if no installed decoder plugin is able |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
561 * to decode the image. This allows us to take advantage of |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
562 * the cache below. |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
563 **/ |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
564 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
565 if (handler.RequiresDicomTags() && |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
566 decoded.get() != NULL) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
567 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
568 // TODO Optimize this lookup for photometric interpretation: |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
569 // It should be implemented by the plugin to avoid parsing |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
570 // twice the DICOM file |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
571 ParsedDicomFile parsed(dicomContent); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
572 parsed.ExtractDicomSummary(dicom); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
573 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
574 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
575 #endif |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
576 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
577 if (decoded.get() == NULL) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
578 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
579 // Use Orthanc's built-in decoder, using the cache to speed-up |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
580 // things on multi-frame images |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
581 ServerContext::DicomCacheLocker locker(context, publicId); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
582 decoded.reset(DicomImageDecoder::Decode(locker.GetDicom(), frame)); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
583 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
584 if (handler.RequiresDicomTags()) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
585 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
586 locker.GetDicom().ExtractDicomSummary(dicom); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
587 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
588 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
589 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
590 catch (OrthancException& e) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
591 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
592 if (e.GetErrorCode() == ErrorCode_ParameterOutOfRange || |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
593 e.GetErrorCode() == ErrorCode_UnknownResource) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
594 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
595 // The frame number is out of the range for this DICOM |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
596 // instance, the resource is not existent |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
597 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
598 else |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
599 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
600 std::string root = ""; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
601 for (size_t i = 1; i < call.GetFullUri().size(); i++) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
602 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
603 root += "../"; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
604 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
605 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
606 call.GetOutput().Redirect(root + "app/images/unsupported.png"); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
607 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
608 return; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
609 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
610 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
611 handler.Handle(call, decoded, dicom); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
612 } |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
613 |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
614 |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
615 static void DefaultHandler(RestApiGetCall& call, |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
616 std::unique_ptr<ImageAccessor>& decoded, |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
617 ImageExtractionMode mode, |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
618 bool invert) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
619 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
620 ImageToEncode image(decoded, mode, invert); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
621 |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
622 HttpContentNegociation negociation; |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
623 EncodePng png(image); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
624 negociation.Register(MIME_PNG, png); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
625 |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
626 EncodeJpeg jpeg(image, call); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
627 negociation.Register(MIME_JPEG, jpeg); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
628 |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
629 EncodePam pam(image); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
630 negociation.Register(MIME_PAM, pam); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
631 |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
632 if (negociation.Apply(call.GetHttpHeaders())) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
633 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
634 image.Answer(call.GetOutput()); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
635 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
636 } |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
637 }; |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3203
diff
changeset
|
638 |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3203
diff
changeset
|
639 |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
640 class GetImageHandler : public IDecodedFrameHandler |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
641 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
642 private: |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
643 ImageExtractionMode mode_; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
644 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
645 public: |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
646 GetImageHandler(ImageExtractionMode mode) : |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
647 mode_(mode) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
648 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
649 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
650 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
651 virtual void Handle(RestApiGetCall& call, |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
652 std::unique_ptr<ImageAccessor>& decoded, |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
653 const DicomMap& dicom) ORTHANC_OVERRIDE |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
654 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
655 bool invert = false; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
656 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
657 if (mode_ == ImageExtractionMode_Preview) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
658 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
659 DicomImageInformation info(dicom); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
660 invert = (info.GetPhotometricInterpretation() == PhotometricInterpretation_Monochrome1); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
661 } |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3203
diff
changeset
|
662 |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
663 DefaultHandler(call, decoded, mode_, invert); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
664 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
665 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
666 virtual bool RequiresDicomTags() const ORTHANC_OVERRIDE |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
667 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
668 return mode_ == ImageExtractionMode_Preview; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
669 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
670 }; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
671 |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3203
diff
changeset
|
672 |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
673 class RenderedFrameHandler : public IDecodedFrameHandler |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3203
diff
changeset
|
674 { |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
675 private: |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
676 static void GetDicomParameters(bool& invert, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
677 float& rescaleSlope, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
678 float& rescaleIntercept, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
679 float& windowWidth, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
680 float& windowCenter, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
681 const DicomMap& dicom) |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
682 { |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
683 DicomImageInformation info(dicom); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
684 |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
685 invert = (info.GetPhotometricInterpretation() == PhotometricInterpretation_Monochrome1); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
686 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
687 rescaleSlope = 1.0f; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
688 rescaleIntercept = 0.0f; |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
689 |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
690 if (dicom.HasTag(Orthanc::DICOM_TAG_RESCALE_SLOPE) && |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
691 dicom.HasTag(Orthanc::DICOM_TAG_RESCALE_INTERCEPT)) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
692 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
693 dicom.ParseFloat(rescaleSlope, Orthanc::DICOM_TAG_RESCALE_SLOPE); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
694 dicom.ParseFloat(rescaleIntercept, Orthanc::DICOM_TAG_RESCALE_INTERCEPT); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
695 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
696 |
3816
09f091b6b569
/rendered route: fix automatic windowing of files without windowing tags and RescaleSlope != 1
Alain Mazy <alain@mazy.be>
parents:
3712
diff
changeset
|
697 windowWidth = static_cast<float>(1 << info.GetBitsStored()) * rescaleSlope; |
09f091b6b569
/rendered route: fix automatic windowing of files without windowing tags and RescaleSlope != 1
Alain Mazy <alain@mazy.be>
parents:
3712
diff
changeset
|
698 windowCenter = windowWidth / 2.0f + rescaleIntercept; |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
699 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
700 if (dicom.HasTag(Orthanc::DICOM_TAG_WINDOW_CENTER) && |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
701 dicom.HasTag(Orthanc::DICOM_TAG_WINDOW_WIDTH)) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
702 { |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
703 dicom.ParseFirstFloat(windowCenter, Orthanc::DICOM_TAG_WINDOW_CENTER); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
704 dicom.ParseFirstFloat(windowWidth, Orthanc::DICOM_TAG_WINDOW_WIDTH); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
705 } |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
706 } |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
707 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
708 static void GetUserArguments(float& windowWidth /* inout */, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
709 float& windowCenter /* inout */, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
710 unsigned int& argWidth, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
711 unsigned int& argHeight, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
712 bool& smooth, |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
713 RestApiGetCall& call) |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
714 { |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
715 static const char* ARG_WINDOW_CENTER = "window-center"; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
716 static const char* ARG_WINDOW_WIDTH = "window-width"; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
717 static const char* ARG_WIDTH = "width"; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
718 static const char* ARG_HEIGHT = "height"; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
719 static const char* ARG_SMOOTH = "smooth"; |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3203
diff
changeset
|
720 |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
721 if (call.HasArgument(ARG_WINDOW_WIDTH)) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
722 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
723 try |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
724 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
725 windowWidth = boost::lexical_cast<float>(call.GetArgument(ARG_WINDOW_WIDTH, "")); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
726 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
727 catch (boost::bad_lexical_cast&) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
728 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
729 throw OrthancException(ErrorCode_ParameterOutOfRange, |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
730 "Bad value for argument: " + std::string(ARG_WINDOW_WIDTH)); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
731 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
732 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
733 |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
734 if (call.HasArgument(ARG_WINDOW_CENTER)) |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
735 { |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
736 try |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
737 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
738 windowCenter = boost::lexical_cast<float>(call.GetArgument(ARG_WINDOW_CENTER, "")); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
739 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
740 catch (boost::bad_lexical_cast&) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
741 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
742 throw OrthancException(ErrorCode_ParameterOutOfRange, |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
743 "Bad value for argument: " + std::string(ARG_WINDOW_CENTER)); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
744 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
745 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
746 |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
747 argWidth = 0; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
748 argHeight = 0; |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
749 |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
750 if (call.HasArgument(ARG_WIDTH)) |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
751 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
752 try |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
753 { |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
754 int tmp = boost::lexical_cast<int>(call.GetArgument(ARG_WIDTH, "")); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
755 if (tmp < 0) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
756 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
757 throw OrthancException(ErrorCode_ParameterOutOfRange, |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
758 "Argument cannot be negative: " + std::string(ARG_WIDTH)); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
759 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
760 else |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
761 { |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
762 argWidth = static_cast<unsigned int>(tmp); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
763 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
764 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
765 catch (boost::bad_lexical_cast&) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
766 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
767 throw OrthancException(ErrorCode_ParameterOutOfRange, |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
768 "Bad value for argument: " + std::string(ARG_WIDTH)); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
769 } |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
770 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
771 |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
772 if (call.HasArgument(ARG_HEIGHT)) |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
773 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
774 try |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
775 { |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
776 int tmp = boost::lexical_cast<int>(call.GetArgument(ARG_HEIGHT, "")); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
777 if (tmp < 0) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
778 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
779 throw OrthancException(ErrorCode_ParameterOutOfRange, |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
780 "Argument cannot be negative: " + std::string(ARG_HEIGHT)); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
781 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
782 else |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
783 { |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
784 argHeight = static_cast<unsigned int>(tmp); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
785 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
786 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
787 catch (boost::bad_lexical_cast&) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
788 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
789 throw OrthancException(ErrorCode_ParameterOutOfRange, |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
790 "Bad value for argument: " + std::string(ARG_HEIGHT)); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
791 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
792 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
793 |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
794 smooth = false; |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
795 |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
796 if (call.HasArgument(ARG_SMOOTH)) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
797 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
798 std::string value = call.GetArgument(ARG_SMOOTH, ""); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
799 if (value == "0" || |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
800 value == "false") |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
801 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
802 smooth = false; |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
803 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
804 else if (value == "1" || |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
805 value == "true") |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
806 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
807 smooth = true; |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
808 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
809 else |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
810 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
811 throw OrthancException(ErrorCode_ParameterOutOfRange, |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
812 "Argument must be Boolean: " + std::string(ARG_SMOOTH)); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
813 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
814 } |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
815 } |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
816 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
817 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
818 public: |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
819 virtual void Handle(RestApiGetCall& call, |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
820 std::unique_ptr<ImageAccessor>& decoded, |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
821 const DicomMap& dicom) ORTHANC_OVERRIDE |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
822 { |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
823 bool invert; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
824 float rescaleSlope, rescaleIntercept, windowWidth, windowCenter; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
825 GetDicomParameters(invert, rescaleSlope, rescaleIntercept, windowWidth, windowCenter, dicom); |
3686 | 826 |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
827 unsigned int argWidth, argHeight; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
828 bool smooth; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
829 GetUserArguments(windowWidth, windowCenter, argWidth, argHeight, smooth, call); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
830 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
831 unsigned int targetWidth = decoded->GetWidth(); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
832 unsigned int targetHeight = decoded->GetHeight(); |
3686 | 833 |
834 if (decoded->GetWidth() != 0 && | |
835 decoded->GetHeight() != 0) | |
836 { | |
837 float ratio = 1; | |
838 | |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
839 if (argWidth != 0 && |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
840 argHeight != 0) |
3686 | 841 { |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
842 float ratioX = static_cast<float>(argWidth) / static_cast<float>(decoded->GetWidth()); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
843 float ratioY = static_cast<float>(argHeight) / static_cast<float>(decoded->GetHeight()); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
844 ratio = std::min(ratioX, ratioY); |
3686 | 845 } |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
846 else if (argWidth != 0) |
3686 | 847 { |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
848 ratio = static_cast<float>(argWidth) / static_cast<float>(decoded->GetWidth()); |
3686 | 849 } |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
850 else if (argHeight != 0) |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
851 { |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
852 ratio = static_cast<float>(argHeight) / static_cast<float>(decoded->GetHeight()); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
853 } |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
854 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
855 targetWidth = boost::math::iround(ratio * static_cast<float>(decoded->GetWidth())); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
856 targetHeight = boost::math::iround(ratio * static_cast<float>(decoded->GetHeight())); |
3686 | 857 } |
858 | |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
859 if (decoded->GetFormat() == PixelFormat_RGB24) |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
860 { |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
861 if (targetWidth == decoded->GetWidth() && |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
862 targetHeight == decoded->GetHeight()) |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
863 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
864 DefaultHandler(call, decoded, ImageExtractionMode_Preview, false); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
865 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
866 else |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
867 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
868 std::unique_ptr<ImageAccessor> resized( |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
869 new Image(decoded->GetFormat(), targetWidth, targetHeight, false)); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
870 |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
871 if (smooth && |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
872 (targetWidth < decoded->GetWidth() || |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
873 targetHeight < decoded->GetHeight())) |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
874 { |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
875 ImageProcessing::SmoothGaussian5x5(*decoded); |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
876 } |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
877 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
878 ImageProcessing::Resize(*resized, *decoded); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
879 DefaultHandler(call, resized, ImageExtractionMode_Preview, false); |
3685
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
880 } |
2cc34837d694
rendering of RGB24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3683
diff
changeset
|
881 } |
3686 | 882 else |
883 { | |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
884 // Grayscale image: (1) convert to Float32, (2) apply |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
885 // windowing to get a Grayscale8, (3) possibly resize |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
886 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
887 Image converted(PixelFormat_Float32, decoded->GetWidth(), decoded->GetHeight(), false); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
888 ImageProcessing::Convert(converted, *decoded); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
889 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
890 // Avoid divisions by zero |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
891 if (windowWidth <= 1.0f) |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
892 { |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
893 windowWidth = 1; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
894 } |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
895 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
896 if (std::abs(rescaleSlope) <= 0.1f) |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
897 { |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
898 rescaleSlope = 0.1f; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
899 } |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
900 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
901 const float scaling = 255.0f * rescaleSlope / windowWidth; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
902 const float offset = (rescaleIntercept - windowCenter + windowWidth / 2.0f) / rescaleSlope; |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
903 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
904 std::unique_ptr<ImageAccessor> rescaled(new Image(PixelFormat_Grayscale8, decoded->GetWidth(), decoded->GetHeight(), false)); |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
905 ImageProcessing::ShiftScale(*rescaled, converted, offset, scaling, false); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
906 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
907 if (targetWidth == decoded->GetWidth() && |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
908 targetHeight == decoded->GetHeight()) |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
909 { |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
910 DefaultHandler(call, rescaled, ImageExtractionMode_UInt8, invert); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
911 } |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
912 else |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
913 { |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
914 std::unique_ptr<ImageAccessor> resized( |
3690
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
915 new Image(PixelFormat_Grayscale8, targetWidth, targetHeight, false)); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
916 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
917 if (smooth && |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
918 (targetWidth < decoded->GetWidth() || |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
919 targetHeight < decoded->GetHeight())) |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
920 { |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
921 ImageProcessing::SmoothGaussian5x5(*rescaled); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
922 } |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
923 |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
924 ImageProcessing::Resize(*resized, *rescaled); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
925 DefaultHandler(call, resized, ImageExtractionMode_UInt8, invert); |
a9ce35d67c3c
implementation of "/instances/.../rendered" for grayscale images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3687
diff
changeset
|
926 } |
3686 | 927 } |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
928 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
929 |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
930 virtual bool RequiresDicomTags() const ORTHANC_OVERRIDE |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
931 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
932 return true; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
933 } |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
934 }; |
3600
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3203
diff
changeset
|
935 } |
4066998150ef
/instances/{id}/preview route now takes the windowing into account
Alain Mazy <alain@mazy.be>
parents:
3203
diff
changeset
|
936 |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
937 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
938 template <enum ImageExtractionMode mode> |
974 | 939 static void GetImage(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
940 { |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
941 GetImageHandler handler(mode); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
942 IDecodedFrameHandler::Apply(call, handler); |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
943 } |
1906
d7c1cb559431
optimization for multi-frame images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1902
diff
changeset
|
944 |
1826
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
945 |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
946 static void GetRenderedFrame(RestApiGetCall& call) |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
947 { |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
948 RenderedFrameHandler handler; |
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
949 IDecodedFrameHandler::Apply(call, handler); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
950 } |
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 |
974 | 953 static void GetMatlabImage(RestApiGetCall& call) |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
954 { |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
955 ServerContext& context = OrthancRestApi::GetContext(call); |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
956 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
957 std::string frameId = call.GetUriComponent("frame", "0"); |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
958 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
959 unsigned int frame; |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
960 try |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
961 { |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
962 frame = boost::lexical_cast<unsigned int>(frameId); |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
963 } |
2836
7133ad478eea
fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2804
diff
changeset
|
964 catch (boost::bad_lexical_cast&) |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
965 { |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
966 return; |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
967 } |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
968 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
969 std::string publicId = call.GetUriComponent("id", ""); |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
970 std::string dicomContent; |
2124 | 971 context.ReadDicom(dicomContent, publicId); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
972 |
2136
dd609a99d39a
uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2131
diff
changeset
|
973 #if ORTHANC_ENABLE_PLUGINS == 1 |
1826
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
974 IDicomImageDecoder& decoder = context.GetPlugins(); |
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
975 #else |
1902
8b0ee8d5e6d0
Refactoring leading to speedups with custom image decoders
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
976 DefaultDicomImageDecoder decoder; // This is Orthanc's built-in decoder |
1826
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
977 #endif |
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
978 |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3690
diff
changeset
|
979 std::unique_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
|
980 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
981 std::string result; |
1826
ac5b0b4e2434
refactoring of DicomImageDecoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1824
diff
changeset
|
982 decoded->ToMatlabString(result); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
983 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
984 call.GetOutput().AnswerBuffer(result, MimeType_PlainText); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
985 } |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
986 |
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
987 |
2408
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
988 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
|
989 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
|
990 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
991 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
|
992 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
993 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
|
994 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
|
995 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
996 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
|
997 } |
2836
7133ad478eea
fix Debian warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2804
diff
changeset
|
998 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
|
999 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
1000 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
|
1001 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
1002 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
1003 std::string publicId = call.GetUriComponent("id", ""); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1004 std::string raw; |
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1005 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
|
1006 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
1007 { |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
1008 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
|
1009 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
|
1010 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
1011 |
2408
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1012 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
|
1013 { |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1014 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
|
1015 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
|
1016 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
|
1017 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
|
1018 } |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1019 else |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1020 { |
26a0cc24d48d
New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2382
diff
changeset
|
1021 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
|
1022 } |
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
|
1023 } |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
1024 |
6c73df12ca51
New URI: "/instances/.../frames/.../raw" to access the raw frames (bypass image decoding)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1906
diff
changeset
|
1025 |
974 | 1026 static void GetResourceStatistics(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1027 { |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1028 static const uint64_t MEGA_BYTES = 1024 * 1024; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1029 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1030 std::string publicId = call.GetUriComponent("id", ""); |
3174
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1031 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1032 ResourceType type; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1033 uint64_t diskSize, uncompressedSize, dicomDiskSize, dicomUncompressedSize; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1034 unsigned int countStudies, countSeries, countInstances; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1035 OrthancRestApi::GetIndex(call).GetResourceStatistics( |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1036 type, diskSize, uncompressedSize, countStudies, countSeries, |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1037 countInstances, dicomDiskSize, dicomUncompressedSize, publicId); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1038 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1039 Json::Value result = Json::objectValue; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1040 result["DiskSize"] = boost::lexical_cast<std::string>(diskSize); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1041 result["DiskSizeMB"] = static_cast<unsigned int>(diskSize / MEGA_BYTES); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1042 result["UncompressedSize"] = boost::lexical_cast<std::string>(uncompressedSize); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1043 result["UncompressedSizeMB"] = static_cast<unsigned int>(uncompressedSize / MEGA_BYTES); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1044 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1045 result["DicomDiskSize"] = boost::lexical_cast<std::string>(dicomDiskSize); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1046 result["DicomDiskSizeMB"] = static_cast<unsigned int>(dicomDiskSize / MEGA_BYTES); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1047 result["DicomUncompressedSize"] = boost::lexical_cast<std::string>(dicomUncompressedSize); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1048 result["DicomUncompressedSizeMB"] = static_cast<unsigned int>(dicomUncompressedSize / MEGA_BYTES); |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1049 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1050 switch (type) |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1051 { |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1052 // Do NOT add "break" below this point! |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1053 case ResourceType_Patient: |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1054 result["CountStudies"] = countStudies; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1055 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1056 case ResourceType_Study: |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1057 result["CountSeries"] = countSeries; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1058 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1059 case ResourceType_Series: |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1060 result["CountInstances"] = countInstances; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1061 |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1062 case ResourceType_Instance: |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1063 default: |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1064 break; |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1065 } |
8ea7c4546c3a
primitives to collect metrics in Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3163
diff
changeset
|
1066 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1067 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1068 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1069 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1070 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1071 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1072 // Handling of metadata ----------------------------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1073 |
974 | 1074 static void CheckValidResourceType(RestApiCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1075 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1076 std::string resourceType = call.GetUriComponent("resourceType", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1077 StringToResourceType(resourceType.c_str()); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1078 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1079 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1080 |
974 | 1081 static void ListMetadata(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1082 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1083 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1084 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1085 std::string publicId = call.GetUriComponent("id", ""); |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
1086 std::map<MetadataType, std::string> metadata; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1087 |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
1088 OrthancRestApi::GetIndex(call).GetAllMetadata(metadata, publicId); |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1089 |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1090 Json::Value result; |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1091 |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1092 if (call.HasArgument("expand")) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1093 { |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1094 result = Json::objectValue; |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1095 |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
1096 for (std::map<MetadataType, std::string>::const_iterator |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1097 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
|
1098 { |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
1099 std::string key = EnumerationToString(it->first); |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
1100 result[key] = it->second; |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1101 } |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1102 } |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1103 else |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1104 { |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1105 result = Json::arrayValue; |
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1106 |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
1107 for (std::map<MetadataType, std::string>::const_iterator |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1108 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
|
1109 { |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3174
diff
changeset
|
1110 result.append(EnumerationToString(it->first)); |
2726
46061a91c88a
new metadata (RemoteIP, CalledAET, HttpUsername), "?expand" metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2704
diff
changeset
|
1111 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1112 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1113 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1114 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1115 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1116 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1117 |
974 | 1118 static void GetMetadata(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1119 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1120 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1121 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1122 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1123 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1124 MetadataType metadata = StringToMetadata(name); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1125 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1126 std::string value; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1127 if (OrthancRestApi::GetIndex(call).LookupMetadata(value, publicId, metadata)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1128 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1129 call.GetOutput().AnswerBuffer(value, MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1130 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1131 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1132 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1133 |
974 | 1134 static void DeleteMetadata(RestApiDeleteCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1135 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1136 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1137 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1138 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1139 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1140 MetadataType metadata = StringToMetadata(name); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1141 |
1773
613df4362575
New UpdatedAttachment and UpdatedMetadata events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1759
diff
changeset
|
1142 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
|
1143 { |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1144 OrthancRestApi::GetIndex(call).DeleteMetadata(publicId, metadata); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1145 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1146 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1147 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1148 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1149 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
|
1150 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1151 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1152 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1153 |
974 | 1154 static void SetMetadata(RestApiPutCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1155 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1156 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1157 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1158 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1159 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1160 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
|
1161 |
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
1162 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
|
1163 call.BodyToString(value); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1164 |
1773
613df4362575
New UpdatedAttachment and UpdatedMetadata events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1759
diff
changeset
|
1165 if (IsUserMetadata(metadata)) // It is forbidden to modify internal metadata |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1166 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1167 // It is forbidden to modify internal metadata |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1168 OrthancRestApi::GetIndex(call).SetMetadata(publicId, metadata, value); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1169 call.GetOutput().AnswerBuffer("", MimeType_PlainText); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1170 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1171 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1172 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1173 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
|
1174 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1175 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1176 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1177 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1178 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1179 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1180 // Handling of attached files ----------------------------------------------- |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1181 |
974 | 1182 static void ListAttachments(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1183 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1184 std::string resourceType = call.GetUriComponent("resourceType", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1185 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1186 std::list<FileContentType> attachments; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1187 OrthancRestApi::GetIndex(call).ListAvailableAttachments(attachments, publicId, StringToResourceType(resourceType.c_str())); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1188 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1189 Json::Value result = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1190 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1191 for (std::list<FileContentType>::const_iterator |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1192 it = attachments.begin(); it != attachments.end(); ++it) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1193 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1194 result.append(EnumerationToString(*it)); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1195 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1196 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1197 call.GetOutput().AnswerJson(result); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1198 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1199 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1200 |
974 | 1201 static bool GetAttachmentInfo(FileInfo& info, RestApiCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1202 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1203 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1204 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1205 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1206 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1207 FileContentType contentType = StringToContentType(name); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1208 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1209 return OrthancRestApi::GetIndex(call).LookupAttachment(info, publicId, contentType); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1210 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1211 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1212 |
974 | 1213 static void GetAttachmentOperations(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1214 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1215 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1216 if (GetAttachmentInfo(info, call)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1217 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1218 Json::Value operations = Json::arrayValue; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1219 |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1220 operations.append("compress"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1221 operations.append("compressed-data"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1222 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1223 if (info.GetCompressedMD5() != "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1224 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1225 operations.append("compressed-md5"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1226 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1227 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1228 operations.append("compressed-size"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1229 operations.append("data"); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1230 operations.append("is-compressed"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1231 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1232 if (info.GetUncompressedMD5() != "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1233 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1234 operations.append("md5"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1235 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1236 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1237 operations.append("size"); |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1238 operations.append("uncompress"); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1239 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1240 if (info.GetCompressedMD5() != "" && |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1241 info.GetUncompressedMD5() != "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1242 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1243 operations.append("verify-md5"); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1244 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1245 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1246 call.GetOutput().AnswerJson(operations); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1247 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1248 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1249 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1250 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1251 template <int uncompress> |
974 | 1252 static void GetAttachmentData(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1253 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1254 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1255 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1256 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1257 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1258 std::string publicId = call.GetUriComponent("id", ""); |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
1259 FileContentType type = StringToContentType(call.GetUriComponent("name", "")); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1260 |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
1261 if (uncompress) |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
1262 { |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
1263 context.AnswerAttachment(call.GetOutput(), publicId, type); |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
1264 } |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
1265 else |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
1266 { |
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
1267 // 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
|
1268 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
|
1269 context.ReadAttachment(content, publicId, type, false); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1270 call.GetOutput().AnswerBuffer(content, MimeType_Binary); |
1146
200fcac0deb4
optimization for access to attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1145
diff
changeset
|
1271 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1272 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1273 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1274 |
974 | 1275 static void GetAttachmentSize(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1276 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1277 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1278 if (GetAttachmentInfo(info, call)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1279 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1280 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
|
1281 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1282 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1283 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1284 |
974 | 1285 static void GetAttachmentCompressedSize(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1286 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1287 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1288 if (GetAttachmentInfo(info, call)) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1289 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1290 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
|
1291 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1292 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1293 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1294 |
974 | 1295 static void GetAttachmentMD5(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1296 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1297 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1298 if (GetAttachmentInfo(info, call) && |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1299 info.GetUncompressedMD5() != "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1300 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1301 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
|
1302 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1303 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1304 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1305 |
974 | 1306 static void GetAttachmentCompressedMD5(RestApiGetCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1307 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1308 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1309 if (GetAttachmentInfo(info, call) && |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1310 info.GetCompressedMD5() != "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1311 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1312 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
|
1313 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1314 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1315 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1316 |
974 | 1317 static void VerifyAttachment(RestApiPostCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1318 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1319 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1320 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1321 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1322 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1323 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1324 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1325 FileInfo info; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1326 if (!GetAttachmentInfo(info, call) || |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1327 info.GetCompressedMD5() == "" || |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1328 info.GetUncompressedMD5() == "") |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1329 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1330 // Inexistent resource, or no MD5 available |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1331 return; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1332 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1333 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1334 bool ok = false; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1335 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1336 // 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
|
1337 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
|
1338 context.ReadAttachment(data, publicId, StringToContentType(name), false); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1339 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1340 std::string actualMD5; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1341 Toolbox::ComputeMD5(actualMD5, data); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1342 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1343 if (actualMD5 == info.GetCompressedMD5()) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1344 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1345 // The compressed data is OK. If a compression algorithm was |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1346 // applied to it, now check the MD5 of the uncompressed data. |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1347 if (info.GetCompressionType() == CompressionType_None) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1348 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1349 ok = true; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1350 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1351 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1352 { |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1353 context.ReadAttachment(data, publicId, StringToContentType(name), true); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1354 Toolbox::ComputeMD5(actualMD5, data); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1355 ok = (actualMD5 == info.GetUncompressedMD5()); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1356 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1357 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1358 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1359 if (ok) |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1360 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1361 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
|
1362 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1363 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1364 else |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1365 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1366 LOG(INFO) << "The attachment " << name << " of resource " << publicId << " has bad MD5!"; |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1367 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1368 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1369 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1370 |
974 | 1371 static void UploadAttachment(RestApiPutCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1372 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1373 ServerContext& context = OrthancRestApi::GetContext(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1374 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1375 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1376 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1377 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1378 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1379 FileContentType contentType = StringToContentType(name); |
1773
613df4362575
New UpdatedAttachment and UpdatedMetadata events in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1759
diff
changeset
|
1380 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
|
1381 context.AddAttachment(publicId, StringToContentType(name), call.GetBodyData(), call.GetBodySize())) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1382 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1383 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1384 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1385 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1386 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1387 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
|
1388 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1389 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1390 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1391 |
974 | 1392 static void DeleteAttachment(RestApiDeleteCall& call) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1393 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1394 CheckValidResourceType(call); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1395 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1396 std::string publicId = call.GetUriComponent("id", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1397 std::string name = call.GetUriComponent("name", ""); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1398 FileContentType contentType = StringToContentType(name); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1399 |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1400 bool allowed; |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1401 if (IsUserContentType(contentType)) |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1402 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1403 allowed = true; |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1404 } |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1405 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1406 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1407 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1408 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1409 if (lock.GetConfiguration().GetBooleanParameter("StoreDicom", true) && |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1410 contentType == FileContentType_DicomAsJson) |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1411 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1412 allowed = true; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1413 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1414 else |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1415 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1416 // 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
|
1417 // 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
|
1418 // 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
|
1419 allowed = false; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2935
diff
changeset
|
1420 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1421 } |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1422 |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1423 if (allowed) |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1424 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1425 OrthancRestApi::GetIndex(call).DeleteAttachment(publicId, contentType); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1426 call.GetOutput().AnswerBuffer("{}", MimeType_Json); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1427 } |
2128
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1428 else |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1429 { |
9329ba17a069
Possibility to DELETE "dicom-as-json" attachments to reconstruct them
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2127
diff
changeset
|
1430 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
|
1431 } |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1432 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1433 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1434 |
1700
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1435 template <enum CompressionType compression> |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1436 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
|
1437 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1438 CheckValidResourceType(call); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1439 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1440 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
|
1441 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
|
1442 FileContentType contentType = StringToContentType(name); |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1443 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1444 OrthancRestApi::GetContext(call).ChangeAttachmentCompression(publicId, contentType, compression); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1445 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
|
1446 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1447 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1448 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1449 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
|
1450 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1451 FileInfo info; |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1452 if (GetAttachmentInfo(info, call)) |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1453 { |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1454 std::string answer = (info.GetCompressionType() == CompressionType_None) ? "0" : "1"; |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1455 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
|
1456 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1457 } |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1458 |
f5ddbd9239dd
New URIs for attachments: ".../compress", ".../uncompress" and ".../is-compressed"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1556
diff
changeset
|
1459 |
782 | 1460 // Raw access to the DICOM tags of an instance ------------------------------ |
1461 | |
974 | 1462 static void GetRawContent(RestApiGetCall& call) |
782 | 1463 { |
1464 std::string id = call.GetUriComponent("id", ""); | |
1465 | |
1466 ServerContext::DicomCacheLocker locker(OrthancRestApi::GetContext(call), id); | |
1467 | |
1468 locker.GetDicom().SendPathValue(call.GetOutput(), call.GetTrailingUri()); | |
1469 } | |
1470 | |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1471 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1472 |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1473 static bool ExtractSharedTags(Json::Value& shared, |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1474 ServerContext& context, |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1475 const std::string& publicId) |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1476 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1477 // 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
|
1478 typedef std::list<std::string> Instances; |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1479 Instances instances; |
959
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1480 context.GetIndex().GetChildInstances(instances, publicId); // (*) |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1481 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1482 // Loop over the instances |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1483 bool isFirst = true; |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1484 shared = Json::objectValue; |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1485 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1486 for (Instances::const_iterator it = instances.begin(); |
1303 | 1487 it != instances.end(); ++it) |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1488 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1489 // 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
|
1490 Json::Value tags; |
959
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1491 |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1492 try |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1493 { |
2124 | 1494 context.ReadDicomAsJson(tags, *it); |
959
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1495 } |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1496 catch (OrthancException&) |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1497 { |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1498 // Race condition: This instance has been removed since |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1499 // (*). Ignore this instance. |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1500 continue; |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1501 } |
bd5659f2a50a
fix possible race condition
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
958
diff
changeset
|
1502 |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1503 if (tags.type() != Json::objectValue) |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1504 { |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1505 return false; // Error |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1506 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1507 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1508 // 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
|
1509 Json::Value::Members members = tags.getMemberNames(); |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1510 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
|
1511 { |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1512 const Json::Value& tag = tags[members[i]]; |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1513 if (tag.type() != Json::objectValue || |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1514 tag["Type"].type() != Json::stringValue || |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1515 tag["Type"].asString() != "String") |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1516 { |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1517 tags.removeMember(members[i]); |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1518 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1519 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1520 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1521 if (isFirst) |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1522 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1523 // 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
|
1524 shared = tags; |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1525 isFirst = false; |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1526 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1527 else |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1528 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1529 // 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
|
1530 // 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
|
1531 // value in the current instance, remove it. |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1532 members = shared.getMemberNames(); |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1533 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
|
1534 { |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1535 if (!tags.isMember(members[i]) || |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1536 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
|
1537 { |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1538 shared.removeMember(members[i]); |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1539 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1540 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1541 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1542 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1543 |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1544 return true; |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1545 } |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1546 |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1547 |
974 | 1548 static void GetSharedTags(RestApiGetCall& call) |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1549 { |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1550 ServerContext& context = OrthancRestApi::GetContext(call); |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1551 std::string publicId = call.GetUriComponent("id", ""); |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1552 |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1553 Json::Value sharedTags; |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1554 if (ExtractSharedTags(sharedTags, context, publicId)) |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1555 { |
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1556 // 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
|
1557 AnswerDicomAsJson(call, sharedTags); |
960
abac5c83134f
simplified and extensive shared-tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
959
diff
changeset
|
1558 } |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1559 } |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1560 |
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
1561 |
1054
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1562 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
|
1563 ResourceType resourceType, |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1564 DicomModule module) |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1565 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1566 if (!((resourceType == ResourceType_Patient && module == DicomModule_Patient) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1567 (resourceType == ResourceType_Study && module == DicomModule_Patient) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1568 (resourceType == ResourceType_Study && module == DicomModule_Study) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1569 (resourceType == ResourceType_Series && module == DicomModule_Series) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1570 (resourceType == ResourceType_Instance && module == DicomModule_Instance) || |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1571 (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
|
1572 { |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1573 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
|
1574 } |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1575 |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1576 ServerContext& context = OrthancRestApi::GetContext(call); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1577 std::string publicId = call.GetUriComponent("id", ""); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1578 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1579 std::set<DicomTag> ignoreTagLength; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1580 ParseSetOfTags(ignoreTagLength, call, "ignore-length"); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1581 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1582 typedef std::set<DicomTag> ModuleTags; |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1583 ModuleTags moduleTags; |
1368 | 1584 DicomTag::AddTagsForModule(moduleTags, module); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1585 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1586 Json::Value tags; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1587 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1588 if (resourceType != ResourceType_Instance) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1589 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1590 // Retrieve all the instances of this patient/study/series |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1591 typedef std::list<std::string> Instances; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1592 Instances instances; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1593 context.GetIndex().GetChildInstances(instances, publicId); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1594 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1595 if (instances.empty()) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1596 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1597 return; // Error: No instance (should never happen) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1598 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1599 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1600 // Select one child instance |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1601 publicId = instances.front(); |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1602 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1603 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1604 context.ReadDicomAsJson(tags, publicId, ignoreTagLength); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1605 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1606 // 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
|
1607 Json::Value result = Json::objectValue; |
1303 | 1608 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
|
1609 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1610 std::string s = tag->Format(); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1611 if (tags.isMember(s)) |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1612 { |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1613 result[s] = tags[s]; |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1614 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1615 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1616 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1617 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
|
1618 } |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1619 |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1620 |
1701dcb6f554
Access patient module at the study level to cope with PatientID collisions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
974
diff
changeset
|
1621 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1622 template <enum ResourceType resourceType, |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1623 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
|
1624 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
|
1625 { |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
1626 GetModuleInternal(call, resourceType, module); |
963
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1627 } |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1628 |
81134ea872ff
retrieve values of modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
960
diff
changeset
|
1629 |
1722 | 1630 namespace |
1631 { | |
1632 typedef std::list< std::pair<ResourceType, std::string> > LookupResults; | |
1633 } | |
1634 | |
1635 | |
1636 static void AccumulateLookupResults(LookupResults& result, | |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1637 ServerIndex& index, |
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1638 const DicomTag& tag, |
1719
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1639 const std::string& value, |
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1640 ResourceType level) |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1641 { |
3034
54e422fe31ce
moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3033
diff
changeset
|
1642 std::vector<std::string> tmp; |
1728
4941494b5dd8
rename LookupIdentifier as LookupIdentifierExact
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1727
diff
changeset
|
1643 index.LookupIdentifierExact(tmp, level, tag, value); |
1719
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1644 |
3034
54e422fe31ce
moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3033
diff
changeset
|
1645 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
|
1646 { |
3034
54e422fe31ce
moving LookupResource to graveyard
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3033
diff
changeset
|
1647 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
|
1648 } |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1649 } |
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1650 |
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1651 |
1139
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1652 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
|
1653 { |
1446
8dc80ba768aa
refactoring: IHttpHandler does not use std::string to hold the request body
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1437
diff
changeset
|
1654 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
|
1655 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
|
1656 |
1722 | 1657 LookupResults resources; |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1658 ServerIndex& index = OrthancRestApi::GetIndex(call); |
1719
3b1f7e706d38
fix Orthanc.test_lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1718
diff
changeset
|
1659 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
|
1660 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
|
1661 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
|
1662 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
|
1663 |
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1664 Json::Value result = Json::arrayValue; |
1722 | 1665 for (LookupResults::const_iterator |
1718
2b812969e136
getting rid of an IDatabaseWrapper::LookupIdentifier flavor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1703
diff
changeset
|
1666 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
|
1667 { |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1668 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
|
1669 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
|
1670 |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1671 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
|
1672 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
|
1673 item["ID"] = id; |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1674 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
|
1675 |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1676 result.append(item); |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1677 } |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1678 |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1679 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
|
1680 } |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1681 |
f167b672db94
/tools/lookup URI to map DICOM UIDs to Orthanc identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1054
diff
changeset
|
1682 |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1683 namespace |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1684 { |
3021
2cbafb5d5a62
renamed LookupResource::IVisitor as ServerContext::ILookupVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3012
diff
changeset
|
1685 class FindVisitor : public ServerContext::ILookupVisitor |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1686 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1687 private: |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1688 bool isComplete_; |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1689 std::list<std::string> resources_; |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1690 |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1691 public: |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1692 FindVisitor() : |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1693 isComplete_(false) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1694 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1695 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1696 |
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
|
1697 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
|
1698 { |
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
|
1699 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
|
1700 } |
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
|
1701 |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1702 virtual void MarkAsComplete() |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1703 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1704 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
|
1705 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1706 |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1707 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
|
1708 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
|
1709 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
|
1710 const Json::Value* dicomAsJson /* unused (*) */) |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1711 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1712 resources_.push_back(publicId); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1713 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1714 |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1715 void Answer(RestApiOutput& output, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1716 ServerIndex& index, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1717 ResourceType level, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1718 bool expand) const |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1719 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1720 AnswerListOfResources(output, index, resources_, level, expand); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1721 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1722 }; |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1723 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1724 |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1725 |
1354 | 1726 static void Find(RestApiPostCall& call) |
1727 { | |
2998 | 1728 static const char* const KEY_CASE_SENSITIVE = "CaseSensitive"; |
1729 static const char* const KEY_EXPAND = "Expand"; | |
1730 static const char* const KEY_LEVEL = "Level"; | |
1731 static const char* const KEY_LIMIT = "Limit"; | |
1732 static const char* const KEY_QUERY = "Query"; | |
1733 static const char* const KEY_SINCE = "Since"; | |
1734 | |
1358 | 1735 ServerContext& context = OrthancRestApi::GetContext(call); |
1354 | 1736 |
1737 Json::Value request; | |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1738 if (!call.ParseJsonRequest(request) || |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1739 request.type() != Json::objectValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1740 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1741 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1742 "The body must contain a JSON object"); |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1743 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1744 else if (!request.isMember(KEY_LEVEL) || |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1745 request[KEY_LEVEL].type() != Json::stringValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1746 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1747 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1748 "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
|
1749 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1750 else if (!request.isMember(KEY_QUERY) && |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1751 request[KEY_QUERY].type() != Json::objectValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1752 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1753 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1754 "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
|
1755 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1756 else if (request.isMember(KEY_CASE_SENSITIVE) && |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1757 request[KEY_CASE_SENSITIVE].type() != Json::booleanValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1758 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1759 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1760 "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
|
1761 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1762 else if (request.isMember(KEY_LIMIT) && |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1763 request[KEY_LIMIT].type() != Json::intValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1764 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1765 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1766 "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
|
1767 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1768 else if (request.isMember(KEY_SINCE) && |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1769 request[KEY_SINCE].type() != Json::intValue) |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1770 { |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1771 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1772 "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
|
1773 } |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1774 else |
1354 | 1775 { |
1776 bool expand = false; | |
2998 | 1777 if (request.isMember(KEY_EXPAND)) |
1354 | 1778 { |
2998 | 1779 expand = request[KEY_EXPAND].asBool(); |
1354 | 1780 } |
1781 | |
1374
a1745d9be6e9
CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
1782 bool caseSensitive = false; |
2998 | 1783 if (request.isMember(KEY_CASE_SENSITIVE)) |
1374
a1745d9be6e9
CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
1784 { |
2998 | 1785 caseSensitive = request[KEY_CASE_SENSITIVE].asBool(); |
1374
a1745d9be6e9
CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
1786 } |
a1745d9be6e9
CaseSensitivePN configuration option
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1361
diff
changeset
|
1787 |
1758 | 1788 size_t limit = 0; |
2998 | 1789 if (request.isMember(KEY_LIMIT)) |
1758 | 1790 { |
2998 | 1791 int tmp = request[KEY_LIMIT].asInt(); |
1847 | 1792 if (tmp < 0) |
1758 | 1793 { |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1794 throw OrthancException(ErrorCode_ParameterOutOfRange, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1795 "Field \"" + std::string(KEY_LIMIT) + "\" should be a positive integer"); |
1758 | 1796 } |
1847 | 1797 |
1798 limit = static_cast<size_t>(tmp); | |
1758 | 1799 } |
1800 | |
2304
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1801 size_t since = 0; |
2998 | 1802 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
|
1803 { |
2998 | 1804 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
|
1805 if (tmp < 0) |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1806 { |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1807 throw OrthancException(ErrorCode_ParameterOutOfRange, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1808 "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
|
1809 } |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1810 |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1811 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
|
1812 } |
563bf878407a
Argument "Since" in URI "/tools/find" (related to issue 53)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2281
diff
changeset
|
1813 |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1814 ResourceType level = StringToResourceType(request[KEY_LEVEL].asCString()); |
1360 | 1815 |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1816 DatabaseLookup query; |
1358 | 1817 |
2998 | 1818 Json::Value::Members members = request[KEY_QUERY].getMemberNames(); |
1354 | 1819 for (size_t i = 0; i < members.size(); i++) |
1820 { | |
2998 | 1821 if (request[KEY_QUERY][members[i]].type() != Json::stringValue) |
1354 | 1822 { |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1823 throw OrthancException(ErrorCode_BadRequest, |
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1824 "Tag \"" + members[i] + "\" should be associated with a string"); |
1354 | 1825 } |
1826 | |
3163
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1827 const std::string value = request[KEY_QUERY][members[i]].asString(); |
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1828 |
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1829 if (!value.empty()) |
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1830 { |
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1831 // An empty string corresponds to an universal constraint, |
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1832 // so we ignore it. This mimics the behavior of class |
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1833 // "OrthancFindRequestHandler" |
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1834 query.AddRestConstraint(FromDcmtkBridge::ParseTag(members[i]), |
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1835 value, caseSensitive, true); |
cf91b6f22278
Fix issue #90 (C-Find shall match missing tags to null/empty string)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3094
diff
changeset
|
1836 } |
1361
94ffb597d297
refactoring of C-Find SCP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1360
diff
changeset
|
1837 } |
2876 | 1838 |
3001
7695a9c81099
refactoring /tools/find using LookupResource::IVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2998
diff
changeset
|
1839 FindVisitor visitor; |
3033
5da6d1063d8f
effectively replacing LookupResource by DatabaseLookup in searches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3027
diff
changeset
|
1840 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
|
1841 visitor.Answer(call.GetOutput(), context.GetIndex(), level, expand); |
1354 | 1842 } |
1843 } | |
1844 | |
1845 | |
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
|
1846 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
|
1847 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
|
1848 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
|
1849 { |
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
|
1850 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
|
1851 |
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
|
1852 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
|
1853 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
|
1854 |
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
|
1855 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
|
1856 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
|
1857 { |
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
|
1858 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
|
1859 |
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
|
1860 for (std::list<std::string>::const_iterator |
1303 | 1861 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
|
1862 { |
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
|
1863 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
|
1864 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
|
1865 } |
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
|
1866 |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1867 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
|
1868 |
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
|
1869 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
|
1870 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
|
1871 } |
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
|
1872 |
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
|
1873 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
|
1874 |
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
|
1875 for (std::list<std::string>::const_iterator |
1303 | 1876 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
|
1877 { |
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
|
1878 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
|
1879 |
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
|
1880 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
|
1881 { |
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
|
1882 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
|
1883 } |
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
|
1884 } |
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
|
1885 |
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
|
1886 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
|
1887 } |
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
|
1888 |
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
|
1889 |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1890 static void GetChildInstancesTags(RestApiGetCall& call) |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1891 { |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1892 ServerContext& context = OrthancRestApi::GetContext(call); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1893 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
|
1894 DicomToJsonFormat format = GetDicomFormat(call); |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1895 |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1896 std::set<DicomTag> ignoreTagLength; |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1897 ParseSetOfTags(ignoreTagLength, call, "ignore-length"); |
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1898 |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1899 // Retrieve all the instances of this patient/study/series |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1900 typedef std::list<std::string> Instances; |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1901 Instances instances; |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1902 |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1903 context.GetIndex().GetChildInstances(instances, publicId); // (*) |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1904 |
1201
09aa7c126be9
URIs 'instance-tags' now indexed by the instance IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1172
diff
changeset
|
1905 Json::Value result = Json::objectValue; |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1906 |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1907 for (Instances::const_iterator it = instances.begin(); |
1303 | 1908 it != instances.end(); ++it) |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1909 { |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1910 Json::Value full; |
2409
e4045b3c9772
ignore-length argument if retrieving DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2408
diff
changeset
|
1911 context.ReadDicomAsJson(full, *it, ignoreTagLength); |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1912 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
1913 if (format != DicomToJsonFormat_Full) |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1914 { |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1915 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
|
1916 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
|
1917 result[*it] = simplified; |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1918 } |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1919 else |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1920 { |
1201
09aa7c126be9
URIs 'instance-tags' now indexed by the instance IDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1172
diff
changeset
|
1921 result[*it] = full; |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1922 } |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1923 } |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1924 |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1925 call.GetOutput().AnswerJson(result); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1926 } |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1927 |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
1928 |
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
|
1929 |
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
|
1930 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
|
1931 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
|
1932 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
|
1933 { |
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
|
1934 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
|
1935 |
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
|
1936 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
|
1937 |
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
|
1938 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
|
1939 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
|
1940 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
|
1941 { |
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
|
1942 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
|
1943 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
|
1944 { |
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
|
1945 // 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
|
1946 // 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
|
1947 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
|
1948 } |
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
|
1949 |
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
|
1950 current = parent; |
1555
d6a93e12b1c1
Creation of DICOM files with encapsulated PDF
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1509
diff
changeset
|
1951 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
|
1952 } |
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
|
1953 |
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
|
1954 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
|
1955 |
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
|
1956 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
|
1957 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
|
1958 { |
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
|
1959 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
|
1960 } |
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
|
1961 } |
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
|
1962 |
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
|
1963 |
1556
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1964 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
|
1965 { |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1966 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
|
1967 |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1968 std::string pdf; |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1969 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
|
1970 |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1971 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
|
1972 { |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
1973 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
|
1974 return; |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1975 } |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1976 } |
b8dc2f855a83
Preview of PDF files encapsulated in DICOM from Orthanc Explorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
1977 |
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
|
1978 |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1979 static void OrderSlices(RestApiGetCall& call) |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1980 { |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1981 const std::string id = call.GetUriComponent("id", ""); |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1982 |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1983 ServerIndex& index = OrthancRestApi::GetIndex(call); |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1984 SliceOrdering ordering(index, id); |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1985 |
1703
b80e76dd1d56
ordered-slices continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1702
diff
changeset
|
1986 Json::Value result; |
b80e76dd1d56
ordered-slices continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1702
diff
changeset
|
1987 ordering.Format(result); |
b80e76dd1d56
ordered-slices continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1702
diff
changeset
|
1988 call.GetOutput().AnswerJson(result); |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1989 } |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1990 |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
1991 |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1992 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
|
1993 { |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1994 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
|
1995 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1996 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
|
1997 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
1998 std::string dicomContent; |
2124 | 1999 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
|
2000 |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2003
diff
changeset
|
2001 // TODO Consider using "DicomMap::ParseDicomMetaInformation()" to |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2003
diff
changeset
|
2002 // speed up things here |
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2003
diff
changeset
|
2003 |
1831
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
2004 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
|
2005 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
2006 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
|
2007 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
|
2008 |
2622
3603a2e14592
New option "?short" to list DICOM tags using their hexadecimal ID
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
2009 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
|
2010 } |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
2011 |
3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1826
diff
changeset
|
2012 |
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
|
2013 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
|
2014 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2015 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
|
2016 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2017 // 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
|
2018 // 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
|
2019 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
|
2020 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
|
2021 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2022 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
|
2023 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
|
2024 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2025 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
|
2026 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
|
2027 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2028 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
|
2029 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
|
2030 { |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2031 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
|
2032 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2033 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2034 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2035 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
|
2036 } |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2037 |
0c09d1af22f3
"/tools/invalidate-tags" to invalidate the JSON summary of all the DICOM files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2128
diff
changeset
|
2038 |
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
|
2039 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
|
2040 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
|
2041 { |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
2042 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
|
2043 ServerToolbox::ReconstructResource(context, call.GetUriComponent("id", "")); |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2044 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
|
2045 } |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
2046 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
2047 |
2804
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2048 static void ReconstructAllResources(RestApiPostCall& call) |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2049 { |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2050 ServerContext& context = OrthancRestApi::GetContext(call); |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2051 |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2052 std::list<std::string> studies; |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2053 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
|
2054 |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2055 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
|
2056 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
|
2057 { |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2058 ServerToolbox::ReconstructResource(context, *study); |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2059 } |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2060 |
2908
9d277f8ad698
new enumeration: MimeType
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2905
diff
changeset
|
2061 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
|
2062 } |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2063 |
d88970f1ffbf
fix ordering of non-parallel slices + /tools/reconstruct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2780
diff
changeset
|
2064 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2065 void OrthancRestApi::RegisterResources() |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2066 { |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2067 Register("/instances", ListResources<ResourceType_Instance>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2068 Register("/patients", ListResources<ResourceType_Patient>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2069 Register("/series", ListResources<ResourceType_Series>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2070 Register("/studies", ListResources<ResourceType_Study>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2071 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2072 Register("/instances/{id}", DeleteSingleResource<ResourceType_Instance>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2073 Register("/instances/{id}", GetSingleResource<ResourceType_Instance>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2074 Register("/patients/{id}", DeleteSingleResource<ResourceType_Patient>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2075 Register("/patients/{id}", GetSingleResource<ResourceType_Patient>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2076 Register("/series/{id}", DeleteSingleResource<ResourceType_Series>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2077 Register("/series/{id}", GetSingleResource<ResourceType_Series>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2078 Register("/studies/{id}", DeleteSingleResource<ResourceType_Study>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2079 Register("/studies/{id}", GetSingleResource<ResourceType_Study>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2080 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2081 Register("/instances/{id}/statistics", GetResourceStatistics); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2082 Register("/patients/{id}/statistics", GetResourceStatistics); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2083 Register("/studies/{id}/statistics", GetResourceStatistics); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2084 Register("/series/{id}/statistics", GetResourceStatistics); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2085 |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
2086 Register("/patients/{id}/shared-tags", GetSharedTags); |
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
2087 Register("/series/{id}/shared-tags", GetSharedTags); |
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
2088 Register("/studies/{id}/shared-tags", GetSharedTags); |
958
1fbe89dc18b5
extraction of the shared tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
874
diff
changeset
|
2089 |
1276
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
2090 Register("/instances/{id}/module", GetModule<ResourceType_Instance, DicomModule_Instance>); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
2091 Register("/patients/{id}/module", GetModule<ResourceType_Patient, DicomModule_Patient>); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
2092 Register("/series/{id}/module", GetModule<ResourceType_Series, DicomModule_Series>); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
2093 Register("/studies/{id}/module", GetModule<ResourceType_Study, DicomModule_Study>); |
6164f7200c43
refactoring modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1201
diff
changeset
|
2094 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
|
2095 |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2096 Register("/instances/{id}/file", GetInstanceFile); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2097 Register("/instances/{id}/export", ExportInstanceFile); |
964
cc7a4ae474c1
simplify has a GET argument
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
963
diff
changeset
|
2098 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
|
2099 Register("/instances/{id}/simplified-tags", GetInstanceTags<DicomToJsonFormat_Human>); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2100 Register("/instances/{id}/frames", ListFrames); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2101 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2102 Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
2103 Register("/instances/{id}/frames/{frame}/rendered", GetRenderedFrame); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2104 Register("/instances/{id}/frames/{frame}/image-uint8", GetImage<ImageExtractionMode_UInt8>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2105 Register("/instances/{id}/frames/{frame}/image-uint16", GetImage<ImageExtractionMode_UInt16>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2106 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
|
2107 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
|
2108 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
|
2109 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
|
2110 Register("/instances/{id}/pdf", ExtractPdf); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2111 Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>); |
3683
12253ddefe5a
skeleton for new route: /instances/{id}/rendered
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
2112 Register("/instances/{id}/rendered", GetRenderedFrame); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2113 Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2114 Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2115 Register("/instances/{id}/image-int16", GetImage<ImageExtractionMode_Int16>); |
874
87791ebc1f50
download matlab images
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
2116 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
|
2117 Register("/instances/{id}/header", GetInstanceHeader); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2118 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2119 Register("/patients/{id}/protected", IsProtectedPatient); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2120 Register("/patients/{id}/protected", SetPatientProtection); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2121 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2122 Register("/{resourceType}/{id}/metadata", ListMetadata); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2123 Register("/{resourceType}/{id}/metadata/{name}", DeleteMetadata); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2124 Register("/{resourceType}/{id}/metadata/{name}", GetMetadata); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2125 Register("/{resourceType}/{id}/metadata/{name}", SetMetadata); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2126 |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2127 Register("/{resourceType}/{id}/attachments", ListAttachments); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2128 Register("/{resourceType}/{id}/attachments/{name}", DeleteAttachment); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2129 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
|
2130 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
|
2131 Register("/{resourceType}/{id}/attachments/{name}/compress", ChangeAttachmentCompression<CompressionType_ZlibWithSize>); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2132 Register("/{resourceType}/{id}/attachments/{name}/compressed-data", GetAttachmentData<0>); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2133 Register("/{resourceType}/{id}/attachments/{name}/compressed-md5", GetAttachmentCompressedMD5); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2134 Register("/{resourceType}/{id}/attachments/{name}/compressed-size", GetAttachmentCompressedSize); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2135 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
|
2136 Register("/{resourceType}/{id}/attachments/{name}/is-compressed", IsAttachmentCompressed); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2137 Register("/{resourceType}/{id}/attachments/{name}/md5", GetAttachmentMD5); |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2138 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
|
2139 Register("/{resourceType}/{id}/attachments/{name}/uncompress", ChangeAttachmentCompression<CompressionType_None>); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2140 Register("/{resourceType}/{id}/attachments/{name}/verify-md5", VerifyAttachment); |
782 | 2141 |
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
|
2142 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
|
2143 Register("/tools/lookup", Lookup); |
1354 | 2144 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
|
2145 |
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
|
2146 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
|
2147 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
|
2148 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
|
2149 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
|
2150 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
|
2151 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
|
2152 |
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
|
2153 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
|
2154 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
|
2155 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
|
2156 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
|
2157 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
|
2158 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
|
2159 |
1166
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
2160 Register("/patients/{id}/instances-tags", GetChildInstancesTags); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
2161 Register("/studies/{id}/instances-tags", GetChildInstancesTags); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
2162 Register("/series/{id}/instances-tags", GetChildInstancesTags); |
a921e3b5e763
bulk tags retrieval
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1146
diff
changeset
|
2163 |
782 | 2164 Register("/instances/{id}/content/*", GetRawContent); |
1702
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
2165 |
9980875edc7c
started work on SliceOrdering
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1701
diff
changeset
|
2166 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
|
2167 |
e3fd5bc429a2
URI to reconstruct the main DICOM tags, the JSON summary and the metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2140
diff
changeset
|
2168 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
|
2169 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
|
2170 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
|
2171 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
|
2172 Register("/tools/reconstruct", ReconstructAllResources); |
751
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2173 } |
5197fd35333c
refactoring of OrthancRestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2174 } |