Mercurial > hg > orthanc
annotate OrthancServer/OrthancRestApi.cpp @ 485:bdbde1fbfab3
send resources through HTTP
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 16 Jul 2013 13:48:33 +0200 |
parents | b8ace6fc1d1f |
children | 7db04aa5104f |
rev | line source |
---|---|
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
399 | 3 * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Belgium |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * License, or (at your option) any later version. |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * program give permission to link the code of its release with the |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * in the program, then also delete it here. |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * General Public License for more details. |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 **/ |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
230 | 33 #include "OrthancRestApi.h" |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
35 #include "../Core/Compression/HierarchicalZipWriter.h" |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
36 #include "../Core/HttpClient.h" |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
37 #include "../Core/HttpServer/FilesystemHttpSender.h" |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
38 #include "../Core/Uuid.h" |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
39 #include "DicomProtocol/DicomUserConnection.h" |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 #include "FromDcmtkBridge.h" |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
41 #include "OrthancInitialization.h" |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
42 #include "ServerToolbox.h" |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 #include <dcmtk/dcmdata/dcistrmb.h> |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 #include <dcmtk/dcmdata/dcfilefo.h> |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 #include <boost/lexical_cast.hpp> |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
47 #include <glog/logging.h> |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
50 #define RETRIEVE_CONTEXT(call) \ |
230 | 51 OrthancRestApi& contextApi = \ |
52 dynamic_cast<OrthancRestApi&>(call.GetContext()); \ | |
225 | 53 ServerContext& context = contextApi.GetContext() |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
55 #define RETRIEVE_MODALITIES(call) \ |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
56 const OrthancRestApi::SetOfStrings& modalities = \ |
230 | 57 dynamic_cast<OrthancRestApi&>(call.GetContext()).GetModalities(); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
58 |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
59 #define RETRIEVE_PEERS(call) \ |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
60 const OrthancRestApi::SetOfStrings& peers = \ |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
61 dynamic_cast<OrthancRestApi&>(call.GetContext()).GetPeers(); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
62 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
63 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 namespace Orthanc |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 { |
315 | 67 // TODO IMPROVE MULTITHREADING |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
68 // Every call to "ParsedDicomFile" must lock this mutex!!! |
315 | 69 static boost::mutex cacheMutex_; |
70 | |
71 | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
72 // DICOM SCU ---------------------------------------------------------------- |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
73 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
74 static void ConnectToModality(DicomUserConnection& connection, |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
75 const std::string& name) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
76 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
77 std::string aet, address; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
78 int port; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
79 GetDicomModality(name, aet, address, port); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
80 connection.SetLocalApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
81 connection.SetDistantApplicationEntityTitle(aet); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
82 connection.SetDistantHost(address); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
83 connection.SetDistantPort(port); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
84 connection.Open(); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
85 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
86 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
87 static bool MergeQueryAndTemplate(DicomMap& result, |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
88 const std::string& postData) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
89 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
90 Json::Value query; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
91 Json::Reader reader; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
92 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
93 if (!reader.parse(postData, query) || |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
94 query.type() != Json::objectValue) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
95 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
96 return false; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
97 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
98 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
99 Json::Value::Members members = query.getMemberNames(); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
100 for (size_t i = 0; i < members.size(); i++) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
101 { |
304 | 102 DicomTag t = FromDcmtkBridge::ParseTag(members[i]); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
103 result.SetValue(t, query[members[i]].asString()); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
104 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
105 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
106 return true; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
107 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
108 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
109 static void DicomFindPatient(RestApi::PostCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
110 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
111 DicomMap m; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
112 DicomMap::SetupFindPatientTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
113 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
114 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
115 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
116 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
117 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
118 DicomUserConnection connection; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
119 ConnectToModality(connection, call.GetUriComponent("id", "")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
120 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
121 DicomFindAnswers answers; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
122 connection.FindPatient(answers, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
123 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
124 Json::Value result; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
125 answers.ToJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
126 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
127 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
128 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
129 static void DicomFindStudy(RestApi::PostCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
130 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
131 DicomMap m; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
132 DicomMap::SetupFindStudyTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
133 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
134 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
135 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
136 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
137 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
138 if (m.GetValue(DICOM_TAG_ACCESSION_NUMBER).AsString().size() <= 2 && |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
139 m.GetValue(DICOM_TAG_PATIENT_ID).AsString().size() <= 2) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
140 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
141 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
142 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
143 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
144 DicomUserConnection connection; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
145 ConnectToModality(connection, call.GetUriComponent("id", "")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
146 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
147 DicomFindAnswers answers; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
148 connection.FindStudy(answers, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
149 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
150 Json::Value result; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
151 answers.ToJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
152 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
153 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
154 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
155 static void DicomFindSeries(RestApi::PostCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
156 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
157 DicomMap m; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
158 DicomMap::SetupFindSeriesTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
159 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
160 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
161 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
162 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
163 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
164 if ((m.GetValue(DICOM_TAG_ACCESSION_NUMBER).AsString().size() <= 2 && |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
165 m.GetValue(DICOM_TAG_PATIENT_ID).AsString().size() <= 2) || |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
166 m.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).AsString().size() <= 2) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
167 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
168 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
169 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
170 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
171 DicomUserConnection connection; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
172 ConnectToModality(connection, call.GetUriComponent("id", "")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
173 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
174 DicomFindAnswers answers; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
175 connection.FindSeries(answers, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
176 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
177 Json::Value result; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
178 answers.ToJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
179 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
180 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
181 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
182 static void DicomFind(RestApi::PostCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
183 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
184 DicomMap m; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
185 DicomMap::SetupFindPatientTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
186 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
187 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
188 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
189 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
190 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
191 DicomUserConnection connection; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
192 ConnectToModality(connection, call.GetUriComponent("id", "")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
193 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
194 DicomFindAnswers patients; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
195 connection.FindPatient(patients, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
196 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
197 // Loop over the found patients |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
198 Json::Value result = Json::arrayValue; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
199 for (size_t i = 0; i < patients.GetSize(); i++) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
200 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
201 Json::Value patient(Json::objectValue); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
202 FromDcmtkBridge::ToJson(patient, patients.GetAnswer(i)); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
203 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
204 DicomMap::SetupFindStudyTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
205 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
206 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
207 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
208 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
209 m.CopyTagIfExists(patients.GetAnswer(i), DICOM_TAG_PATIENT_ID); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
210 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
211 DicomFindAnswers studies; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
212 connection.FindStudy(studies, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
213 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
214 patient["Studies"] = Json::arrayValue; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
215 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
216 // Loop over the found studies |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
217 for (size_t j = 0; j < studies.GetSize(); j++) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
218 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
219 Json::Value study(Json::objectValue); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
220 FromDcmtkBridge::ToJson(study, studies.GetAnswer(j)); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
221 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
222 DicomMap::SetupFindSeriesTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
223 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
224 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
225 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
226 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
227 m.CopyTagIfExists(studies.GetAnswer(j), DICOM_TAG_PATIENT_ID); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
228 m.CopyTagIfExists(studies.GetAnswer(j), DICOM_TAG_STUDY_INSTANCE_UID); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
229 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
230 DicomFindAnswers series; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
231 connection.FindSeries(series, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
232 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
233 // Loop over the found series |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
234 study["Series"] = Json::arrayValue; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
235 for (size_t k = 0; k < series.GetSize(); k++) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
236 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
237 Json::Value series2(Json::objectValue); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
238 FromDcmtkBridge::ToJson(series2, series.GetAnswer(k)); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
239 study["Series"].append(series2); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
240 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
241 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
242 patient["Studies"].append(study); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
243 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
244 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
245 result.append(patient); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
246 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
247 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
248 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
249 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
250 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
251 |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
252 static bool GetInstancesToExport(std::list<std::string>& instances, |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
253 const std::string& remote, |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
254 RestApi::PostCall& call) |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
255 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
256 RETRIEVE_CONTEXT(call); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
257 |
402 | 258 std::string stripped = Toolbox::StripSpaces(call.GetPostBody()); |
259 | |
260 Json::Value request; | |
261 if (Toolbox::IsSHA1(stripped)) | |
262 { | |
263 // This is for compatibility with Orthanc <= 0.5.1. | |
264 request = stripped; | |
265 } | |
266 else if (!call.ParseJsonRequest(request)) | |
267 { | |
268 // Bad JSON request | |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
269 return false; |
402 | 270 } |
271 | |
272 if (request.isString()) | |
273 { | |
274 context.GetIndex().LogExportedResource(request.asString(), remote); | |
275 context.GetIndex().GetChildInstances(instances, request.asString()); | |
276 } | |
277 else if (request.isArray()) | |
278 { | |
279 for (Json::Value::ArrayIndex i = 0; i < request.size(); i++) | |
280 { | |
281 if (!request[i].isString()) | |
282 { | |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
283 return false; |
402 | 284 } |
285 | |
286 std::string stripped = Toolbox::StripSpaces(request[i].asString()); | |
287 if (!Toolbox::IsSHA1(stripped)) | |
288 { | |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
289 return false; |
402 | 290 } |
291 | |
292 context.GetIndex().LogExportedResource(stripped, remote); | |
293 | |
294 std::list<std::string> tmp; | |
295 context.GetIndex().GetChildInstances(tmp, stripped); | |
296 instances.merge(tmp); | |
297 assert(tmp.size() == 0); | |
298 } | |
299 } | |
300 else | |
301 { | |
302 // Neither a string, nor a list of strings. Bad request. | |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
303 return false; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
304 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
305 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
306 return true; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
307 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
308 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
309 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
310 static void DicomStore(RestApi::PostCall& call) |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
311 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
312 RETRIEVE_CONTEXT(call); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
313 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
314 std::string remote = call.GetUriComponent("id", ""); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
315 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
316 std::list<std::string> instances; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
317 if (!GetInstancesToExport(instances, remote, call)) |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
318 { |
402 | 319 return; |
320 } | |
321 | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
322 DicomUserConnection connection; |
231 | 323 ConnectToModality(connection, remote); |
324 | |
402 | 325 for (std::list<std::string>::const_iterator |
326 it = instances.begin(); it != instances.end(); it++) | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
327 { |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
328 LOG(INFO) << "Sending resource " << *it << " to modality \"" << remote << "\""; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
329 |
402 | 330 std::string dicom; |
331 context.ReadFile(dicom, *it, FileContentType_Dicom); | |
332 connection.Store(dicom); | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
333 } |
231 | 334 |
402 | 335 call.GetOutput().AnswerBuffer("{}", "application/json"); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
336 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
337 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
338 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
339 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 // System information ------------------------------------------------------- |
211 | 341 |
342 static void ServeRoot(RestApi::GetCall& call) | |
343 { | |
344 call.GetOutput().Redirect("app/explorer.html"); | |
345 } | |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 static void GetSystemInformation(RestApi::GetCall& call) |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 { |
238 | 349 Json::Value result = Json::objectValue; |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 result["Version"] = ORTHANC_VERSION; |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 result["Name"] = GetGlobalStringParameter("Name", ""); |
238 | 353 |
354 call.GetOutput().AnswerJson(result); | |
355 } | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
356 |
238 | 357 static void GetStatistics(RestApi::GetCall& call) |
358 { | |
359 RETRIEVE_CONTEXT(call); | |
360 Json::Value result = Json::objectValue; | |
361 context.GetIndex().ComputeStatistics(result); | |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 call.GetOutput().AnswerJson(result); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 |
342
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
365 static void GenerateUid(RestApi::GetCall& call) |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
366 { |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
367 std::string level = call.GetArgument("level", ""); |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
368 if (level == "patient") |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
369 { |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
370 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Patient), "text/plain"); |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
371 } |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
372 else if (level == "study") |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
373 { |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
374 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Study), "text/plain"); |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
375 } |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
376 else if (level == "series") |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
377 { |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
378 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series), "text/plain"); |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
379 } |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
380 else if (level == "instance") |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
381 { |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
382 call.GetOutput().AnswerBuffer(FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Instance), "text/plain"); |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
383 } |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
384 } |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
385 |
418
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
386 static void ExecuteScript(RestApi::PostCall& call) |
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
387 { |
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
388 std::string result; |
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
389 RETRIEVE_CONTEXT(call); |
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
390 context.GetLuaContext().Execute(result, call.GetPostBody()); |
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
391 call.GetOutput().AnswerBuffer(result, "text/plain"); |
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
392 } |
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
393 |
446 | 394 static void GetNowIsoString(RestApi::GetCall& call) |
395 { | |
396 call.GetOutput().AnswerBuffer(Toolbox::GetNowIsoString(), "text/plain"); | |
397 } | |
398 | |
399 | |
400 | |
418
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
401 |
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
402 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 |
211 | 404 // List all the patients, studies, series or instances ---------------------- |
405 | |
406 template <enum ResourceType resourceType> | |
407 static void ListResources(RestApi::GetCall& call) | |
408 { | |
409 RETRIEVE_CONTEXT(call); | |
410 | |
411 Json::Value result; | |
412 context.GetIndex().GetAllUuids(result, resourceType); | |
413 call.GetOutput().AnswerJson(result); | |
414 } | |
415 | |
212 | 416 template <enum ResourceType resourceType> |
417 static void GetSingleResource(RestApi::GetCall& call) | |
418 { | |
419 RETRIEVE_CONTEXT(call); | |
420 | |
421 Json::Value result; | |
422 if (context.GetIndex().LookupResource(result, call.GetUriComponent("id", ""), resourceType)) | |
423 { | |
424 call.GetOutput().AnswerJson(result); | |
425 } | |
426 } | |
427 | |
428 template <enum ResourceType resourceType> | |
429 static void DeleteSingleResource(RestApi::DeleteCall& call) | |
430 { | |
431 RETRIEVE_CONTEXT(call); | |
432 | |
433 Json::Value result; | |
434 if (context.GetIndex().DeleteResource(result, call.GetUriComponent("id", ""), resourceType)) | |
435 { | |
436 call.GetOutput().AnswerJson(result); | |
437 } | |
438 } | |
439 | |
211 | 440 |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
441 // Download of ZIP files ---------------------------------------------------- |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
442 |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
443 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
444 static std::string GetDirectoryNameInArchive(const Json::Value& resource, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
445 ResourceType resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
446 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
447 switch (resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
448 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
449 case ResourceType_Patient: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
450 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
451 std::string p = resource["MainDicomTags"]["PatientID"].asString(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
452 std::string n = resource["MainDicomTags"]["PatientName"].asString(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
453 return p + " " + n; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
454 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
455 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
456 case ResourceType_Study: |
253 | 457 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
458 return resource["MainDicomTags"]["StudyDescription"].asString(); |
253 | 459 } |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
460 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
461 case ResourceType_Series: |
253 | 462 { |
463 std::string d = resource["MainDicomTags"]["SeriesDescription"].asString(); | |
464 std::string m = resource["MainDicomTags"]["Modality"].asString(); | |
465 return m + " " + d; | |
466 } | |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
467 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
468 default: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
469 throw OrthancException(ErrorCode_InternalError); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
470 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
471 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
472 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
473 static bool CreateRootDirectoryInArchive(HierarchicalZipWriter& writer, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
474 ServerContext& context, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
475 const Json::Value& resource, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
476 ResourceType resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
477 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
478 if (resourceType == ResourceType_Patient) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
479 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
480 return true; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
481 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
482 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
483 ResourceType parentType = GetParentResourceType(resourceType); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
484 Json::Value parent; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
485 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
486 switch (resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
487 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
488 case ResourceType_Study: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
489 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
490 if (!context.GetIndex().LookupResource(parent, resource["ParentPatient"].asString(), parentType)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
491 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
492 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
493 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
494 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
495 break; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
496 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
497 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
498 case ResourceType_Series: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
499 if (!context.GetIndex().LookupResource(parent, resource["ParentStudy"].asString(), parentType) || |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
500 !CreateRootDirectoryInArchive(writer, context, parent, parentType)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
501 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
502 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
503 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
504 break; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
505 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
506 default: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
507 throw OrthancException(ErrorCode_NotImplemented); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
508 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
509 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
510 writer.OpenDirectory(GetDirectoryNameInArchive(parent, parentType).c_str()); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
511 return true; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
512 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
513 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
514 static bool ArchiveInstance(HierarchicalZipWriter& writer, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
515 ServerContext& context, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
516 const std::string& instancePublicId) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
517 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
518 Json::Value instance; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
519 if (!context.GetIndex().LookupResource(instance, instancePublicId, ResourceType_Instance)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
520 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
521 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
522 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
523 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
524 std::string filename = instance["MainDicomTags"]["SOPInstanceUID"].asString() + ".dcm"; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
525 writer.OpenFile(filename.c_str()); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
526 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
527 std::string dicom; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
528 context.ReadFile(dicom, instancePublicId, FileContentType_Dicom); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
529 writer.Write(dicom); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
530 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
531 return true; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
532 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
533 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
534 static bool ArchiveInternal(HierarchicalZipWriter& writer, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
535 ServerContext& context, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
536 const std::string& publicId, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
537 ResourceType resourceType, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
538 bool isFirstLevel) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
539 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
540 Json::Value resource; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
541 if (!context.GetIndex().LookupResource(resource, publicId, resourceType)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
542 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
543 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
544 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
545 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
546 if (isFirstLevel && |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
547 !CreateRootDirectoryInArchive(writer, context, resource, resourceType)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
548 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
549 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
550 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
551 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
552 writer.OpenDirectory(GetDirectoryNameInArchive(resource, resourceType).c_str()); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
553 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
554 switch (resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
555 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
556 case ResourceType_Patient: |
299 | 557 for (Json::Value::ArrayIndex i = 0; i < resource["Studies"].size(); i++) |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
558 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
559 std::string studyId = resource["Studies"][i].asString(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
560 if (!ArchiveInternal(writer, context, studyId, ResourceType_Study, false)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
561 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
562 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
563 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
564 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
565 break; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
566 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
567 case ResourceType_Study: |
299 | 568 for (Json::Value::ArrayIndex i = 0; i < resource["Series"].size(); i++) |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
569 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
570 std::string seriesId = resource["Series"][i].asString(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
571 if (!ArchiveInternal(writer, context, seriesId, ResourceType_Series, false)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
572 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
573 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
574 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
575 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
576 break; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
577 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
578 case ResourceType_Series: |
299 | 579 for (Json::Value::ArrayIndex i = 0; i < resource["Instances"].size(); i++) |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
580 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
581 if (!ArchiveInstance(writer, context, resource["Instances"][i].asString())) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
582 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
583 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
584 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
585 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
586 break; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
587 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
588 default: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
589 throw OrthancException(ErrorCode_InternalError); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
590 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
591 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
592 writer.CloseDirectory(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
593 return true; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
594 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
595 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
596 template <enum ResourceType resourceType> |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
597 static void GetArchive(RestApi::GetCall& call) |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
598 { |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
599 RETRIEVE_CONTEXT(call); |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
600 |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
601 // Create a RAII for the temporary file to manage the ZIP file |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
602 Toolbox::TemporaryFile tmp; |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
603 std::string id = call.GetUriComponent("id", ""); |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
604 |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
605 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
606 // Create a ZIP writer |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
607 HierarchicalZipWriter writer(tmp.GetPath().c_str()); |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
608 |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
609 // Store the requested resource into the ZIP |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
610 if (!ArchiveInternal(writer, context, id, resourceType, true)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
611 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
612 return; |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
613 } |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
614 } |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
615 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
616 // Prepare the sending of the ZIP file |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
617 FilesystemHttpSender sender(tmp.GetPath().c_str()); |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
618 sender.SetContentType("application/zip"); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
619 sender.SetDownloadFilename(id + ".zip"); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
620 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
621 // Send the ZIP |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
622 call.GetOutput().AnswerFile(sender); |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
623 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
624 // The temporary file is automatically removed thanks to the RAII |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
625 } |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
626 |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
627 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 // Changes API -------------------------------------------------------------- |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
629 |
231 | 630 static void GetSinceAndLimit(int64_t& since, |
631 unsigned int& limit, | |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
632 bool& last, |
231 | 633 const RestApi::GetCall& call) |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 static const unsigned int MAX_RESULTS = 100; |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
636 |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
637 if (call.HasArgument("last")) |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
638 { |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
639 last = true; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
640 return; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
641 } |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
642 |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
643 last = false; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
644 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
645 try |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
646 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
647 since = boost::lexical_cast<int64_t>(call.GetArgument("since", "0")); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
648 limit = boost::lexical_cast<unsigned int>(call.GetArgument("limit", "0")); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 catch (boost::bad_lexical_cast) |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 return; |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
655 if (limit == 0 || limit > MAX_RESULTS) |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
656 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
657 limit = MAX_RESULTS; |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
658 } |
231 | 659 } |
660 | |
661 static void GetChanges(RestApi::GetCall& call) | |
662 { | |
663 RETRIEVE_CONTEXT(call); | |
664 | |
665 //std::string filter = GetArgument(getArguments, "filter", ""); | |
666 int64_t since; | |
667 unsigned int limit; | |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
668 bool last; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
669 GetSinceAndLimit(since, limit, last, call); |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
671 Json::Value result; |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
672 if ((!last && context.GetIndex().GetChanges(result, since, limit)) || |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
673 ( last && context.GetIndex().GetLastChange(result))) |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
675 call.GetOutput().AnswerJson(result); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
676 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
677 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
678 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
679 |
413
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
680 static void DeleteChanges(RestApi::DeleteCall& call) |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
681 { |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
682 RETRIEVE_CONTEXT(call); |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
683 context.GetIndex().DeleteChanges(); |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
684 call.GetOutput().AnswerBuffer("", "text/plain"); |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
685 } |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
686 |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
687 |
231 | 688 static void GetExports(RestApi::GetCall& call) |
689 { | |
690 RETRIEVE_CONTEXT(call); | |
691 | |
692 int64_t since; | |
693 unsigned int limit; | |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
694 bool last; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
695 GetSinceAndLimit(since, limit, last, call); |
231 | 696 |
697 Json::Value result; | |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
698 if ((!last && context.GetIndex().GetExportedResources(result, since, limit)) || |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
699 ( last && context.GetIndex().GetLastExportedResource(result))) |
231 | 700 { |
701 call.GetOutput().AnswerJson(result); | |
702 } | |
703 } | |
704 | |
413
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
705 |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
706 static void DeleteExports(RestApi::DeleteCall& call) |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
707 { |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
708 RETRIEVE_CONTEXT(call); |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
709 context.GetIndex().DeleteExportedResources(); |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
710 call.GetOutput().AnswerBuffer("", "text/plain"); |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
711 } |
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
712 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 |
272
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
714 // Get information about a single patient ----------------------------------- |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
715 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
716 static void IsProtectedPatient(RestApi::GetCall& call) |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
717 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
718 RETRIEVE_CONTEXT(call); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
719 std::string publicId = call.GetUriComponent("id", ""); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
720 bool isProtected = context.GetIndex().IsProtectedPatient(publicId); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
721 call.GetOutput().AnswerBuffer(isProtected ? "1" : "0", "text/plain"); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
722 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
723 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
724 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
725 static void SetPatientProtection(RestApi::PutCall& call) |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
726 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
727 RETRIEVE_CONTEXT(call); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
728 std::string publicId = call.GetUriComponent("id", ""); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
729 std::string s = Toolbox::StripSpaces(call.GetPutBody()); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
730 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
731 if (s == "0") |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
732 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
733 context.GetIndex().SetProtectedPatient(publicId, false); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
734 call.GetOutput().AnswerBuffer("", "text/plain"); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
735 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
736 else if (s == "1") |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
737 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
738 context.GetIndex().SetProtectedPatient(publicId, true); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
739 call.GetOutput().AnswerBuffer("", "text/plain"); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
740 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
741 else |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
742 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
743 // Bad request |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
744 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
745 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
746 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
747 |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
748 // Get information about a single instance ---------------------------------- |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
749 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
750 static void GetInstanceFile(RestApi::GetCall& call) |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
751 { |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
752 RETRIEVE_CONTEXT(call); |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
753 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
754 std::string publicId = call.GetUriComponent("id", ""); |
233 | 755 context.AnswerFile(call.GetOutput(), publicId, FileContentType_Dicom); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
756 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
757 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
758 |
483
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
759 static void ExportInstanceFile(RestApi::PostCall& call) |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
760 { |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
761 RETRIEVE_CONTEXT(call); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
762 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
763 std::string publicId = call.GetUriComponent("id", ""); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
764 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
765 std::string dicom; |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
766 context.ReadFile(dicom, publicId, FileContentType_Dicom); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
767 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
768 Toolbox::WriteFile(dicom, call.GetPostBody()); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
769 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
770 call.GetOutput().AnswerBuffer("{}", "application/json"); |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
771 } |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
772 |
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
773 |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
774 template <bool simplify> |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
775 static void GetInstanceTags(RestApi::GetCall& call) |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
776 { |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
777 RETRIEVE_CONTEXT(call); |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
778 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
779 std::string publicId = call.GetUriComponent("id", ""); |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
780 |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
781 Json::Value full; |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
782 context.ReadJson(full, publicId); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
783 |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
784 if (simplify) |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
785 { |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
786 Json::Value simplified; |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
787 SimplifyTags(simplified, full); |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
788 call.GetOutput().AnswerJson(simplified); |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
789 } |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
790 else |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
791 { |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
792 call.GetOutput().AnswerJson(full); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
793 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
794 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
795 |
214 | 796 |
797 static void ListFrames(RestApi::GetCall& call) | |
798 { | |
799 RETRIEVE_CONTEXT(call); | |
800 | |
801 Json::Value instance; | |
802 if (context.GetIndex().LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance)) | |
803 { | |
804 unsigned int numberOfFrames = 1; | |
805 | |
806 try | |
807 { | |
808 Json::Value tmp = instance["MainDicomTags"]["NumberOfFrames"]; | |
809 numberOfFrames = boost::lexical_cast<unsigned int>(tmp.asString()); | |
810 } | |
811 catch (...) | |
812 { | |
813 } | |
814 | |
815 Json::Value result = Json::arrayValue; | |
816 for (unsigned int i = 0; i < numberOfFrames; i++) | |
817 { | |
818 result.append(i); | |
819 } | |
820 | |
821 call.GetOutput().AnswerJson(result); | |
822 } | |
823 } | |
824 | |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
825 |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
826 template <enum ImageExtractionMode mode> |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
827 static void GetImage(RestApi::GetCall& call) |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
828 { |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
829 RETRIEVE_CONTEXT(call); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
830 |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
831 std::string frameId = call.GetUriComponent("frame", "0"); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
832 |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
833 unsigned int frame; |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
834 try |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
835 { |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
836 frame = boost::lexical_cast<unsigned int>(frameId); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
837 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
838 catch (boost::bad_lexical_cast) |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
839 { |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
840 return; |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
841 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
842 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
843 std::string publicId = call.GetUriComponent("id", ""); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
844 std::string dicomContent, png; |
233 | 845 context.ReadFile(dicomContent, publicId, FileContentType_Dicom); |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
846 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
847 try |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
848 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
849 FromDcmtkBridge::ExtractPngImage(png, dicomContent, frame, mode); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
850 call.GetOutput().AnswerBuffer(png, "image/png"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
851 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
852 catch (OrthancException& e) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
853 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
854 if (e.GetErrorCode() == ErrorCode_ParameterOutOfRange) |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
855 { |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
856 // The frame number is out of the range for this DICOM |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
857 // instance, the resource is not existent |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
858 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
859 else |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
860 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
861 std::string root = ""; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
862 for (size_t i = 1; i < call.GetFullUri().size(); i++) |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
863 { |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
864 root += "../"; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
865 } |
218 | 866 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
867 call.GetOutput().Redirect(root + "app/images/unsupported.png"); |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
868 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
869 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
870 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
871 |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
872 |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
873 // Upload of DICOM files through HTTP --------------------------------------- |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
874 |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
875 static void UploadDicomFile(RestApi::PostCall& call) |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
876 { |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
877 RETRIEVE_CONTEXT(call); |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
878 |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
879 const std::string& postData = call.GetPostBody(); |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
880 if (postData.size() == 0) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
881 { |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
882 return; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
883 } |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
884 |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
885 LOG(INFO) << "Receiving a DICOM file of " << postData.size() << " bytes through HTTP"; |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
886 |
304 | 887 std::string publicId; |
888 StoreStatus status = context.Store(publicId, postData); | |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
889 Json::Value result = Json::objectValue; |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
890 |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
891 if (status != StoreStatus_Failure) |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
892 { |
304 | 893 result["ID"] = publicId; |
894 result["Path"] = GetBasePath(ResourceType_Instance, publicId); | |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
895 } |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
896 |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
418
diff
changeset
|
897 result["Status"] = EnumerationToString(status); |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
898 call.GetOutput().AnswerJson(result); |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
899 } |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
900 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
901 |
304 | 902 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
903 // DICOM bridge ------------------------------------------------------------- |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
904 |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
905 static bool IsExistingModality(const OrthancRestApi::SetOfStrings& modalities, |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
906 const std::string& id) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
907 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
908 return modalities.find(id) != modalities.end(); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
909 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
910 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
911 static void ListModalities(RestApi::GetCall& call) |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
912 { |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
913 RETRIEVE_MODALITIES(call); |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
914 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
915 Json::Value result = Json::arrayValue; |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
916 for (OrthancRestApi::SetOfStrings::const_iterator |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
917 it = modalities.begin(); it != modalities.end(); it++) |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
918 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 result.append(*it); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
920 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
921 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 call.GetOutput().AnswerJson(result); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
924 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
925 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
926 static void ListModalityOperations(RestApi::GetCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
927 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
928 RETRIEVE_MODALITIES(call); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
929 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
930 std::string id = call.GetUriComponent("id", ""); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
931 if (IsExistingModality(modalities, id)) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
932 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
933 Json::Value result = Json::arrayValue; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
934 result.append("find-patient"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
935 result.append("find-study"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
936 result.append("find-series"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
937 result.append("find"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
938 result.append("store"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
939 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
940 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
941 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
942 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
943 |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
944 |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
945 // Raw access to the DICOM tags of an instance ------------------------------ |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
946 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
947 static void GetRawContent(RestApi::GetCall& call) |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
948 { |
315 | 949 boost::mutex::scoped_lock lock(cacheMutex_); |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
950 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
951 RETRIEVE_CONTEXT(call); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
952 std::string id = call.GetUriComponent("id", ""); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
953 ParsedDicomFile& dicom = context.GetDicomFile(id); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
954 dicom.SendPathValue(call.GetOutput(), call.GetTrailingUri()); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
955 } |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
956 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
957 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
958 |
304 | 959 // Modification of DICOM instances ------------------------------------------ |
960 | |
311 | 961 namespace |
962 { | |
963 typedef std::set<DicomTag> Removals; | |
964 typedef std::map<DicomTag, std::string> Replacements; | |
350
8031f9cfe7fe
removal of old code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
349
diff
changeset
|
965 typedef std::map< std::pair<DicomRootLevel, std::string>, std::string> UidMap; |
311 | 966 } |
310 | 967 |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
968 static void ReplaceInstanceInternal(ParsedDicomFile& toModify, |
310 | 969 const Removals& removals, |
970 const Replacements& replacements, | |
312 | 971 DicomReplaceMode mode, |
972 bool removePrivateTags) | |
304 | 973 { |
312 | 974 if (removePrivateTags) |
975 { | |
976 toModify.RemovePrivateTags(); | |
977 } | |
978 | |
310 | 979 for (Removals::const_iterator it = removals.begin(); |
980 it != removals.end(); it++) | |
981 { | |
982 toModify.Remove(*it); | |
983 } | |
984 | |
985 for (Replacements::const_iterator it = replacements.begin(); | |
986 it != replacements.end(); it++) | |
987 { | |
988 toModify.Replace(it->first, it->second, mode); | |
989 } | |
990 | |
991 // A new SOP instance UID is automatically generated | |
992 std::string instanceUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Instance); | |
993 toModify.Replace(DICOM_TAG_SOP_INSTANCE_UID, instanceUid, DicomReplaceMode_InsertIfAbsent); | |
994 } | |
995 | |
996 | |
997 static void ParseRemovals(Removals& target, | |
998 const Json::Value& removals) | |
999 { | |
1000 if (!removals.isArray()) | |
304 | 1001 { |
1002 throw OrthancException(ErrorCode_BadRequest); | |
1003 } | |
1004 | |
310 | 1005 target.clear(); |
1006 | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1007 for (Json::Value::ArrayIndex i = 0; i < removals.size(); i++) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1008 { |
357
8d3a0db39967
fix of standalone builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1009 std::string name = removals[i].asString(); |
8d3a0db39967
fix of standalone builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1010 DicomTag tag = FromDcmtkBridge::ParseTag(name); |
310 | 1011 target.insert(tag); |
357
8d3a0db39967
fix of standalone builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1012 |
8d3a0db39967
fix of standalone builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1013 VLOG(1) << "Removal: " << name << " " << tag << std::endl; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1014 } |
310 | 1015 } |
1016 | |
1017 | |
1018 static void ParseReplacements(Replacements& target, | |
1019 const Json::Value& replacements) | |
1020 { | |
1021 if (!replacements.isObject()) | |
1022 { | |
1023 throw OrthancException(ErrorCode_BadRequest); | |
1024 } | |
1025 | |
1026 target.clear(); | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1027 |
304 | 1028 Json::Value::Members members = replacements.getMemberNames(); |
1029 for (size_t i = 0; i < members.size(); i++) | |
1030 { | |
1031 const std::string& name = members[i]; | |
1032 std::string value = replacements[name].asString(); | |
1033 | |
1034 DicomTag tag = FromDcmtkBridge::ParseTag(name); | |
310 | 1035 target[tag] = value; |
357
8d3a0db39967
fix of standalone builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1036 |
8d3a0db39967
fix of standalone builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
351
diff
changeset
|
1037 VLOG(1) << "Replacement: " << name << " " << tag << " == " << value << std::endl; |
304 | 1038 } |
1039 } | |
1040 | |
310 | 1041 |
311 | 1042 static std::string GeneratePatientName(ServerContext& context) |
1043 { | |
1044 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence); | |
1045 return "Anonymized" + boost::lexical_cast<std::string>(seq); | |
1046 } | |
1047 | |
1048 | |
310 | 1049 static void SetupAnonymization(Removals& removals, |
1050 Replacements& replacements) | |
1051 { | |
311 | 1052 // This is Table E.1-1 from PS 3.15-2008 - DICOM Part 15: Security and System Management Profiles |
310 | 1053 removals.insert(DicomTag(0x0008, 0x0014)); // Instance Creator UID |
311 | 1054 //removals.insert(DicomTag(0x0008, 0x0018)); // SOP Instance UID => set by ReplaceInstanceInternal() |
1055 removals.insert(DicomTag(0x0008, 0x0050)); // Accession Number | |
1056 removals.insert(DicomTag(0x0008, 0x0080)); // Institution Name | |
1057 removals.insert(DicomTag(0x0008, 0x0081)); // Institution Address | |
1058 removals.insert(DicomTag(0x0008, 0x0090)); // Referring Physician's Name | |
1059 removals.insert(DicomTag(0x0008, 0x0092)); // Referring Physician's Address | |
1060 removals.insert(DicomTag(0x0008, 0x0094)); // Referring Physician's Telephone Numbers | |
1061 removals.insert(DicomTag(0x0008, 0x1010)); // Station Name | |
1062 removals.insert(DicomTag(0x0008, 0x1030)); // Study Description | |
1063 removals.insert(DicomTag(0x0008, 0x103e)); // Series Description | |
1064 removals.insert(DicomTag(0x0008, 0x1040)); // Institutional Department Name | |
1065 removals.insert(DicomTag(0x0008, 0x1048)); // Physician(s) of Record | |
1066 removals.insert(DicomTag(0x0008, 0x1050)); // Performing Physicians' Name | |
1067 removals.insert(DicomTag(0x0008, 0x1060)); // Name of Physician(s) Reading Study | |
1068 removals.insert(DicomTag(0x0008, 0x1070)); // Operators' Name | |
1069 removals.insert(DicomTag(0x0008, 0x1080)); // Admitting Diagnoses Description | |
1070 removals.insert(DicomTag(0x0008, 0x1155)); // Referenced SOP Instance UID | |
1071 removals.insert(DicomTag(0x0008, 0x2111)); // Derivation Description | |
1072 removals.insert(DicomTag(0x0010, 0x0010)); // Patient's Name | |
1073 removals.insert(DicomTag(0x0010, 0x0020)); // Patient ID | |
1074 removals.insert(DicomTag(0x0010, 0x0030)); // Patient's Birth Date | |
1075 removals.insert(DicomTag(0x0010, 0x0032)); // Patient's Birth Time | |
1076 removals.insert(DicomTag(0x0010, 0x0040)); // Patient's Sex | |
1077 removals.insert(DicomTag(0x0010, 0x1000)); // Other Patient Ids | |
1078 removals.insert(DicomTag(0x0010, 0x1001)); // Other Patient Names | |
1079 removals.insert(DicomTag(0x0010, 0x1010)); // Patient's Age | |
1080 removals.insert(DicomTag(0x0010, 0x1020)); // Patient's Size | |
1081 removals.insert(DicomTag(0x0010, 0x1030)); // Patient's Weight | |
1082 removals.insert(DicomTag(0x0010, 0x1090)); // Medical Record Locator | |
1083 removals.insert(DicomTag(0x0010, 0x2160)); // Ethnic Group | |
1084 removals.insert(DicomTag(0x0010, 0x2180)); // Occupation | |
1085 removals.insert(DicomTag(0x0010, 0x21b0)); // Additional Patient's History | |
1086 removals.insert(DicomTag(0x0010, 0x4000)); // Patient Comments | |
1087 removals.insert(DicomTag(0x0018, 0x1000)); // Device Serial Number | |
1088 removals.insert(DicomTag(0x0018, 0x1030)); // Protocol Name | |
1089 //removals.insert(DicomTag(0x0020, 0x000d)); // Study Instance UID => generated below | |
1090 //removals.insert(DicomTag(0x0020, 0x000e)); // Series Instance UID => generated below | |
1091 removals.insert(DicomTag(0x0020, 0x0010)); // Study ID | |
1092 removals.insert(DicomTag(0x0020, 0x0052)); // Frame of Reference UID | |
1093 removals.insert(DicomTag(0x0020, 0x0200)); // Synchronization Frame of Reference UID | |
1094 removals.insert(DicomTag(0x0020, 0x4000)); // Image Comments | |
1095 removals.insert(DicomTag(0x0040, 0x0275)); // Request Attributes Sequence | |
1096 removals.insert(DicomTag(0x0040, 0xa124)); // UID | |
1097 removals.insert(DicomTag(0x0040, 0xa730)); // Content Sequence | |
1098 removals.insert(DicomTag(0x0088, 0x0140)); // Storage Media File-set UID | |
1099 removals.insert(DicomTag(0x3006, 0x0024)); // Referenced Frame of Reference UID | |
1100 removals.insert(DicomTag(0x3006, 0x00c2)); // Related Frame of Reference UID | |
1101 | |
1102 // Some more removals (from the experience of DICOM files at the CHU of Liege) | |
1103 removals.insert(DicomTag(0x0010, 0x1040)); // Patient's Address | |
1104 removals.insert(DicomTag(0x0032, 0x1032)); // Requesting Physician | |
463
005aaeb63414
anonymization of PatientTelephoneNumbers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
446
diff
changeset
|
1105 removals.insert(DicomTag(0x0010, 0x2154)); // PatientTelephoneNumbers |
311 | 1106 |
1107 // Set the DeidentificationMethod tag | |
1108 replacements.insert(std::make_pair(DicomTag(0x0012, 0x0063), "Orthanc " ORTHANC_VERSION " - PS 3.15-2008 Table E.1-1")); | |
1109 | |
1110 // Set the PatientIdentityRemoved | |
1111 replacements.insert(std::make_pair(DicomTag(0x0012, 0x0062), "YES")); | |
1112 | |
321 | 1113 // Generate random study UID if not specified |
1114 if (replacements.find(DICOM_TAG_STUDY_INSTANCE_UID) == replacements.end()) | |
1115 { | |
1116 replacements.insert(std::make_pair(DICOM_TAG_STUDY_INSTANCE_UID, | |
1117 FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Study))); | |
1118 } | |
1119 | |
1120 // Generate random series UID if not specified | |
1121 if (replacements.find(DICOM_TAG_SERIES_INSTANCE_UID) == replacements.end()) | |
1122 { | |
1123 replacements.insert(std::make_pair(DICOM_TAG_SERIES_INSTANCE_UID, | |
1124 FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series))); | |
1125 } | |
310 | 1126 } |
1127 | |
1128 | |
1129 static bool ParseModifyRequest(Removals& removals, | |
1130 Replacements& replacements, | |
312 | 1131 bool& removePrivateTags, |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1132 const RestApi::PostCall& call) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1133 { |
312 | 1134 removePrivateTags = false; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1135 Json::Value request; |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1136 if (call.ParseJsonRequest(request) && |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1137 request.isObject()) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1138 { |
310 | 1139 Json::Value removalsPart = Json::arrayValue; |
1140 Json::Value replacementsPart = Json::objectValue; | |
304 | 1141 |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1142 if (request.isMember("Remove")) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1143 { |
310 | 1144 removalsPart = request["Remove"]; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1145 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1146 |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1147 if (request.isMember("Replace")) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1148 { |
310 | 1149 replacementsPart = request["Replace"]; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1150 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1151 |
312 | 1152 if (request.isMember("RemovePrivateTags")) |
1153 { | |
1154 removePrivateTags = true; | |
1155 } | |
1156 | |
310 | 1157 ParseRemovals(removals, removalsPart); |
1158 ParseReplacements(replacements, replacementsPart); | |
1159 | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1160 return true; |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1161 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1162 else |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1163 { |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1164 return false; |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1165 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1166 } |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1167 |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1168 |
311 | 1169 static bool ParseAnonymizationRequest(Removals& removals, |
1170 Replacements& replacements, | |
1171 bool& removePrivateTags, | |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1172 RestApi::PostCall& call) |
311 | 1173 { |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1174 RETRIEVE_CONTEXT(call); |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1175 |
311 | 1176 removePrivateTags = true; |
1177 | |
1178 Json::Value request; | |
1179 if (call.ParseJsonRequest(request) && | |
1180 request.isObject()) | |
1181 { | |
1182 Json::Value keepPart = Json::arrayValue; | |
312 | 1183 Json::Value removalsPart = Json::arrayValue; |
1184 Json::Value replacementsPart = Json::objectValue; | |
1185 | |
311 | 1186 if (request.isMember("Keep")) |
1187 { | |
1188 keepPart = request["Keep"]; | |
1189 } | |
1190 | |
1191 if (request.isMember("KeepPrivateTags")) | |
1192 { | |
1193 removePrivateTags = false; | |
1194 } | |
1195 | |
312 | 1196 if (request.isMember("Replace")) |
1197 { | |
1198 replacementsPart = request["Replace"]; | |
1199 } | |
1200 | |
311 | 1201 Removals toKeep; |
1202 ParseRemovals(toKeep, keepPart); | |
1203 | |
1204 SetupAnonymization(removals, replacements); | |
1205 | |
1206 for (Removals::iterator it = toKeep.begin(); it != toKeep.end(); it++) | |
1207 { | |
1208 removals.erase(*it); | |
1209 } | |
1210 | |
312 | 1211 Removals additionalRemovals; |
1212 ParseRemovals(additionalRemovals, removalsPart); | |
1213 | |
1214 for (Removals::iterator it = additionalRemovals.begin(); | |
1215 it != additionalRemovals.end(); it++) | |
1216 { | |
321 | 1217 removals.insert(*it); |
312 | 1218 } |
1219 | |
1220 ParseReplacements(replacements, replacementsPart); | |
1221 | |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1222 // Generate random Patient's Name if none is specified |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1223 if (replacements.find(DicomTag(0x0010, 0x0010)) == replacements.end()) |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1224 { |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1225 replacements.insert(std::make_pair(DicomTag(0x0010, 0x0010), GeneratePatientName(context))); |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1226 } |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1227 |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1228 // Generate random Patient's ID if none is specified |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1229 if (replacements.find(DICOM_TAG_PATIENT_ID) == replacements.end()) |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1230 { |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1231 replacements.insert(std::make_pair(DICOM_TAG_PATIENT_ID, |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1232 FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Patient))); |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1233 } |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1234 |
311 | 1235 return true; |
1236 } | |
1237 else | |
1238 { | |
1239 return false; | |
1240 } | |
1241 } | |
1242 | |
1243 | |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1244 static void AnonymizeOrModifyInstance(Removals& removals, |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1245 Replacements& replacements, |
314 | 1246 bool removePrivateTags, |
1247 RestApi::PostCall& call) | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1248 { |
315 | 1249 boost::mutex::scoped_lock lock(cacheMutex_); |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1250 RETRIEVE_CONTEXT(call); |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1251 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1252 std::string id = call.GetUriComponent("id", ""); |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1253 ParsedDicomFile& dicom = context.GetDicomFile(id); |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1254 |
314 | 1255 std::auto_ptr<ParsedDicomFile> modified(dicom.Clone()); |
1256 ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags); | |
1257 modified->Answer(call.GetOutput()); | |
1258 } | |
1259 | |
1260 | |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1261 static bool RetrieveMappedUid(ParsedDicomFile& dicom, |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1262 DicomRootLevel level, |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1263 Replacements& replacements, |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1264 UidMap& uidMap) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1265 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1266 std::auto_ptr<DicomTag> tag; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1267 if (level == DicomRootLevel_Series) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1268 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1269 tag.reset(new DicomTag(DICOM_TAG_SERIES_INSTANCE_UID)); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1270 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1271 else |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1272 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1273 assert(level == DicomRootLevel_Study); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1274 tag.reset(new DicomTag(DICOM_TAG_STUDY_INSTANCE_UID)); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1275 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1276 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1277 std::string original; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1278 if (!dicom.GetTagValue(original, *tag)) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1279 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1280 throw OrthancException(ErrorCode_InternalError); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1281 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1282 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1283 std::string mapped; |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1284 bool isNew; |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1285 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1286 UidMap::const_iterator previous = uidMap.find(std::make_pair(level, original)); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1287 if (previous == uidMap.end()) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1288 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1289 mapped = FromDcmtkBridge::GenerateUniqueIdentifier(level); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1290 uidMap.insert(std::make_pair(std::make_pair(level, original), mapped)); |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1291 isNew = true; |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1292 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1293 else |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1294 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1295 mapped = previous->second; |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1296 isNew = false; |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1297 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1298 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1299 replacements[*tag] = mapped; |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1300 return isNew; |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1301 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1302 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1303 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1304 static void AnonymizeOrModifyResource(Removals& removals, |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1305 Replacements& replacements, |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1306 bool removePrivateTags, |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1307 MetadataType metadataType, |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1308 ChangeType changeType, |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1309 ResourceType resourceType, |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1310 RestApi::PostCall& call) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1311 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1312 typedef std::list<std::string> Instances; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1313 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1314 bool isFirst = true; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1315 Json::Value result(Json::objectValue); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1316 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1317 boost::mutex::scoped_lock lock(cacheMutex_); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1318 RETRIEVE_CONTEXT(call); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1319 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1320 Instances instances; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1321 std::string id = call.GetUriComponent("id", ""); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1322 context.GetIndex().GetChildInstances(instances, id); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1323 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1324 if (instances.size() == 0) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1325 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1326 return; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1327 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1328 |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1329 |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1330 /** |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1331 * Loop over all the instances of the resource. |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1332 **/ |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1333 |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1334 UidMap uidMap; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1335 for (Instances::const_iterator it = instances.begin(); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1336 it != instances.end(); it++) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1337 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1338 LOG(INFO) << "Modifying instance " << *it; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1339 ParsedDicomFile& original = context.GetDicomFile(*it); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1340 |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1341 bool isNewSeries = RetrieveMappedUid(original, DicomRootLevel_Series, replacements, uidMap); |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1342 |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1343 bool isNewStudy = false; |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1344 if (resourceType == ResourceType_Study || |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1345 resourceType == ResourceType_Patient) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1346 { |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1347 isNewStudy = RetrieveMappedUid(original, DicomRootLevel_Study, replacements, uidMap); |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1348 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1349 |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1350 /** |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1351 * Compute the resulting DICOM instance and store it into the Orthanc store. |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1352 **/ |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1353 |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1354 std::auto_ptr<ParsedDicomFile> modified(original.Clone()); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1355 ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1356 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1357 std::string modifiedInstance; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1358 if (context.Store(modifiedInstance, modified->GetDicom()) != StoreStatus_Success) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1359 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1360 LOG(ERROR) << "Error while storing a modified instance " << *it; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1361 return; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1362 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1363 |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1364 |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1365 /** |
443
be93b666ed79
link anonymized to original resource in OrthancExplorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
1366 * Record metadata information (AnonymizedFrom/ModifiedFrom). |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1367 **/ |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1368 |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1369 DicomInstanceHasher modifiedHasher = modified->GetHasher(); |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1370 DicomInstanceHasher originalHasher = original.GetHasher(); |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1371 |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1372 if (isNewSeries) |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1373 { |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1374 context.GetIndex().SetMetadata(modifiedHasher.HashSeries(), |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1375 metadataType, originalHasher.HashSeries()); |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1376 } |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1377 |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1378 if (isNewStudy) |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1379 { |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1380 context.GetIndex().SetMetadata(modifiedHasher.HashStudy(), |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1381 metadataType, originalHasher.HashStudy()); |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1382 } |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1383 |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1384 assert(*it == originalHasher.HashInstance()); |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1385 assert(modifiedInstance == modifiedHasher.HashInstance()); |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1386 context.GetIndex().SetMetadata(modifiedInstance, metadataType, *it); |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1387 |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1388 |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1389 /** |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1390 * Compute the JSON object that is returned by the REST call. |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1391 **/ |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1392 |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1393 if (isFirst) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1394 { |
443
be93b666ed79
link anonymized to original resource in OrthancExplorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
1395 context.GetIndex().SetMetadata(modifiedHasher.HashPatient(), |
be93b666ed79
link anonymized to original resource in OrthancExplorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
1396 metadataType, originalHasher.HashPatient()); |
be93b666ed79
link anonymized to original resource in OrthancExplorer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
1397 |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1398 std::string newId; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1399 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1400 switch (resourceType) |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1401 { |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1402 case ResourceType_Series: |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1403 newId = modifiedHasher.HashSeries(); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1404 break; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1405 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1406 case ResourceType_Study: |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1407 newId = modifiedHasher.HashStudy(); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1408 break; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1409 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1410 case ResourceType_Patient: |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1411 newId = modifiedHasher.HashPatient(); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1412 break; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1413 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1414 default: |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1415 throw OrthancException(ErrorCode_InternalError); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1416 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1417 |
434
ccf3a0a43dac
EnumerationDictionary
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
418
diff
changeset
|
1418 result["Type"] = EnumerationToString(resourceType); |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1419 result["ID"] = newId; |
348
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1420 result["Path"] = GetBasePath(resourceType, newId); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1421 result["PatientID"] = modifiedHasher.HashPatient(); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1422 isFirst = false; |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1423 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1424 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1425 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1426 call.GetOutput().AnswerJson(result); |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1427 } |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1428 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1429 |
1082e8121d10
refactoring anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
344
diff
changeset
|
1430 |
314 | 1431 static void ModifyInstance(RestApi::PostCall& call) |
1432 { | |
310 | 1433 Removals removals; |
1434 Replacements replacements; | |
312 | 1435 bool removePrivateTags; |
310 | 1436 |
312 | 1437 if (ParseModifyRequest(removals, replacements, removePrivateTags, call)) |
304 | 1438 { |
314 | 1439 AnonymizeOrModifyInstance(removals, replacements, removePrivateTags, call); |
304 | 1440 } |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1441 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1442 |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1443 |
311 | 1444 static void AnonymizeInstance(RestApi::PostCall& call) |
1445 { | |
1446 Removals removals; | |
1447 Replacements replacements; | |
1448 bool removePrivateTags; | |
1449 | |
1450 if (ParseAnonymizationRequest(removals, replacements, removePrivateTags, call)) | |
1451 { | |
314 | 1452 AnonymizeOrModifyInstance(removals, replacements, removePrivateTags, call); |
311 | 1453 } |
1454 } | |
1455 | |
1456 | |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1457 static void ModifySeriesInplace(RestApi::PostCall& call) |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1458 { |
310 | 1459 Removals removals; |
1460 Replacements replacements; | |
312 | 1461 bool removePrivateTags; |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1462 |
312 | 1463 if (ParseModifyRequest(removals, replacements, removePrivateTags, call)) |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1464 { |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1465 AnonymizeOrModifyResource(removals, replacements, removePrivateTags, |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1466 MetadataType_ModifiedFrom, ChangeType_ModifiedSeries, |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1467 ResourceType_Series, call); |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1468 } |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1469 } |
315 | 1470 |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1471 |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1472 static void AnonymizeSeriesInplace(RestApi::PostCall& call) |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1473 { |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1474 Removals removals; |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1475 Replacements replacements; |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1476 bool removePrivateTags; |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1477 |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1478 if (ParseAnonymizationRequest(removals, replacements, removePrivateTags, call)) |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1479 { |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1480 AnonymizeOrModifyResource(removals, replacements, removePrivateTags, |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1481 MetadataType_AnonymizedFrom, ChangeType_AnonymizedSeries, |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1482 ResourceType_Series, call); |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1483 } |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1484 } |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1485 |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1486 |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1487 static void ModifyStudyInplace(RestApi::PostCall& call) |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1488 { |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1489 Removals removals; |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1490 Replacements replacements; |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1491 bool removePrivateTags; |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1492 |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1493 if (ParseModifyRequest(removals, replacements, removePrivateTags, call)) |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1494 { |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1495 AnonymizeOrModifyResource(removals, replacements, removePrivateTags, |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1496 MetadataType_ModifiedFrom, ChangeType_ModifiedStudy, |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1497 ResourceType_Study, call); |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1498 } |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1499 } |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1500 |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1501 |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1502 static void AnonymizeStudyInplace(RestApi::PostCall& call) |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1503 { |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1504 Removals removals; |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1505 Replacements replacements; |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1506 bool removePrivateTags; |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1507 |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1508 if (ParseAnonymizationRequest(removals, replacements, removePrivateTags, call)) |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1509 { |
349
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1510 AnonymizeOrModifyResource(removals, replacements, removePrivateTags, |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1511 MetadataType_AnonymizedFrom, ChangeType_AnonymizedStudy, |
c5edf0cc6e95
switch to refactored version
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
348
diff
changeset
|
1512 ResourceType_Study, call); |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1513 } |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1514 } |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1515 |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1516 |
351 | 1517 static void ModifyPatientInplace(RestApi::PostCall& call) |
1518 { | |
1519 Removals removals; | |
1520 Replacements replacements; | |
1521 bool removePrivateTags; | |
1522 | |
1523 if (ParseModifyRequest(removals, replacements, removePrivateTags, call)) | |
1524 { | |
1525 AnonymizeOrModifyResource(removals, replacements, removePrivateTags, | |
1526 MetadataType_ModifiedFrom, ChangeType_ModifiedPatient, | |
1527 ResourceType_Patient, call); | |
1528 } | |
1529 } | |
1530 | |
1531 | |
1532 static void AnonymizePatientInplace(RestApi::PostCall& call) | |
1533 { | |
1534 Removals removals; | |
1535 Replacements replacements; | |
1536 bool removePrivateTags; | |
1537 | |
1538 if (ParseAnonymizationRequest(removals, replacements, removePrivateTags, call)) | |
1539 { | |
1540 AnonymizeOrModifyResource(removals, replacements, removePrivateTags, | |
1541 MetadataType_AnonymizedFrom, ChangeType_AnonymizedPatient, | |
1542 ResourceType_Patient, call); | |
1543 } | |
1544 } | |
1545 | |
1546 | |
436
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1547 // Handling of metadata ----------------------------------------------------- |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1548 |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1549 static void ListMetadata(RestApi::GetCall& call) |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1550 { |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1551 RETRIEVE_CONTEXT(call); |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1552 |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1553 std::string publicId = call.GetUriComponent("id", ""); |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1554 std::list<MetadataType> metadata; |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1555 if (context.GetIndex().ListAvailableMetadata(metadata, publicId)) |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1556 { |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1557 Json::Value result = Json::arrayValue; |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1558 |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1559 for (std::list<MetadataType>::const_iterator |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1560 it = metadata.begin(); it != metadata.end(); it++) |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1561 { |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1562 result.append(EnumerationToString(*it)); |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1563 } |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1564 |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1565 call.GetOutput().AnswerJson(result); |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1566 } |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1567 } |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1568 |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1569 |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1570 static void GetMetadata(RestApi::GetCall& call) |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1571 { |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1572 RETRIEVE_CONTEXT(call); |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1573 |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1574 std::string publicId = call.GetUriComponent("id", ""); |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1575 std::string name = call.GetUriComponent("name", ""); |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1576 MetadataType metadata = StringToMetadata(name); |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1577 |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1578 std::string value; |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1579 if (context.GetIndex().LookupMetadata(value, publicId, metadata)) |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1580 { |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1581 call.GetOutput().AnswerBuffer(value, "text/plain"); |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1582 } |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1583 } |
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1584 |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
1585 |
438 | 1586 static void DeleteMetadata(RestApi::DeleteCall& call) |
1587 { | |
1588 RETRIEVE_CONTEXT(call); | |
1589 | |
1590 std::string publicId = call.GetUriComponent("id", ""); | |
1591 std::string name = call.GetUriComponent("name", ""); | |
1592 MetadataType metadata = StringToMetadata(name); | |
1593 | |
1594 if (metadata >= MetadataType_StartUser && | |
1595 metadata <= MetadataType_EndUser) | |
1596 { | |
1597 // It is forbidden to modify internal metadata | |
1598 context.GetIndex().DeleteMetadata(publicId, metadata); | |
1599 call.GetOutput().AnswerBuffer("", "text/plain"); | |
1600 } | |
1601 } | |
1602 | |
1603 | |
437 | 1604 static void SetMetadata(RestApi::PutCall& call) |
1605 { | |
1606 RETRIEVE_CONTEXT(call); | |
1607 | |
1608 std::string publicId = call.GetUriComponent("id", ""); | |
1609 std::string name = call.GetUriComponent("name", ""); | |
1610 MetadataType metadata = StringToMetadata(name); | |
1611 std::string value = call.GetPutBody(); | |
1612 | |
1613 if (metadata >= MetadataType_StartUser && | |
1614 metadata <= MetadataType_EndUser) | |
1615 { | |
1616 // It is forbidden to modify internal metadata | |
1617 context.GetIndex().SetMetadata(publicId, metadata, value); | |
1618 call.GetOutput().AnswerBuffer("", "text/plain"); | |
1619 } | |
1620 } | |
1621 | |
1622 | |
440
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1623 static void GetResourceStatistics(RestApi::GetCall& call) |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1624 { |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1625 RETRIEVE_CONTEXT(call); |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1626 std::string publicId = call.GetUriComponent("id", ""); |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1627 Json::Value result; |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1628 context.GetIndex().GetStatistics(result, publicId); |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1629 call.GetOutput().AnswerJson(result); |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1630 } |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1631 |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1632 |
437 | 1633 |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1634 // Orthanc Peers ------------------------------------------------------------ |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1635 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1636 static bool IsExistingPeer(const OrthancRestApi::SetOfStrings& peers, |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1637 const std::string& id) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1638 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1639 return peers.find(id) != peers.end(); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1640 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1641 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1642 static void ListPeers(RestApi::GetCall& call) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1643 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1644 RETRIEVE_PEERS(call); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1645 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1646 Json::Value result = Json::arrayValue; |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1647 for (OrthancRestApi::SetOfStrings::const_iterator |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1648 it = peers.begin(); it != peers.end(); it++) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1649 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1650 result.append(*it); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1651 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1652 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1653 call.GetOutput().AnswerJson(result); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1654 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1655 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1656 static void ListPeerOperations(RestApi::GetCall& call) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1657 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1658 RETRIEVE_PEERS(call); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1659 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1660 std::string id = call.GetUriComponent("id", ""); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1661 if (IsExistingPeer(peers, id)) |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1662 { |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1663 Json::Value result = Json::arrayValue; |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1664 result.append("store"); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1665 call.GetOutput().AnswerJson(result); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1666 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1667 } |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1668 |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1669 static void PeerStore(RestApi::PostCall& call) |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1670 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1671 RETRIEVE_CONTEXT(call); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1672 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1673 std::string remote = call.GetUriComponent("id", ""); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1674 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1675 std::list<std::string> instances; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1676 if (!GetInstancesToExport(instances, remote, call)) |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1677 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1678 return; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1679 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1680 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1681 std::string url, username, password; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1682 GetOrthancPeer(remote, url, username, password); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1683 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1684 // Configure the HTTP client |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1685 HttpClient client; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1686 if (username.size() != 0 && password.size() != 0) |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1687 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1688 client.SetCredentials(username.c_str(), password.c_str()); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1689 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1690 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1691 client.SetUrl(url + "instances"); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1692 client.SetMethod(HttpMethod_Post); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1693 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1694 // Loop over the instances that are to be sent |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1695 for (std::list<std::string>::const_iterator |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1696 it = instances.begin(); it != instances.end(); it++) |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1697 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1698 LOG(INFO) << "Sending resource " << *it << " to peer \"" << remote << "\""; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1699 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1700 context.ReadFile(client.AccessPostData(), *it, FileContentType_Dicom); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1701 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1702 std::string answer; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1703 if (!client.Apply(answer)) |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1704 { |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1705 LOG(ERROR) << "Unable to send resource " << *it << " to peer \"" << remote << "\""; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1706 return; |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1707 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1708 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1709 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1710 call.GetOutput().AnswerBuffer("{}", "application/json"); |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1711 } |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1712 |
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1713 |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1714 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1715 |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1716 |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1717 // Registration of the various REST handlers -------------------------------- |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1718 |
230 | 1719 OrthancRestApi::OrthancRestApi(ServerContext& context) : |
224
4eb0c7ce86c9
refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
1720 context_(context) |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1721 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1722 GetListOfDicomModalities(modalities_); |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1723 GetListOfOrthancPeers(peers_); |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1724 |
211 | 1725 Register("/", ServeRoot); |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1726 Register("/system", GetSystemInformation); |
238 | 1727 Register("/statistics", GetStatistics); |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1728 Register("/changes", GetChanges); |
413
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
1729 Register("/changes", DeleteChanges); |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1730 Register("/exports", GetExports); |
413
47d63c941902
clearing /exports and /changes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
403
diff
changeset
|
1731 Register("/exports", DeleteExports); |
211 | 1732 |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
1733 Register("/instances", UploadDicomFile); |
211 | 1734 Register("/instances", ListResources<ResourceType_Instance>); |
1735 Register("/patients", ListResources<ResourceType_Patient>); | |
1736 Register("/series", ListResources<ResourceType_Series>); | |
1737 Register("/studies", ListResources<ResourceType_Study>); | |
212 | 1738 |
1739 Register("/instances/{id}", DeleteSingleResource<ResourceType_Instance>); | |
1740 Register("/instances/{id}", GetSingleResource<ResourceType_Instance>); | |
1741 Register("/patients/{id}", DeleteSingleResource<ResourceType_Patient>); | |
1742 Register("/patients/{id}", GetSingleResource<ResourceType_Patient>); | |
1743 Register("/series/{id}", DeleteSingleResource<ResourceType_Series>); | |
1744 Register("/series/{id}", GetSingleResource<ResourceType_Series>); | |
1745 Register("/studies/{id}", DeleteSingleResource<ResourceType_Study>); | |
1746 Register("/studies/{id}", GetSingleResource<ResourceType_Study>); | |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
1747 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
1748 Register("/patients/{id}/archive", GetArchive<ResourceType_Patient>); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
1749 Register("/studies/{id}/archive", GetArchive<ResourceType_Study>); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
1750 Register("/series/{id}/archive", GetArchive<ResourceType_Series>); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1751 |
440
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1752 Register("/instances/{id}/statistics", GetResourceStatistics); |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1753 Register("/patients/{id}/statistics", GetResourceStatistics); |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1754 Register("/studies/{id}/statistics", GetResourceStatistics); |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1755 Register("/series/{id}/statistics", GetResourceStatistics); |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
1756 |
437 | 1757 Register("/instances/{id}/metadata", ListMetadata); |
438 | 1758 Register("/instances/{id}/metadata/{name}", DeleteMetadata); |
437 | 1759 Register("/instances/{id}/metadata/{name}", GetMetadata); |
1760 Register("/instances/{id}/metadata/{name}", SetMetadata); | |
1761 Register("/patients/{id}/metadata", ListMetadata); | |
438 | 1762 Register("/patients/{id}/metadata/{name}", DeleteMetadata); |
437 | 1763 Register("/patients/{id}/metadata/{name}", GetMetadata); |
1764 Register("/patients/{id}/metadata/{name}", SetMetadata); | |
1765 Register("/series/{id}/metadata", ListMetadata); | |
438 | 1766 Register("/series/{id}/metadata/{name}", DeleteMetadata); |
437 | 1767 Register("/series/{id}/metadata/{name}", GetMetadata); |
1768 Register("/series/{id}/metadata/{name}", SetMetadata); | |
1769 Register("/studies/{id}/metadata", ListMetadata); | |
438 | 1770 Register("/studies/{id}/metadata/{name}", DeleteMetadata); |
437 | 1771 Register("/studies/{id}/metadata/{name}", GetMetadata); |
1772 Register("/studies/{id}/metadata/{name}", SetMetadata); | |
436
d51186bf7602
read access to metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
434
diff
changeset
|
1773 |
272
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
1774 Register("/patients/{id}/protected", IsProtectedPatient); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
1775 Register("/patients/{id}/protected", SetPatientProtection); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1776 Register("/instances/{id}/file", GetInstanceFile); |
483
8c3573d28868
export dicom instances to the filesystem
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
465
diff
changeset
|
1777 Register("/instances/{id}/export", ExportInstanceFile); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1778 Register("/instances/{id}/tags", GetInstanceTags<false>); |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1779 Register("/instances/{id}/simplified-tags", GetInstanceTags<true>); |
214 | 1780 Register("/instances/{id}/frames", ListFrames); |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
1781 Register("/instances/{id}/content/*", GetRawContent); |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1782 |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1783 Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1784 Register("/instances/{id}/frames/{frame}/image-uint8", GetImage<ImageExtractionMode_UInt8>); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1785 Register("/instances/{id}/frames/{frame}/image-uint16", GetImage<ImageExtractionMode_UInt16>); |
465
7a966b440f19
signed images to PNG
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
463
diff
changeset
|
1786 Register("/instances/{id}/frames/{frame}/image-int16", GetImage<ImageExtractionMode_Int16>); |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1787 Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1788 Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1789 Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>); |
465
7a966b440f19
signed images to PNG
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
463
diff
changeset
|
1790 Register("/instances/{id}/image-int16", GetImage<ImageExtractionMode_Int16>); |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1791 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1792 Register("/modalities", ListModalities); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1793 Register("/modalities/{id}", ListModalityOperations); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1794 Register("/modalities/{id}/find-patient", DicomFindPatient); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1795 Register("/modalities/{id}/find-study", DicomFindStudy); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1796 Register("/modalities/{id}/find-series", DicomFindSeries); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1797 Register("/modalities/{id}/find", DicomFind); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1798 Register("/modalities/{id}/store", DicomStore); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1799 |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1800 Register("/peers", ListPeers); |
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1801 Register("/peers/{id}", ListPeerOperations); |
485
bdbde1fbfab3
send resources through HTTP
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
484
diff
changeset
|
1802 Register("/peers/{id}/store", PeerStore); |
484
b8ace6fc1d1f
preparation for handling Orthanc peers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
483
diff
changeset
|
1803 |
304 | 1804 Register("/instances/{id}/modify", ModifyInstance); |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1805 Register("/series/{id}/modify", ModifySeriesInplace); |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1806 Register("/studies/{id}/modify", ModifyStudyInplace); |
351 | 1807 Register("/patients/{id}/modify", ModifyPatientInplace); |
311 | 1808 |
1809 Register("/instances/{id}/anonymize", AnonymizeInstance); | |
316
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1810 Register("/series/{id}/anonymize", AnonymizeSeriesInplace); |
d526ac73c886
anonymization of studies and series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
315
diff
changeset
|
1811 Register("/studies/{id}/anonymize", AnonymizeStudyInplace); |
351 | 1812 Register("/patients/{id}/anonymize", AnonymizePatientInplace); |
342
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
1813 |
a58a8be26aff
generation of random uid in the rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
321
diff
changeset
|
1814 Register("/tools/generate-uid", GenerateUid); |
418
b79bf2f4ab2e
execution of lua through REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
413
diff
changeset
|
1815 Register("/tools/execute-script", ExecuteScript); |
446 | 1816 Register("/tools/now", GetNowIsoString); |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1817 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1818 } |