Mercurial > hg > orthanc
annotate OrthancServer/OrthancRestApi.cpp @ 315:fc856d175d18
modifications
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 21 Dec 2012 17:18:04 +0100 |
parents | 4f17834a50b6 |
children | d526ac73c886 |
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 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege, |
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 |
63 static boost::mutex cacheMutex_; | |
64 | |
65 | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
66 // DICOM SCU ---------------------------------------------------------------- |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
67 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
68 static void ConnectToModality(DicomUserConnection& connection, |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
69 const std::string& name) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
70 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
71 std::string aet, address; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
72 int port; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
73 GetDicomModality(name, aet, address, port); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
74 connection.SetLocalApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
75 connection.SetDistantApplicationEntityTitle(aet); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
76 connection.SetDistantHost(address); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
77 connection.SetDistantPort(port); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
78 connection.Open(); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
79 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
80 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
81 static bool MergeQueryAndTemplate(DicomMap& result, |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
82 const std::string& postData) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
83 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
84 Json::Value query; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
85 Json::Reader reader; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
86 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
87 if (!reader.parse(postData, query) || |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
88 query.type() != Json::objectValue) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
89 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
90 return false; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
91 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
92 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
93 Json::Value::Members members = query.getMemberNames(); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
94 for (size_t i = 0; i < members.size(); i++) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
95 { |
304 | 96 DicomTag t = FromDcmtkBridge::ParseTag(members[i]); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
97 result.SetValue(t, query[members[i]].asString()); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
98 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
99 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
100 return true; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
101 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
102 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
103 static void DicomFindPatient(RestApi::PostCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
104 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
105 DicomMap m; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
106 DicomMap::SetupFindPatientTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
107 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
108 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
109 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
110 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
111 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
112 DicomUserConnection connection; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
113 ConnectToModality(connection, call.GetUriComponent("id", "")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
114 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
115 DicomFindAnswers answers; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
116 connection.FindPatient(answers, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
117 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
118 Json::Value result; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
119 answers.ToJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
120 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
121 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
122 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
123 static void DicomFindStudy(RestApi::PostCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
124 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
125 DicomMap m; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
126 DicomMap::SetupFindStudyTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
127 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
128 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
129 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
130 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
131 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
132 if (m.GetValue(DICOM_TAG_ACCESSION_NUMBER).AsString().size() <= 2 && |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
133 m.GetValue(DICOM_TAG_PATIENT_ID).AsString().size() <= 2) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
134 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
135 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
136 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
137 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
138 DicomUserConnection connection; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
139 ConnectToModality(connection, call.GetUriComponent("id", "")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
140 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
141 DicomFindAnswers answers; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
142 connection.FindStudy(answers, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
143 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
144 Json::Value result; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
145 answers.ToJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
146 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
147 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
148 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
149 static void DicomFindSeries(RestApi::PostCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
150 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
151 DicomMap m; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
152 DicomMap::SetupFindSeriesTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
153 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
154 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
155 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
156 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
157 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
158 if ((m.GetValue(DICOM_TAG_ACCESSION_NUMBER).AsString().size() <= 2 && |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
159 m.GetValue(DICOM_TAG_PATIENT_ID).AsString().size() <= 2) || |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
160 m.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).AsString().size() <= 2) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
161 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
162 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
163 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
164 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
165 DicomUserConnection connection; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
166 ConnectToModality(connection, call.GetUriComponent("id", "")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
167 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
168 DicomFindAnswers answers; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
169 connection.FindSeries(answers, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
170 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
171 Json::Value result; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
172 answers.ToJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
173 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
174 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
175 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
176 static void DicomFind(RestApi::PostCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
177 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
178 DicomMap m; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
179 DicomMap::SetupFindPatientTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
180 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
181 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
182 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
183 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
184 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
185 DicomUserConnection connection; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
186 ConnectToModality(connection, call.GetUriComponent("id", "")); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
187 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
188 DicomFindAnswers patients; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
189 connection.FindPatient(patients, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
190 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
191 // Loop over the found patients |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
192 Json::Value result = Json::arrayValue; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
193 for (size_t i = 0; i < patients.GetSize(); i++) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
194 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
195 Json::Value patient(Json::objectValue); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
196 FromDcmtkBridge::ToJson(patient, patients.GetAnswer(i)); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
197 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
198 DicomMap::SetupFindStudyTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
199 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
200 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
201 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
202 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
203 m.CopyTagIfExists(patients.GetAnswer(i), DICOM_TAG_PATIENT_ID); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
204 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
205 DicomFindAnswers studies; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
206 connection.FindStudy(studies, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
207 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
208 patient["Studies"] = Json::arrayValue; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
209 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
210 // Loop over the found studies |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
211 for (size_t j = 0; j < studies.GetSize(); j++) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
212 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
213 Json::Value study(Json::objectValue); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
214 FromDcmtkBridge::ToJson(study, studies.GetAnswer(j)); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
215 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
216 DicomMap::SetupFindSeriesTemplate(m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
217 if (!MergeQueryAndTemplate(m, call.GetPostBody())) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
218 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
219 return; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
220 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
221 m.CopyTagIfExists(studies.GetAnswer(j), DICOM_TAG_PATIENT_ID); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
222 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
|
223 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
224 DicomFindAnswers series; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
225 connection.FindSeries(series, m); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
226 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
227 // Loop over the found series |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
228 study["Series"] = Json::arrayValue; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
229 for (size_t k = 0; k < series.GetSize(); k++) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
230 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
231 Json::Value series2(Json::objectValue); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
232 FromDcmtkBridge::ToJson(series2, series.GetAnswer(k)); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
233 study["Series"].append(series2); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
234 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
235 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
236 patient["Studies"].append(study); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
237 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
238 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
239 result.append(patient); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
240 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
241 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
242 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
243 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
244 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
245 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
246 static void DicomStore(RestApi::PostCall& call) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
247 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
248 RETRIEVE_CONTEXT(call); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
249 |
231 | 250 std::string remote = call.GetUriComponent("id", ""); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
251 DicomUserConnection connection; |
231 | 252 ConnectToModality(connection, remote); |
253 | |
254 const std::string& resourceId = call.GetPostBody(); | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
255 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
256 Json::Value found; |
231 | 257 if (context.GetIndex().LookupResource(found, resourceId, ResourceType_Series)) |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
258 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
259 // The UUID corresponds to a series |
231 | 260 context.GetIndex().LogExportedResource(resourceId, remote); |
261 | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
262 for (Json::Value::ArrayIndex i = 0; i < found["Instances"].size(); i++) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
263 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
264 std::string instanceId = found["Instances"][i].asString(); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
265 std::string dicom; |
233 | 266 context.ReadFile(dicom, instanceId, FileContentType_Dicom); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
267 connection.Store(dicom); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
268 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
269 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
270 call.GetOutput().AnswerBuffer("{}", "application/json"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
271 } |
231 | 272 else if (context.GetIndex().LookupResource(found, resourceId, ResourceType_Instance)) |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
273 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
274 // The UUID corresponds to an instance |
231 | 275 context.GetIndex().LogExportedResource(resourceId, remote); |
276 | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
277 std::string dicom; |
233 | 278 context.ReadFile(dicom, resourceId, FileContentType_Dicom); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
279 connection.Store(dicom); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
280 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
281 call.GetOutput().AnswerBuffer("{}", "application/json"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
282 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
283 else |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
284 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
285 // The POST body is not a known resource, assume that it |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
286 // contains a raw DICOM instance |
231 | 287 connection.Store(resourceId); |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
288 call.GetOutput().AnswerBuffer("{}", "application/json"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
289 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
290 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
291 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
292 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
293 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 // System information ------------------------------------------------------- |
211 | 295 |
296 static void ServeRoot(RestApi::GetCall& call) | |
297 { | |
298 call.GetOutput().Redirect("app/explorer.html"); | |
299 } | |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 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
|
302 { |
238 | 303 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
|
304 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 result["Version"] = ORTHANC_VERSION; |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 result["Name"] = GetGlobalStringParameter("Name", ""); |
238 | 307 |
308 call.GetOutput().AnswerJson(result); | |
309 } | |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
310 |
238 | 311 static void GetStatistics(RestApi::GetCall& call) |
312 { | |
313 RETRIEVE_CONTEXT(call); | |
314 Json::Value result = Json::objectValue; | |
315 context.GetIndex().ComputeStatistics(result); | |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 call.GetOutput().AnswerJson(result); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 |
211 | 320 // List all the patients, studies, series or instances ---------------------- |
321 | |
322 template <enum ResourceType resourceType> | |
323 static void ListResources(RestApi::GetCall& call) | |
324 { | |
325 RETRIEVE_CONTEXT(call); | |
326 | |
327 Json::Value result; | |
328 context.GetIndex().GetAllUuids(result, resourceType); | |
329 call.GetOutput().AnswerJson(result); | |
330 } | |
331 | |
212 | 332 template <enum ResourceType resourceType> |
333 static void GetSingleResource(RestApi::GetCall& call) | |
334 { | |
335 RETRIEVE_CONTEXT(call); | |
336 | |
337 Json::Value result; | |
338 if (context.GetIndex().LookupResource(result, call.GetUriComponent("id", ""), resourceType)) | |
339 { | |
340 call.GetOutput().AnswerJson(result); | |
341 } | |
342 } | |
343 | |
344 template <enum ResourceType resourceType> | |
345 static void DeleteSingleResource(RestApi::DeleteCall& call) | |
346 { | |
347 RETRIEVE_CONTEXT(call); | |
348 | |
349 Json::Value result; | |
350 if (context.GetIndex().DeleteResource(result, call.GetUriComponent("id", ""), resourceType)) | |
351 { | |
352 call.GetOutput().AnswerJson(result); | |
353 } | |
354 } | |
355 | |
211 | 356 |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
357 // Download of ZIP files ---------------------------------------------------- |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
358 |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
359 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
360 static std::string GetDirectoryNameInArchive(const Json::Value& resource, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
361 ResourceType resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
362 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
363 switch (resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
364 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
365 case ResourceType_Patient: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
366 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
367 std::string p = resource["MainDicomTags"]["PatientID"].asString(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
368 std::string n = resource["MainDicomTags"]["PatientName"].asString(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
369 return p + " " + n; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
370 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
371 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
372 case ResourceType_Study: |
253 | 373 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
374 return resource["MainDicomTags"]["StudyDescription"].asString(); |
253 | 375 } |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
376 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
377 case ResourceType_Series: |
253 | 378 { |
379 std::string d = resource["MainDicomTags"]["SeriesDescription"].asString(); | |
380 std::string m = resource["MainDicomTags"]["Modality"].asString(); | |
381 return m + " " + d; | |
382 } | |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
383 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
384 default: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
385 throw OrthancException(ErrorCode_InternalError); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
386 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
387 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
388 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
389 static bool CreateRootDirectoryInArchive(HierarchicalZipWriter& writer, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
390 ServerContext& context, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
391 const Json::Value& resource, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
392 ResourceType resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
393 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
394 if (resourceType == ResourceType_Patient) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
395 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
396 return true; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
397 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
398 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
399 ResourceType parentType = GetParentResourceType(resourceType); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
400 Json::Value parent; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
401 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
402 switch (resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
403 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
404 case ResourceType_Study: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
405 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
406 if (!context.GetIndex().LookupResource(parent, resource["ParentPatient"].asString(), parentType)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
407 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
408 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
409 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
410 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
411 break; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
412 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
413 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
414 case ResourceType_Series: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
415 if (!context.GetIndex().LookupResource(parent, resource["ParentStudy"].asString(), parentType) || |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
416 !CreateRootDirectoryInArchive(writer, context, parent, parentType)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
417 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
418 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
419 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
420 break; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
421 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
422 default: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
423 throw OrthancException(ErrorCode_NotImplemented); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
424 } |
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 writer.OpenDirectory(GetDirectoryNameInArchive(parent, parentType).c_str()); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
427 return true; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
428 } |
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 static bool ArchiveInstance(HierarchicalZipWriter& writer, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
431 ServerContext& context, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
432 const std::string& instancePublicId) |
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 Json::Value instance; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
435 if (!context.GetIndex().LookupResource(instance, instancePublicId, ResourceType_Instance)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
436 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
437 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
438 } |
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 std::string filename = instance["MainDicomTags"]["SOPInstanceUID"].asString() + ".dcm"; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
441 writer.OpenFile(filename.c_str()); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
442 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
443 std::string dicom; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
444 context.ReadFile(dicom, instancePublicId, FileContentType_Dicom); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
445 writer.Write(dicom); |
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 return true; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
448 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
449 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
450 static bool ArchiveInternal(HierarchicalZipWriter& writer, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
451 ServerContext& context, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
452 const std::string& publicId, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
453 ResourceType resourceType, |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
454 bool isFirstLevel) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
455 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
456 Json::Value resource; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
457 if (!context.GetIndex().LookupResource(resource, publicId, resourceType)) |
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 false; |
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 if (isFirstLevel && |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
463 !CreateRootDirectoryInArchive(writer, context, resource, resourceType)) |
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 return false; |
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 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
468 writer.OpenDirectory(GetDirectoryNameInArchive(resource, resourceType).c_str()); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
469 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
470 switch (resourceType) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
471 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
472 case ResourceType_Patient: |
299 | 473 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
|
474 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
475 std::string studyId = resource["Studies"][i].asString(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
476 if (!ArchiveInternal(writer, context, studyId, ResourceType_Study, false)) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
477 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
478 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
479 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
480 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
481 break; |
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 case ResourceType_Study: |
299 | 484 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
|
485 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
486 std::string seriesId = resource["Series"][i].asString(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
487 if (!ArchiveInternal(writer, context, seriesId, ResourceType_Series, false)) |
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 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
490 } |
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 break; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
493 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
494 case ResourceType_Series: |
299 | 495 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
|
496 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
497 if (!ArchiveInstance(writer, context, resource["Instances"][i].asString())) |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
498 { |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
499 return false; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
500 } |
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 break; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
503 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
504 default: |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
505 throw OrthancException(ErrorCode_InternalError); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
506 } |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
507 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
508 writer.CloseDirectory(); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
509 return true; |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
510 } |
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 template <enum ResourceType resourceType> |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
513 static void GetArchive(RestApi::GetCall& call) |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
514 { |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
515 RETRIEVE_CONTEXT(call); |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
516 |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
517 // 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
|
518 Toolbox::TemporaryFile tmp; |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
519 std::string id = call.GetUriComponent("id", ""); |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
520 |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
521 { |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
522 // Create a ZIP writer |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
523 HierarchicalZipWriter writer(tmp.GetPath().c_str()); |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
524 |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
525 // Store the requested resource into the ZIP |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
526 if (!ArchiveInternal(writer, context, id, resourceType, true)) |
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; |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
529 } |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
530 } |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
531 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
532 // Prepare the sending of the ZIP file |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
533 FilesystemHttpSender sender(tmp.GetPath().c_str()); |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
534 sender.SetContentType("application/zip"); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
535 sender.SetDownloadFilename(id + ".zip"); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
536 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
537 // Send the ZIP |
248
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
538 call.GetOutput().AnswerFile(sender); |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
539 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
540 // 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
|
541 } |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
542 |
2442033911d6
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
238
diff
changeset
|
543 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 // Changes API -------------------------------------------------------------- |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 |
231 | 546 static void GetSinceAndLimit(int64_t& since, |
547 unsigned int& limit, | |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
548 bool& last, |
231 | 549 const RestApi::GetCall& call) |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 static const unsigned int MAX_RESULTS = 100; |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
552 |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
553 if (call.HasArgument("last")) |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
554 { |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
555 last = true; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
556 return; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
557 } |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
558 |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
559 last = false; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
560 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 try |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 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
|
564 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
|
565 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 catch (boost::bad_lexical_cast) |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
568 return; |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 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
|
572 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 limit = MAX_RESULTS; |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 } |
231 | 575 } |
576 | |
577 static void GetChanges(RestApi::GetCall& call) | |
578 { | |
579 RETRIEVE_CONTEXT(call); | |
580 | |
581 //std::string filter = GetArgument(getArguments, "filter", ""); | |
582 int64_t since; | |
583 unsigned int limit; | |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
584 bool last; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
585 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
|
586 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 Json::Value result; |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
588 if ((!last && context.GetIndex().GetChanges(result, since, limit)) || |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
589 ( 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
|
590 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 call.GetOutput().AnswerJson(result); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
593 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
594 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
595 |
231 | 596 static void GetExports(RestApi::GetCall& call) |
597 { | |
598 RETRIEVE_CONTEXT(call); | |
599 | |
600 int64_t since; | |
601 unsigned int limit; | |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
602 bool last; |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
603 GetSinceAndLimit(since, limit, last, call); |
231 | 604 |
605 Json::Value result; | |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
606 if ((!last && context.GetIndex().GetExportedResources(result, since, limit)) || |
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
607 ( last && context.GetIndex().GetLastExportedResource(result))) |
231 | 608 { |
609 call.GetOutput().AnswerJson(result); | |
610 } | |
611 } | |
612 | |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 |
272
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
614 // Get information about a single patient ----------------------------------- |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
615 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
616 static void IsProtectedPatient(RestApi::GetCall& call) |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
617 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
618 RETRIEVE_CONTEXT(call); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
619 std::string publicId = call.GetUriComponent("id", ""); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
620 bool isProtected = context.GetIndex().IsProtectedPatient(publicId); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
621 call.GetOutput().AnswerBuffer(isProtected ? "1" : "0", "text/plain"); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
622 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
623 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
624 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
625 static void SetPatientProtection(RestApi::PutCall& call) |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
626 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
627 RETRIEVE_CONTEXT(call); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
628 std::string publicId = call.GetUriComponent("id", ""); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
629 std::string s = Toolbox::StripSpaces(call.GetPutBody()); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
630 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
631 if (s == "0") |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
632 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
633 context.GetIndex().SetProtectedPatient(publicId, false); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
634 call.GetOutput().AnswerBuffer("", "text/plain"); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
635 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
636 else if (s == "1") |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
637 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
638 context.GetIndex().SetProtectedPatient(publicId, true); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
639 call.GetOutput().AnswerBuffer("", "text/plain"); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
640 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
641 else |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
642 { |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
643 // Bad request |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
644 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
645 } |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
646 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
647 |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
648 // 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
|
649 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
650 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
|
651 { |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
652 RETRIEVE_CONTEXT(call); |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
653 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
654 std::string publicId = call.GetUriComponent("id", ""); |
233 | 655 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
|
656 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
657 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
658 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
659 template <bool simplify> |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
660 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
|
661 { |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
662 RETRIEVE_CONTEXT(call); |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
663 |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
664 std::string publicId = call.GetUriComponent("id", ""); |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
665 |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
666 Json::Value full; |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
667 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
|
668 |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
669 if (simplify) |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
670 { |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
671 Json::Value simplified; |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
672 SimplifyTags(simplified, full); |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
673 call.GetOutput().AnswerJson(simplified); |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
674 } |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
675 else |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
676 { |
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
225
diff
changeset
|
677 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
|
678 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
679 } |
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
680 |
214 | 681 |
682 static void ListFrames(RestApi::GetCall& call) | |
683 { | |
684 RETRIEVE_CONTEXT(call); | |
685 | |
686 Json::Value instance; | |
687 if (context.GetIndex().LookupResource(instance, call.GetUriComponent("id", ""), ResourceType_Instance)) | |
688 { | |
689 unsigned int numberOfFrames = 1; | |
690 | |
691 try | |
692 { | |
693 Json::Value tmp = instance["MainDicomTags"]["NumberOfFrames"]; | |
694 numberOfFrames = boost::lexical_cast<unsigned int>(tmp.asString()); | |
695 } | |
696 catch (...) | |
697 { | |
698 } | |
699 | |
700 Json::Value result = Json::arrayValue; | |
701 for (unsigned int i = 0; i < numberOfFrames; i++) | |
702 { | |
703 result.append(i); | |
704 } | |
705 | |
706 call.GetOutput().AnswerJson(result); | |
707 } | |
708 } | |
709 | |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
710 |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
711 template <enum ImageExtractionMode mode> |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
712 static void GetImage(RestApi::GetCall& call) |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
713 { |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
714 RETRIEVE_CONTEXT(call); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
715 |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
716 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
|
717 |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
718 unsigned int frame; |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
719 try |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
720 { |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
721 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
|
722 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
723 catch (boost::bad_lexical_cast) |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
724 { |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
725 return; |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
726 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
727 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
728 std::string publicId = call.GetUriComponent("id", ""); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
729 std::string dicomContent, png; |
233 | 730 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
|
731 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
732 try |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
733 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
734 FromDcmtkBridge::ExtractPngImage(png, dicomContent, frame, mode); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
735 call.GetOutput().AnswerBuffer(png, "image/png"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
736 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
737 catch (OrthancException& e) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
738 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
739 if (e.GetErrorCode() == ErrorCode_ParameterOutOfRange) |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
740 { |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
741 // 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
|
742 // instance, the resource is not existent |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
743 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
744 else |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
745 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
746 std::string root = ""; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
747 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
|
748 { |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
749 root += "../"; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
750 } |
218 | 751 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
752 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
|
753 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
754 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
755 } |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
756 |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
757 |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
758 // Upload of DICOM files through HTTP --------------------------------------- |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
759 |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
760 static void UploadDicomFile(RestApi::PostCall& call) |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
761 { |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
762 RETRIEVE_CONTEXT(call); |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
763 |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
764 const std::string& postData = call.GetPostBody(); |
291
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
765 if (postData.size() == 0) |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
766 { |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
767 return; |
4d7469f72a0b
embedding of dicom dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
768 } |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
769 |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
770 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
|
771 |
304 | 772 std::string publicId; |
773 StoreStatus status = context.Store(publicId, postData); | |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
774 Json::Value result = Json::objectValue; |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
775 |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
776 if (status != StoreStatus_Failure) |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
777 { |
304 | 778 result["ID"] = publicId; |
779 result["Path"] = GetBasePath(ResourceType_Instance, publicId); | |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
780 } |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
781 |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
782 result["Status"] = ToString(status); |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
783 call.GetOutput().AnswerJson(result); |
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
784 } |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
785 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 |
304 | 787 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 // DICOM bridge ------------------------------------------------------------- |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 |
230 | 790 static bool IsExistingModality(const OrthancRestApi::Modalities& modalities, |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
791 const std::string& id) |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
792 { |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
793 return modalities.find(id) != modalities.end(); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
794 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
795 |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 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
|
797 { |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
798 RETRIEVE_MODALITIES(call); |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 Json::Value result = Json::arrayValue; |
230 | 801 for (OrthancRestApi::Modalities::const_iterator |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
802 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
|
803 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
804 result.append(*it); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
805 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 call.GetOutput().AnswerJson(result); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
808 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
809 |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
810 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
811 static void ListModalityOperations(RestApi::GetCall& call) |
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 RETRIEVE_MODALITIES(call); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
814 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
815 std::string id = call.GetUriComponent("id", ""); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
816 if (IsExistingModality(modalities, id)) |
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 Json::Value result = Json::arrayValue; |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
819 result.append("find-patient"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
820 result.append("find-study"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
821 result.append("find-series"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
822 result.append("find"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
823 result.append("store"); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
824 call.GetOutput().AnswerJson(result); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
825 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
826 } |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
827 |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
828 |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
829 |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
830 // 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
|
831 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
832 static void GetRawContent(RestApi::GetCall& call) |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
833 { |
315 | 834 boost::mutex::scoped_lock lock(cacheMutex_); |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
835 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
836 RETRIEVE_CONTEXT(call); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
837 std::string id = call.GetUriComponent("id", ""); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
838 ParsedDicomFile& dicom = context.GetDicomFile(id); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
839 dicom.SendPathValue(call.GetOutput(), call.GetTrailingUri()); |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
840 } |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
841 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
842 |
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
843 |
304 | 844 // Modification of DICOM instances ------------------------------------------ |
845 | |
311 | 846 namespace |
847 { | |
848 typedef std::set<DicomTag> Removals; | |
849 typedef std::map<DicomTag, std::string> Replacements; | |
850 } | |
310 | 851 |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
852 static void ReplaceInstanceInternal(ParsedDicomFile& toModify, |
310 | 853 const Removals& removals, |
854 const Replacements& replacements, | |
312 | 855 DicomReplaceMode mode, |
856 bool removePrivateTags) | |
304 | 857 { |
312 | 858 if (removePrivateTags) |
859 { | |
860 toModify.RemovePrivateTags(); | |
861 } | |
862 | |
310 | 863 for (Removals::const_iterator it = removals.begin(); |
864 it != removals.end(); it++) | |
865 { | |
866 toModify.Remove(*it); | |
867 } | |
868 | |
869 for (Replacements::const_iterator it = replacements.begin(); | |
870 it != replacements.end(); it++) | |
871 { | |
872 toModify.Replace(it->first, it->second, mode); | |
873 } | |
874 | |
875 // A new SOP instance UID is automatically generated | |
876 std::string instanceUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Instance); | |
877 toModify.Replace(DICOM_TAG_SOP_INSTANCE_UID, instanceUid, DicomReplaceMode_InsertIfAbsent); | |
878 } | |
879 | |
880 | |
881 static void ParseRemovals(Removals& target, | |
882 const Json::Value& removals) | |
883 { | |
884 if (!removals.isArray()) | |
304 | 885 { |
886 throw OrthancException(ErrorCode_BadRequest); | |
887 } | |
888 | |
310 | 889 target.clear(); |
890 | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
891 for (Json::Value::ArrayIndex i = 0; i < removals.size(); i++) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
892 { |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
893 DicomTag tag = FromDcmtkBridge::ParseTag(removals[i].asString()); |
310 | 894 target.insert(tag); |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
895 } |
310 | 896 } |
897 | |
898 | |
899 static void ParseReplacements(Replacements& target, | |
900 const Json::Value& replacements) | |
901 { | |
902 if (!replacements.isObject()) | |
903 { | |
904 throw OrthancException(ErrorCode_BadRequest); | |
905 } | |
906 | |
907 target.clear(); | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
908 |
304 | 909 Json::Value::Members members = replacements.getMemberNames(); |
910 for (size_t i = 0; i < members.size(); i++) | |
911 { | |
912 const std::string& name = members[i]; | |
913 std::string value = replacements[name].asString(); | |
914 | |
915 DicomTag tag = FromDcmtkBridge::ParseTag(name); | |
310 | 916 target[tag] = value; |
304 | 917 } |
918 } | |
919 | |
310 | 920 |
311 | 921 static std::string GeneratePatientName(ServerContext& context) |
922 { | |
923 uint64_t seq = context.GetIndex().IncrementGlobalSequence(GlobalProperty_AnonymizationSequence); | |
924 return "Anonymized" + boost::lexical_cast<std::string>(seq); | |
925 } | |
926 | |
927 | |
310 | 928 static void SetupAnonymization(Removals& removals, |
929 Replacements& replacements) | |
930 { | |
311 | 931 // This is Table E.1-1 from PS 3.15-2008 - DICOM Part 15: Security and System Management Profiles |
310 | 932 removals.insert(DicomTag(0x0008, 0x0014)); // Instance Creator UID |
311 | 933 //removals.insert(DicomTag(0x0008, 0x0018)); // SOP Instance UID => set by ReplaceInstanceInternal() |
934 removals.insert(DicomTag(0x0008, 0x0050)); // Accession Number | |
935 removals.insert(DicomTag(0x0008, 0x0080)); // Institution Name | |
936 removals.insert(DicomTag(0x0008, 0x0081)); // Institution Address | |
937 removals.insert(DicomTag(0x0008, 0x0090)); // Referring Physician's Name | |
938 removals.insert(DicomTag(0x0008, 0x0092)); // Referring Physician's Address | |
939 removals.insert(DicomTag(0x0008, 0x0094)); // Referring Physician's Telephone Numbers | |
940 removals.insert(DicomTag(0x0008, 0x1010)); // Station Name | |
941 removals.insert(DicomTag(0x0008, 0x1030)); // Study Description | |
942 removals.insert(DicomTag(0x0008, 0x103e)); // Series Description | |
943 removals.insert(DicomTag(0x0008, 0x1040)); // Institutional Department Name | |
944 removals.insert(DicomTag(0x0008, 0x1048)); // Physician(s) of Record | |
945 removals.insert(DicomTag(0x0008, 0x1050)); // Performing Physicians' Name | |
946 removals.insert(DicomTag(0x0008, 0x1060)); // Name of Physician(s) Reading Study | |
947 removals.insert(DicomTag(0x0008, 0x1070)); // Operators' Name | |
948 removals.insert(DicomTag(0x0008, 0x1080)); // Admitting Diagnoses Description | |
949 removals.insert(DicomTag(0x0008, 0x1155)); // Referenced SOP Instance UID | |
950 removals.insert(DicomTag(0x0008, 0x2111)); // Derivation Description | |
951 removals.insert(DicomTag(0x0010, 0x0010)); // Patient's Name | |
952 removals.insert(DicomTag(0x0010, 0x0020)); // Patient ID | |
953 removals.insert(DicomTag(0x0010, 0x0030)); // Patient's Birth Date | |
954 removals.insert(DicomTag(0x0010, 0x0032)); // Patient's Birth Time | |
955 removals.insert(DicomTag(0x0010, 0x0040)); // Patient's Sex | |
956 removals.insert(DicomTag(0x0010, 0x1000)); // Other Patient Ids | |
957 removals.insert(DicomTag(0x0010, 0x1001)); // Other Patient Names | |
958 removals.insert(DicomTag(0x0010, 0x1010)); // Patient's Age | |
959 removals.insert(DicomTag(0x0010, 0x1020)); // Patient's Size | |
960 removals.insert(DicomTag(0x0010, 0x1030)); // Patient's Weight | |
961 removals.insert(DicomTag(0x0010, 0x1090)); // Medical Record Locator | |
962 removals.insert(DicomTag(0x0010, 0x2160)); // Ethnic Group | |
963 removals.insert(DicomTag(0x0010, 0x2180)); // Occupation | |
964 removals.insert(DicomTag(0x0010, 0x21b0)); // Additional Patient's History | |
965 removals.insert(DicomTag(0x0010, 0x4000)); // Patient Comments | |
966 removals.insert(DicomTag(0x0018, 0x1000)); // Device Serial Number | |
967 removals.insert(DicomTag(0x0018, 0x1030)); // Protocol Name | |
968 //removals.insert(DicomTag(0x0020, 0x000d)); // Study Instance UID => generated below | |
969 //removals.insert(DicomTag(0x0020, 0x000e)); // Series Instance UID => generated below | |
970 removals.insert(DicomTag(0x0020, 0x0010)); // Study ID | |
971 removals.insert(DicomTag(0x0020, 0x0052)); // Frame of Reference UID | |
972 removals.insert(DicomTag(0x0020, 0x0200)); // Synchronization Frame of Reference UID | |
973 removals.insert(DicomTag(0x0020, 0x4000)); // Image Comments | |
974 removals.insert(DicomTag(0x0040, 0x0275)); // Request Attributes Sequence | |
975 removals.insert(DicomTag(0x0040, 0xa124)); // UID | |
976 removals.insert(DicomTag(0x0040, 0xa730)); // Content Sequence | |
977 removals.insert(DicomTag(0x0088, 0x0140)); // Storage Media File-set UID | |
978 removals.insert(DicomTag(0x3006, 0x0024)); // Referenced Frame of Reference UID | |
979 removals.insert(DicomTag(0x3006, 0x00c2)); // Related Frame of Reference UID | |
980 | |
981 // Some more removals (from the experience of DICOM files at the CHU of Liege) | |
982 removals.insert(DicomTag(0x0010, 0x1040)); // Patient's Address | |
983 removals.insert(DicomTag(0x0032, 0x1032)); // Requesting Physician | |
984 | |
985 // Set the DeidentificationMethod tag | |
986 replacements.insert(std::make_pair(DicomTag(0x0012, 0x0063), "Orthanc " ORTHANC_VERSION " - PS 3.15-2008 Table E.1-1")); | |
987 | |
988 // Set the PatientIdentityRemoved | |
989 replacements.insert(std::make_pair(DicomTag(0x0012, 0x0062), "YES")); | |
990 | |
991 replacements.insert(std::make_pair(DICOM_TAG_STUDY_INSTANCE_UID, | |
992 FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Study))); | |
993 replacements.insert(std::make_pair(DICOM_TAG_SERIES_INSTANCE_UID, | |
994 FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series))); | |
310 | 995 } |
996 | |
997 | |
998 static bool ParseModifyRequest(Removals& removals, | |
999 Replacements& replacements, | |
312 | 1000 bool& removePrivateTags, |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1001 const RestApi::PostCall& call) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1002 { |
312 | 1003 removePrivateTags = false; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1004 Json::Value request; |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1005 if (call.ParseJsonRequest(request) && |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1006 request.isObject()) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1007 { |
310 | 1008 Json::Value removalsPart = Json::arrayValue; |
1009 Json::Value replacementsPart = Json::objectValue; | |
304 | 1010 |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1011 if (request.isMember("Remove")) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1012 { |
310 | 1013 removalsPart = request["Remove"]; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1014 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1015 |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1016 if (request.isMember("Replace")) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1017 { |
310 | 1018 replacementsPart = request["Replace"]; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1019 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1020 |
312 | 1021 if (request.isMember("RemovePrivateTags")) |
1022 { | |
1023 removePrivateTags = true; | |
1024 } | |
1025 | |
310 | 1026 ParseRemovals(removals, removalsPart); |
1027 ParseReplacements(replacements, replacementsPart); | |
1028 | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1029 return true; |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1030 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1031 else |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1032 { |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1033 return false; |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1034 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1035 } |
305
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1036 |
86bb79522f19
name of the private tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
304
diff
changeset
|
1037 |
311 | 1038 static bool ParseAnonymizationRequest(Removals& removals, |
1039 Replacements& replacements, | |
1040 bool& removePrivateTags, | |
1041 const RestApi::PostCall& call) | |
1042 { | |
1043 removePrivateTags = true; | |
1044 | |
1045 Json::Value request; | |
1046 if (call.ParseJsonRequest(request) && | |
1047 request.isObject()) | |
1048 { | |
1049 Json::Value keepPart = Json::arrayValue; | |
312 | 1050 Json::Value removalsPart = Json::arrayValue; |
1051 Json::Value replacementsPart = Json::objectValue; | |
1052 | |
311 | 1053 if (request.isMember("Keep")) |
1054 { | |
1055 keepPart = request["Keep"]; | |
1056 } | |
1057 | |
1058 if (request.isMember("KeepPrivateTags")) | |
1059 { | |
1060 removePrivateTags = false; | |
1061 } | |
1062 | |
312 | 1063 if (request.isMember("Replace")) |
1064 { | |
1065 replacementsPart = request["Replace"]; | |
1066 } | |
1067 | |
311 | 1068 Removals toKeep; |
1069 ParseRemovals(toKeep, keepPart); | |
1070 | |
1071 SetupAnonymization(removals, replacements); | |
1072 | |
1073 for (Removals::iterator it = toKeep.begin(); it != toKeep.end(); it++) | |
1074 { | |
1075 removals.erase(*it); | |
1076 } | |
1077 | |
312 | 1078 Removals additionalRemovals; |
1079 ParseRemovals(additionalRemovals, removalsPart); | |
1080 | |
1081 for (Removals::iterator it = additionalRemovals.begin(); | |
1082 it != additionalRemovals.end(); it++) | |
1083 { | |
1084 removals.erase(*it); | |
1085 } | |
1086 | |
1087 ParseReplacements(replacements, replacementsPart); | |
1088 | |
311 | 1089 return true; |
1090 } | |
1091 else | |
1092 { | |
1093 return false; | |
1094 } | |
1095 } | |
1096 | |
1097 | |
314 | 1098 static void AnonymizeOrModifyInstance(Removals removals, |
1099 Replacements replacements, | |
1100 bool removePrivateTags, | |
1101 RestApi::PostCall& call) | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1102 { |
315 | 1103 boost::mutex::scoped_lock lock(cacheMutex_); |
1104 | |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1105 RETRIEVE_CONTEXT(call); |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1106 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1107 std::string id = call.GetUriComponent("id", ""); |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1108 ParsedDicomFile& dicom = context.GetDicomFile(id); |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1109 |
314 | 1110 std::auto_ptr<ParsedDicomFile> modified(dicom.Clone()); |
1111 ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags); | |
1112 modified->Answer(call.GetOutput()); | |
1113 } | |
1114 | |
1115 | |
1116 static void ModifyInstance(RestApi::PostCall& call) | |
1117 { | |
310 | 1118 Removals removals; |
1119 Replacements replacements; | |
312 | 1120 bool removePrivateTags; |
310 | 1121 |
312 | 1122 if (ParseModifyRequest(removals, replacements, removePrivateTags, call)) |
304 | 1123 { |
314 | 1124 AnonymizeOrModifyInstance(removals, replacements, removePrivateTags, call); |
304 | 1125 } |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1126 } |
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 |
311 | 1129 static void AnonymizeInstance(RestApi::PostCall& call) |
1130 { | |
1131 RETRIEVE_CONTEXT(call); | |
1132 | |
1133 Removals removals; | |
1134 Replacements replacements; | |
1135 bool removePrivateTags; | |
1136 | |
1137 if (ParseAnonymizationRequest(removals, replacements, removePrivateTags, call)) | |
1138 { | |
312 | 1139 // Generate random Patient's Name if none is specified |
1140 if (replacements.find(DicomTag(0x0010, 0x0010)) == replacements.end()) | |
1141 { | |
1142 replacements.insert(std::make_pair(DicomTag(0x0010, 0x0010), GeneratePatientName(context))); | |
1143 } | |
311 | 1144 |
312 | 1145 // Generate random Patient's ID if none is specified |
1146 if (replacements.find(DICOM_TAG_PATIENT_ID) == replacements.end()) | |
1147 { | |
1148 replacements.insert(std::make_pair(DICOM_TAG_PATIENT_ID, | |
1149 FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Patient))); | |
1150 } | |
311 | 1151 |
314 | 1152 AnonymizeOrModifyInstance(removals, replacements, removePrivateTags, call); |
311 | 1153 } |
1154 } | |
1155 | |
1156 | |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1157 static void ModifySeriesInplace(RestApi::PostCall& call) |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1158 { |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1159 RETRIEVE_CONTEXT(call); |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1160 |
310 | 1161 Removals removals; |
1162 Replacements replacements; | |
312 | 1163 bool removePrivateTags; |
310 | 1164 |
312 | 1165 if (ParseModifyRequest(removals, replacements, removePrivateTags, call)) |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1166 { |
315 | 1167 boost::mutex::scoped_lock lock(cacheMutex_); |
1168 | |
1169 typedef std::list<std::string> Instances; | |
1170 Instances instances; | |
1171 std::string id = call.GetUriComponent("id", ""); | |
1172 context.GetIndex().GetChildInstances(instances, id); | |
1173 | |
1174 if (instances.size() == 0) | |
1175 { | |
1176 return; | |
1177 } | |
1178 | |
310 | 1179 replacements[DICOM_TAG_SERIES_INSTANCE_UID] = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series); |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1180 |
315 | 1181 std::string newSeriesId; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1182 for (Instances::const_iterator it = instances.begin(); |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1183 it != instances.end(); it++) |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1184 { |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1185 LOG(INFO) << "Modifying instance " << *it; |
315 | 1186 ParsedDicomFile& original = context.GetDicomFile(*it); |
1187 std::auto_ptr<ParsedDicomFile> modified(original.Clone()); | |
312 | 1188 ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags); |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1189 |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1190 std::string modifiedInstance; |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1191 if (context.Store(modifiedInstance, modified->GetDicom()) != StoreStatus_Success) |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1192 { |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1193 LOG(ERROR) << "Error while storing a modified instance " << *it; |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1194 return; |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1195 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1196 |
315 | 1197 DicomInstanceHasher modifiedHasher = modified->GetHasher(); |
1198 DicomInstanceHasher originalHasher = original.GetHasher(); | |
1199 | |
1200 if (newSeriesId.size() == 0) | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1201 { |
315 | 1202 assert(id == originalHasher.HashSeries()); |
1203 newSeriesId = modifiedHasher.HashSeries(); | |
1204 context.GetIndex().SetMetadata(newSeriesId, MetadataType_ModifiedFrom, id); | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1205 } |
313 | 1206 |
315 | 1207 assert(*it == originalHasher.HashInstance()); |
1208 assert(modifiedInstance == modifiedHasher.HashInstance()); | |
1209 context.GetIndex().SetMetadata(modifiedInstance, MetadataType_ModifiedFrom, *it); | |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1210 } |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1211 |
315 | 1212 context.GetIndex().LogChange(ChangeType_ModifiedSeries, newSeriesId); |
1213 | |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1214 assert(newSeriesId.size() != 0); |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1215 Json::Value result = Json::objectValue; |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1216 result["ID"] = newSeriesId; |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1217 result["Path"] = GetBasePath(ResourceType_Series, newSeriesId); |
306
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1218 call.GetOutput().AnswerJson(result); |
326d5a4a5af3
modification of instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
305
diff
changeset
|
1219 } |
302
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1220 } |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1221 |
238134081136
modification of dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
299
diff
changeset
|
1222 |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1223 static void ModifyStudyInplace(RestApi::PostCall& call) |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1224 { |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1225 RETRIEVE_CONTEXT(call); |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1226 |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1227 typedef std::list<std::string> Instances; |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1228 typedef std::map<std::string, std::string> SeriesUidMap; |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1229 |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1230 SeriesUidMap seriesUidMap; |
310 | 1231 Removals removals; |
1232 Replacements replacements; | |
312 | 1233 bool removePrivateTags; |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1234 |
312 | 1235 if (ParseModifyRequest(removals, replacements, removePrivateTags, call)) |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1236 { |
315 | 1237 boost::mutex::scoped_lock lock(cacheMutex_); |
1238 | |
1239 Instances instances; | |
1240 std::string id = call.GetUriComponent("id", ""); | |
1241 context.GetIndex().GetChildInstances(instances, id); | |
1242 | |
1243 if (instances.size() == 0) | |
1244 { | |
1245 return; | |
1246 } | |
1247 | |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1248 std::string newStudyId; |
310 | 1249 replacements[DICOM_TAG_STUDY_INSTANCE_UID] = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Study); |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1250 |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1251 for (Instances::const_iterator it = instances.begin(); |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1252 it != instances.end(); it++) |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1253 { |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1254 LOG(INFO) << "Modifying instance " << *it; |
315 | 1255 ParsedDicomFile& original = context.GetDicomFile(*it); |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1256 |
315 | 1257 std::string seriesUid; |
1258 if (!original.GetTagValue(seriesUid, DICOM_TAG_SERIES_INSTANCE_UID)) | |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1259 { |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1260 throw OrthancException(ErrorCode_InternalError); |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1261 } |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1262 |
315 | 1263 bool isNewSeries; |
1264 SeriesUidMap::const_iterator it2 = seriesUidMap.find(seriesUid); | |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1265 if (it2 == seriesUidMap.end()) |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1266 { |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1267 std::string newSeriesUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series); |
315 | 1268 seriesUidMap[seriesUid] = newSeriesUid; |
310 | 1269 replacements[DICOM_TAG_SERIES_INSTANCE_UID] = newSeriesUid; |
315 | 1270 isNewSeries = true; |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1271 } |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1272 else |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1273 { |
310 | 1274 replacements[DICOM_TAG_SERIES_INSTANCE_UID] = it2->second; |
315 | 1275 isNewSeries = false; |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1276 } |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1277 |
315 | 1278 std::auto_ptr<ParsedDicomFile> modified(original.Clone()); |
312 | 1279 ReplaceInstanceInternal(*modified, removals, replacements, DicomReplaceMode_InsertIfAbsent, removePrivateTags); |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1280 |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1281 std::string modifiedInstance; |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1282 if (context.Store(modifiedInstance, modified->GetDicom()) != StoreStatus_Success) |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1283 { |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1284 LOG(ERROR) << "Error while storing a modified instance " << *it; |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1285 return; |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1286 } |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1287 |
315 | 1288 DicomInstanceHasher modifiedHasher = modified->GetHasher(); |
1289 DicomInstanceHasher originalHasher = original.GetHasher(); | |
1290 | |
1291 if (isNewSeries) | |
1292 { | |
1293 context.GetIndex().SetMetadata | |
1294 (modifiedHasher.HashSeries(), MetadataType_ModifiedFrom, originalHasher.HashSeries()); | |
1295 } | |
1296 | |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1297 if (newStudyId.size() == 0) |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1298 { |
315 | 1299 newStudyId = modifiedHasher.HashStudy(); |
1300 context.GetIndex().SetMetadata(newStudyId, MetadataType_ModifiedFrom, originalHasher.HashStudy()); | |
1301 } | |
313 | 1302 |
315 | 1303 assert(*it == originalHasher.HashInstance()); |
1304 assert(modifiedInstance == modifiedHasher.HashInstance()); | |
1305 context.GetIndex().SetMetadata(modifiedInstance, MetadataType_ModifiedFrom, *it); | |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1306 } |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1307 |
315 | 1308 context.GetIndex().LogChange(ChangeType_ModifiedStudy, newStudyId); |
1309 | |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1310 assert(newStudyId.size() != 0); |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1311 Json::Value result = Json::objectValue; |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1312 result["ID"] = newStudyId; |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1313 result["Path"] = GetBasePath(ResourceType_Study, newStudyId); |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1314 call.GetOutput().AnswerJson(result); |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1315 } |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1316 } |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1317 |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1318 |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1319 |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
1320 |
213
4ce7fdcc8879
access to tags, simplified-tags and file of an instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
1321 // 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
|
1322 |
230 | 1323 OrthancRestApi::OrthancRestApi(ServerContext& context) : |
224
4eb0c7ce86c9
refactoring for store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
218
diff
changeset
|
1324 context_(context) |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1325 { |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1326 GetListOfDicomModalities(modalities_); |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1327 |
211 | 1328 Register("/", ServeRoot); |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1329 Register("/system", GetSystemInformation); |
238 | 1330 Register("/statistics", GetStatistics); |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1331 Register("/changes", GetChanges); |
237
16a4ac70bd8a
last change and export
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
233
diff
changeset
|
1332 Register("/exports", GetExports); |
211 | 1333 |
216
e5d5d4a9a326
refactored upload of dicom through http
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
215
diff
changeset
|
1334 Register("/instances", UploadDicomFile); |
211 | 1335 Register("/instances", ListResources<ResourceType_Instance>); |
1336 Register("/patients", ListResources<ResourceType_Patient>); | |
1337 Register("/series", ListResources<ResourceType_Series>); | |
1338 Register("/studies", ListResources<ResourceType_Study>); | |
212 | 1339 |
1340 Register("/instances/{id}", DeleteSingleResource<ResourceType_Instance>); | |
1341 Register("/instances/{id}", GetSingleResource<ResourceType_Instance>); | |
1342 Register("/patients/{id}", DeleteSingleResource<ResourceType_Patient>); | |
1343 Register("/patients/{id}", GetSingleResource<ResourceType_Patient>); | |
1344 Register("/series/{id}", DeleteSingleResource<ResourceType_Series>); | |
1345 Register("/series/{id}", GetSingleResource<ResourceType_Series>); | |
1346 Register("/studies/{id}", DeleteSingleResource<ResourceType_Study>); | |
1347 Register("/studies/{id}", GetSingleResource<ResourceType_Study>); | |
250
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
1348 |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
1349 Register("/patients/{id}/archive", GetArchive<ResourceType_Patient>); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
1350 Register("/studies/{id}/archive", GetArchive<ResourceType_Study>); |
f23318b11b39
creation of zip files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
249
diff
changeset
|
1351 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
|
1352 |
272
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
1353 Register("/patients/{id}/protected", IsProtectedPatient); |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
253
diff
changeset
|
1354 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
|
1355 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
|
1356 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
|
1357 Register("/instances/{id}/simplified-tags", GetInstanceTags<true>); |
214 | 1358 Register("/instances/{id}/frames", ListFrames); |
285
4031f73fe0e4
access to the raw dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
1359 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
|
1360 |
215
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1361 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
|
1362 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
|
1363 Register("/instances/{id}/frames/{frame}/image-uint16", GetImage<ImageExtractionMode_UInt16>); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1364 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
|
1365 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
|
1366 Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>); |
c07170f3f4f7
refactoring of access to images in REST
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
214
diff
changeset
|
1367 |
227
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1368 Register("/modalities", ListModalities); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1369 Register("/modalities/{id}", ListModalityOperations); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1370 Register("/modalities/{id}/find-patient", DicomFindPatient); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1371 Register("/modalities/{id}/find-study", DicomFindStudy); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1372 Register("/modalities/{id}/find-series", DicomFindSeries); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1373 Register("/modalities/{id}/find", DicomFind); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1374 Register("/modalities/{id}/store", DicomStore); |
209ca3f6db62
dicom-scu from rest
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
226
diff
changeset
|
1375 |
304 | 1376 Register("/instances/{id}/modify", ModifyInstance); |
308
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1377 Register("/series/{id}/modify", ModifySeriesInplace); |
fbf2b2282086
inplace modification of series and studies
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
307
diff
changeset
|
1378 Register("/studies/{id}/modify", ModifyStudyInplace); |
311 | 1379 |
1380 Register("/instances/{id}/anonymize", AnonymizeInstance); | |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1381 } |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1382 } |