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