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