0
|
1 /**
|
62
|
2 * Orthanc - A Lightweight, RESTful DICOM Store
|
0
|
3 * Copyright (C) 2012 Medical Physics Department, CHU of Liege,
|
|
4 * Belgium
|
|
5 *
|
|
6 * This program is free software: you can redistribute it and/or
|
|
7 * modify it under the terms of the GNU General Public License as
|
|
8 * published by the Free Software Foundation, either version 3 of the
|
|
9 * License, or (at your option) any later version.
|
136
|
10 *
|
|
11 * In addition, as a special exception, the copyright holders of this
|
|
12 * program give permission to link the code of its release with the
|
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
|
|
14 * that use the same license as the "OpenSSL" library), and distribute
|
|
15 * the linked executables. You must obey the GNU General Public License
|
|
16 * in all respects for all of the code used other than "OpenSSL". If you
|
|
17 * modify file(s) with this exception, you may extend this exception to
|
|
18 * your version of the file(s), but you are not obligated to do so. If
|
|
19 * you do not wish to do so, delete this exception statement from your
|
|
20 * version. If you delete this exception statement from all source files
|
|
21 * in the program, then also delete it here.
|
0
|
22 *
|
|
23 * This program is distributed in the hope that it will be useful, but
|
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
26 * General Public License for more details.
|
|
27 *
|
|
28 * You should have received a copy of the GNU General Public License
|
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
30 **/
|
|
31
|
|
32
|
|
33 #pragma once
|
|
34
|
|
35 #include <boost/thread.hpp>
|
|
36 #include "../Core/SQLite/Connection.h"
|
|
37 #include "../Core/DicomFormat/DicomMap.h"
|
|
38 #include "../Core/FileStorage.h"
|
|
39
|
|
40
|
62
|
41 namespace Orthanc
|
0
|
42 {
|
|
43 enum SeriesStatus
|
|
44 {
|
|
45 SeriesStatus_Complete,
|
|
46 SeriesStatus_Missing,
|
|
47 SeriesStatus_Inconsistent,
|
|
48 SeriesStatus_Unknown
|
|
49 };
|
|
50
|
|
51
|
|
52 enum StoreStatus
|
|
53 {
|
|
54 StoreStatus_Success,
|
|
55 StoreStatus_AlreadyStored,
|
|
56 StoreStatus_Failure
|
|
57 };
|
|
58
|
|
59
|
82
|
60 enum ResourceType
|
|
61 {
|
|
62 ResourceType_Patient = 1,
|
|
63 ResourceType_Study = 2,
|
|
64 ResourceType_Series = 3,
|
|
65 ResourceType_Instance = 4,
|
|
66 ResourceType_File = 5
|
|
67 };
|
|
68
|
|
69
|
0
|
70 namespace Internals
|
|
71 {
|
|
72 class SignalDeletedLevelFunction;
|
|
73 }
|
|
74
|
|
75
|
|
76 class ServerIndex
|
|
77 {
|
|
78 private:
|
|
79 SQLite::Connection db_;
|
|
80 boost::mutex mutex_;
|
|
81
|
|
82 // DO NOT delete the following one, SQLite::Connection will do it automatically
|
|
83 Internals::SignalDeletedLevelFunction* deletedLevels_;
|
|
84
|
|
85 void StoreMainDicomTags(const std::string& uuid,
|
|
86 const DicomMap& map);
|
|
87
|
|
88 bool GetMainDicomStringTag(std::string& result,
|
|
89 const std::string& uuid,
|
|
90 const DicomTag& tag);
|
|
91
|
|
92 bool GetMainDicomIntTag(int& result,
|
|
93 const std::string& uuid,
|
|
94 const DicomTag& tag);
|
|
95
|
|
96 bool HasInstance(std::string& instanceUuid,
|
|
97 const std::string& dicomInstance);
|
|
98
|
|
99 void RecordChange(const std::string& resourceType,
|
|
100 const std::string& uuid);
|
|
101
|
|
102 std::string CreateInstance(const std::string& parentSeriesUuid,
|
|
103 const std::string& dicomInstance,
|
|
104 const DicomMap& dicomSummary,
|
|
105 const std::string& fileUuid,
|
|
106 uint64_t fileSize,
|
|
107 const std::string& jsonUuid,
|
|
108 const std::string& distantAet);
|
|
109
|
|
110 void RemoveInstance(const std::string& uuid);
|
|
111
|
|
112 bool HasSeries(std::string& seriesUuid,
|
|
113 const std::string& dicomSeries);
|
|
114
|
|
115 std::string CreateSeries(const std::string& parentStudyUuid,
|
|
116 const std::string& dicomSeries,
|
|
117 const DicomMap& dicomSummary);
|
|
118
|
|
119 bool HasStudy(std::string& studyUuid,
|
|
120 const std::string& dicomStudy);
|
|
121
|
|
122 std::string CreateStudy(const std::string& parentPatientUuid,
|
|
123 const std::string& dicomStudy,
|
|
124 const DicomMap& dicomSummary);
|
|
125
|
|
126 bool HasPatient(std::string& patientUuid,
|
|
127 const std::string& dicomPatientId);
|
|
128
|
|
129 std::string CreatePatient(const std::string& patientId,
|
|
130 const DicomMap& dicomSummary);
|
|
131
|
|
132 void GetMainDicomTags(DicomMap& map,
|
|
133 const std::string& uuid);
|
|
134
|
|
135 void MainDicomTagsToJson(Json::Value& target,
|
|
136 const std::string& uuid);
|
|
137
|
|
138 bool DeleteInternal(Json::Value& target,
|
|
139 const std::string& uuid,
|
|
140 const std::string& tableName);
|
|
141
|
|
142 public:
|
|
143 ServerIndex(const std::string& storagePath);
|
|
144
|
|
145 StoreStatus Store(std::string& instanceUuid,
|
|
146 const DicomMap& dicomSummary,
|
|
147 const std::string& fileUuid,
|
|
148 uint64_t uncompressedFileSize,
|
|
149 const std::string& jsonUuid,
|
|
150 const std::string& distantAet);
|
|
151
|
|
152 StoreStatus Store(std::string& instanceUuid,
|
|
153 FileStorage& storage,
|
|
154 const char* dicomFile,
|
|
155 size_t dicomSize,
|
|
156 const DicomMap& dicomSummary,
|
|
157 const Json::Value& dicomJson,
|
|
158 const std::string& distantAet);
|
|
159
|
|
160 uint64_t GetTotalSize();
|
|
161
|
|
162 SeriesStatus GetSeriesStatus(const std::string& seriesUuid);
|
|
163
|
|
164
|
|
165 bool GetInstance(Json::Value& result,
|
|
166 const std::string& instanceUuid);
|
|
167
|
|
168 bool GetSeries(Json::Value& result,
|
|
169 const std::string& seriesUuid);
|
|
170
|
|
171 bool GetStudy(Json::Value& result,
|
|
172 const std::string& studyUuid);
|
|
173
|
|
174 bool GetPatient(Json::Value& result,
|
|
175 const std::string& patientUuid);
|
|
176
|
|
177 bool GetJsonFile(std::string& fileUuid,
|
|
178 const std::string& instanceUuid);
|
|
179
|
|
180 bool GetDicomFile(std::string& fileUuid,
|
|
181 const std::string& instanceUuid);
|
|
182
|
|
183 void GetAllUuids(Json::Value& target,
|
|
184 const std::string& tableName);
|
|
185
|
|
186 bool DeletePatient(Json::Value& target,
|
|
187 const std::string& patientUuid)
|
|
188 {
|
|
189 return DeleteInternal(target, patientUuid, "Patients");
|
|
190 }
|
|
191
|
|
192 bool DeleteStudy(Json::Value& target,
|
|
193 const std::string& studyUuid)
|
|
194 {
|
|
195 return DeleteInternal(target, studyUuid, "Studies");
|
|
196 }
|
|
197
|
|
198 bool DeleteSeries(Json::Value& target,
|
|
199 const std::string& seriesUuid)
|
|
200 {
|
|
201 return DeleteInternal(target, seriesUuid, "Series");
|
|
202 }
|
|
203
|
|
204 bool DeleteInstance(Json::Value& target,
|
|
205 const std::string& instanceUuid)
|
|
206 {
|
|
207 return DeleteInternal(target, instanceUuid, "Instances");
|
|
208 }
|
|
209
|
|
210 bool GetChanges(Json::Value& target,
|
|
211 int64_t since,
|
|
212 const std::string& filter,
|
|
213 unsigned int maxResults);
|
82
|
214
|
|
215 /*bool GetAllInstances(std::list<std::string>& instancesUuid,
|
|
216 const std::string& uuid,
|
|
217 bool clear = true);*/
|
0
|
218 };
|
|
219 }
|