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