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