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
|
|
48 namespace Internals
|
|
49 {
|
|
50 class SignalDeletedLevelFunction;
|
|
51 }
|
|
52
|
|
53
|
|
54 class ServerIndex
|
|
55 {
|
|
56 private:
|
|
57 SQLite::Connection db_;
|
|
58 boost::mutex mutex_;
|
|
59
|
|
60 // DO NOT delete the following one, SQLite::Connection will do it automatically
|
|
61 Internals::SignalDeletedLevelFunction* deletedLevels_;
|
|
62
|
|
63 void StoreMainDicomTags(const std::string& uuid,
|
|
64 const DicomMap& map);
|
|
65
|
|
66 bool GetMainDicomStringTag(std::string& result,
|
|
67 const std::string& uuid,
|
|
68 const DicomTag& tag);
|
|
69
|
|
70 bool GetMainDicomIntTag(int& result,
|
|
71 const std::string& uuid,
|
|
72 const DicomTag& tag);
|
|
73
|
|
74 bool HasInstance(std::string& instanceUuid,
|
|
75 const std::string& dicomInstance);
|
|
76
|
|
77 void RecordChange(const std::string& resourceType,
|
|
78 const std::string& uuid);
|
|
79
|
|
80 std::string CreateInstance(const std::string& parentSeriesUuid,
|
|
81 const std::string& dicomInstance,
|
|
82 const DicomMap& dicomSummary,
|
|
83 const std::string& fileUuid,
|
|
84 uint64_t fileSize,
|
|
85 const std::string& jsonUuid,
|
|
86 const std::string& distantAet);
|
|
87
|
|
88 void RemoveInstance(const std::string& uuid);
|
|
89
|
|
90 bool HasSeries(std::string& seriesUuid,
|
|
91 const std::string& dicomSeries);
|
|
92
|
|
93 std::string CreateSeries(const std::string& parentStudyUuid,
|
|
94 const std::string& dicomSeries,
|
|
95 const DicomMap& dicomSummary);
|
|
96
|
|
97 bool HasStudy(std::string& studyUuid,
|
|
98 const std::string& dicomStudy);
|
|
99
|
|
100 std::string CreateStudy(const std::string& parentPatientUuid,
|
|
101 const std::string& dicomStudy,
|
|
102 const DicomMap& dicomSummary);
|
|
103
|
|
104 bool HasPatient(std::string& patientUuid,
|
|
105 const std::string& dicomPatientId);
|
|
106
|
|
107 std::string CreatePatient(const std::string& patientId,
|
|
108 const DicomMap& dicomSummary);
|
|
109
|
|
110 void GetMainDicomTags(DicomMap& map,
|
|
111 const std::string& uuid);
|
|
112
|
|
113 void MainDicomTagsToJson(Json::Value& target,
|
|
114 const std::string& uuid);
|
|
115
|
|
116 bool DeleteInternal(Json::Value& target,
|
|
117 const std::string& uuid,
|
|
118 const std::string& tableName);
|
|
119
|
|
120 public:
|
|
121 ServerIndex(const std::string& storagePath);
|
|
122
|
|
123 StoreStatus Store(std::string& instanceUuid,
|
|
124 const DicomMap& dicomSummary,
|
|
125 const std::string& fileUuid,
|
|
126 uint64_t uncompressedFileSize,
|
|
127 const std::string& jsonUuid,
|
|
128 const std::string& distantAet);
|
|
129
|
|
130 StoreStatus Store(std::string& instanceUuid,
|
|
131 FileStorage& storage,
|
|
132 const char* dicomFile,
|
|
133 size_t dicomSize,
|
|
134 const DicomMap& dicomSummary,
|
|
135 const Json::Value& dicomJson,
|
|
136 const std::string& distantAet);
|
|
137
|
|
138 uint64_t GetTotalSize();
|
|
139
|
|
140 SeriesStatus GetSeriesStatus(const std::string& seriesUuid);
|
|
141
|
|
142
|
|
143 bool GetInstance(Json::Value& result,
|
|
144 const std::string& instanceUuid);
|
|
145
|
|
146 bool GetSeries(Json::Value& result,
|
|
147 const std::string& seriesUuid);
|
|
148
|
|
149 bool GetStudy(Json::Value& result,
|
|
150 const std::string& studyUuid);
|
|
151
|
|
152 bool GetPatient(Json::Value& result,
|
|
153 const std::string& patientUuid);
|
|
154
|
|
155 bool GetJsonFile(std::string& fileUuid,
|
|
156 const std::string& instanceUuid);
|
|
157
|
|
158 bool GetDicomFile(std::string& fileUuid,
|
|
159 const std::string& instanceUuid);
|
|
160
|
|
161 void GetAllUuids(Json::Value& target,
|
|
162 const std::string& tableName);
|
|
163
|
|
164 bool DeletePatient(Json::Value& target,
|
|
165 const std::string& patientUuid)
|
|
166 {
|
|
167 return DeleteInternal(target, patientUuid, "Patients");
|
|
168 }
|
|
169
|
|
170 bool DeleteStudy(Json::Value& target,
|
|
171 const std::string& studyUuid)
|
|
172 {
|
|
173 return DeleteInternal(target, studyUuid, "Studies");
|
|
174 }
|
|
175
|
|
176 bool DeleteSeries(Json::Value& target,
|
|
177 const std::string& seriesUuid)
|
|
178 {
|
|
179 return DeleteInternal(target, seriesUuid, "Series");
|
|
180 }
|
|
181
|
|
182 bool DeleteInstance(Json::Value& target,
|
|
183 const std::string& instanceUuid)
|
|
184 {
|
|
185 return DeleteInternal(target, instanceUuid, "Instances");
|
|
186 }
|
|
187
|
|
188 bool GetChanges(Json::Value& target,
|
|
189 int64_t since,
|
|
190 const std::string& filter,
|
|
191 unsigned int maxResults);
|
|
192 };
|
|
193 }
|