0
|
1 /**
|
|
2 * Orthanc - A Lightweight, RESTful DICOM Store
|
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
|
|
4 * Department, University Hospital of Liege, Belgium
|
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
|
|
6 *
|
|
7 * This program is free software: you can redistribute it and/or
|
|
8 * modify it under the terms of the GNU Affero General Public License
|
|
9 * as published by the Free Software Foundation, either version 3 of
|
|
10 * the License, or (at your option) any later version.
|
|
11 *
|
|
12 * This program is distributed in the hope that it will be useful, but
|
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
15 * Affero General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU Affero General Public License
|
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
19 **/
|
|
20
|
|
21
|
|
22
|
|
23 /**
|
|
24 * NOTE: Until Orthanc 1.4.0, this file was part of the Orthanc source
|
|
25 * distribution. This file is now part of "orthanc-databases", in
|
|
26 * order to uncouple its evolution from the Orthanc core.
|
|
27 **/
|
|
28
|
|
29 #pragma once
|
|
30
|
|
31 #include <orthanc/OrthancCDatabasePlugin.h>
|
|
32
|
|
33 #define ORTHANC_PLUGINS_DATABASE_CATCH_COMMON \
|
|
34 catch (::std::runtime_error& e) \
|
|
35 { \
|
|
36 LogError(backend, e); \
|
|
37 return OrthancPluginErrorCode_DatabasePlugin; \
|
|
38 } \
|
|
39 catch (::OrthancPlugins::DatabaseException& e) \
|
|
40 { \
|
|
41 return e.GetErrorCode(); \
|
|
42 } \
|
|
43 catch (...) \
|
|
44 { \
|
|
45 backend->GetOutput().LogError("Native exception"); \
|
|
46 return OrthancPluginErrorCode_DatabasePlugin; \
|
|
47 }
|
|
48
|
|
49 #if HAS_ORTHANC_EXCEPTION == 1
|
|
50 # include <Core/OrthancException.h>
|
|
51 # define ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC \
|
|
52 catch (::Orthanc::OrthancException& e) \
|
|
53 { \
|
|
54 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); \
|
|
55 }
|
|
56 #else
|
|
57 # define ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
58 #endif
|
|
59
|
|
60
|
|
61 #include <stdexcept>
|
|
62 #include <list>
|
|
63 #include <string>
|
|
64
|
|
65 namespace OrthancPlugins
|
|
66 {
|
|
67 //! @cond Doxygen_Suppress
|
|
68 // This class mimics "boost::noncopyable"
|
|
69 class NonCopyable
|
|
70 {
|
|
71 private:
|
|
72 NonCopyable(const NonCopyable&);
|
|
73
|
|
74 NonCopyable& operator= (const NonCopyable&);
|
|
75
|
|
76 protected:
|
|
77 NonCopyable()
|
|
78 {
|
|
79 }
|
|
80
|
|
81 ~NonCopyable()
|
|
82 {
|
|
83 }
|
|
84 };
|
|
85 //! @endcond
|
|
86
|
|
87
|
|
88 /**
|
|
89 * @ingroup Callbacks
|
|
90 **/
|
|
91 class DatabaseException
|
|
92 {
|
|
93 private:
|
|
94 OrthancPluginErrorCode code_;
|
|
95
|
|
96 public:
|
|
97 DatabaseException() : code_(OrthancPluginErrorCode_DatabasePlugin)
|
|
98 {
|
|
99 }
|
|
100
|
|
101 DatabaseException(OrthancPluginErrorCode code) : code_(code)
|
|
102 {
|
|
103 }
|
|
104
|
|
105 OrthancPluginErrorCode GetErrorCode() const
|
|
106 {
|
|
107 return code_;
|
|
108 }
|
|
109 };
|
|
110
|
|
111
|
|
112 /**
|
|
113 * @ingroup Callbacks
|
|
114 **/
|
|
115 class DatabaseBackendOutput : public NonCopyable
|
|
116 {
|
|
117 friend class DatabaseBackendAdapter;
|
|
118
|
|
119 private:
|
|
120 enum AllowedAnswers
|
|
121 {
|
|
122 AllowedAnswers_All,
|
|
123 AllowedAnswers_None,
|
|
124 AllowedAnswers_Attachment,
|
|
125 AllowedAnswers_Change,
|
|
126 AllowedAnswers_DicomTag,
|
|
127 AllowedAnswers_ExportedResource
|
|
128 };
|
|
129
|
|
130 OrthancPluginContext* context_;
|
|
131 OrthancPluginDatabaseContext* database_;
|
|
132 AllowedAnswers allowedAnswers_;
|
|
133
|
|
134 void SetAllowedAnswers(AllowedAnswers allowed)
|
|
135 {
|
|
136 allowedAnswers_ = allowed;
|
|
137 }
|
|
138
|
|
139 public:
|
|
140 DatabaseBackendOutput(OrthancPluginContext* context,
|
|
141 OrthancPluginDatabaseContext* database) :
|
|
142 context_(context),
|
|
143 database_(database),
|
|
144 allowedAnswers_(AllowedAnswers_All /* for unit tests */)
|
|
145 {
|
|
146 }
|
|
147
|
|
148 OrthancPluginContext* GetContext()
|
|
149 {
|
|
150 return context_;
|
|
151 }
|
|
152
|
|
153 void LogError(const std::string& message)
|
|
154 {
|
|
155 OrthancPluginLogError(context_, message.c_str());
|
|
156 }
|
|
157
|
|
158 void LogWarning(const std::string& message)
|
|
159 {
|
|
160 OrthancPluginLogWarning(context_, message.c_str());
|
|
161 }
|
|
162
|
|
163 void LogInfo(const std::string& message)
|
|
164 {
|
|
165 OrthancPluginLogInfo(context_, message.c_str());
|
|
166 }
|
|
167
|
|
168 void SignalDeletedAttachment(const std::string& uuid,
|
|
169 int32_t contentType,
|
|
170 uint64_t uncompressedSize,
|
|
171 const std::string& uncompressedHash,
|
|
172 int32_t compressionType,
|
|
173 uint64_t compressedSize,
|
|
174 const std::string& compressedHash)
|
|
175 {
|
|
176 OrthancPluginAttachment attachment;
|
|
177 attachment.uuid = uuid.c_str();
|
|
178 attachment.contentType = contentType;
|
|
179 attachment.uncompressedSize = uncompressedSize;
|
|
180 attachment.uncompressedHash = uncompressedHash.c_str();
|
|
181 attachment.compressionType = compressionType;
|
|
182 attachment.compressedSize = compressedSize;
|
|
183 attachment.compressedHash = compressedHash.c_str();
|
|
184
|
|
185 OrthancPluginDatabaseSignalDeletedAttachment(context_, database_, &attachment);
|
|
186 }
|
|
187
|
|
188 void SignalDeletedResource(const std::string& publicId,
|
|
189 OrthancPluginResourceType resourceType)
|
|
190 {
|
|
191 OrthancPluginDatabaseSignalDeletedResource(context_, database_, publicId.c_str(), resourceType);
|
|
192 }
|
|
193
|
|
194 void SignalRemainingAncestor(const std::string& ancestorId,
|
|
195 OrthancPluginResourceType ancestorType)
|
|
196 {
|
|
197 OrthancPluginDatabaseSignalRemainingAncestor(context_, database_, ancestorId.c_str(), ancestorType);
|
|
198 }
|
|
199
|
|
200 void AnswerAttachment(const std::string& uuid,
|
|
201 int32_t contentType,
|
|
202 uint64_t uncompressedSize,
|
|
203 const std::string& uncompressedHash,
|
|
204 int32_t compressionType,
|
|
205 uint64_t compressedSize,
|
|
206 const std::string& compressedHash)
|
|
207 {
|
|
208 if (allowedAnswers_ != AllowedAnswers_All &&
|
|
209 allowedAnswers_ != AllowedAnswers_Attachment)
|
|
210 {
|
|
211 throw std::runtime_error("Cannot answer with an attachment in the current state");
|
|
212 }
|
|
213
|
|
214 OrthancPluginAttachment attachment;
|
|
215 attachment.uuid = uuid.c_str();
|
|
216 attachment.contentType = contentType;
|
|
217 attachment.uncompressedSize = uncompressedSize;
|
|
218 attachment.uncompressedHash = uncompressedHash.c_str();
|
|
219 attachment.compressionType = compressionType;
|
|
220 attachment.compressedSize = compressedSize;
|
|
221 attachment.compressedHash = compressedHash.c_str();
|
|
222
|
|
223 OrthancPluginDatabaseAnswerAttachment(context_, database_, &attachment);
|
|
224 }
|
|
225
|
|
226 void AnswerChange(int64_t seq,
|
|
227 int32_t changeType,
|
|
228 OrthancPluginResourceType resourceType,
|
|
229 const std::string& publicId,
|
|
230 const std::string& date)
|
|
231 {
|
|
232 if (allowedAnswers_ != AllowedAnswers_All &&
|
|
233 allowedAnswers_ != AllowedAnswers_Change)
|
|
234 {
|
|
235 throw std::runtime_error("Cannot answer with a change in the current state");
|
|
236 }
|
|
237
|
|
238 OrthancPluginChange change;
|
|
239 change.seq = seq;
|
|
240 change.changeType = changeType;
|
|
241 change.resourceType = resourceType;
|
|
242 change.publicId = publicId.c_str();
|
|
243 change.date = date.c_str();
|
|
244
|
|
245 OrthancPluginDatabaseAnswerChange(context_, database_, &change);
|
|
246 }
|
|
247
|
|
248 void AnswerDicomTag(uint16_t group,
|
|
249 uint16_t element,
|
|
250 const std::string& value)
|
|
251 {
|
|
252 if (allowedAnswers_ != AllowedAnswers_All &&
|
|
253 allowedAnswers_ != AllowedAnswers_DicomTag)
|
|
254 {
|
|
255 throw std::runtime_error("Cannot answer with a DICOM tag in the current state");
|
|
256 }
|
|
257
|
|
258 OrthancPluginDicomTag tag;
|
|
259 tag.group = group;
|
|
260 tag.element = element;
|
|
261 tag.value = value.c_str();
|
|
262
|
|
263 OrthancPluginDatabaseAnswerDicomTag(context_, database_, &tag);
|
|
264 }
|
|
265
|
|
266 void AnswerExportedResource(int64_t seq,
|
|
267 OrthancPluginResourceType resourceType,
|
|
268 const std::string& publicId,
|
|
269 const std::string& modality,
|
|
270 const std::string& date,
|
|
271 const std::string& patientId,
|
|
272 const std::string& studyInstanceUid,
|
|
273 const std::string& seriesInstanceUid,
|
|
274 const std::string& sopInstanceUid)
|
|
275 {
|
|
276 if (allowedAnswers_ != AllowedAnswers_All &&
|
|
277 allowedAnswers_ != AllowedAnswers_ExportedResource)
|
|
278 {
|
|
279 throw std::runtime_error("Cannot answer with an exported resource in the current state");
|
|
280 }
|
|
281
|
|
282 OrthancPluginExportedResource exported;
|
|
283 exported.seq = seq;
|
|
284 exported.resourceType = resourceType;
|
|
285 exported.publicId = publicId.c_str();
|
|
286 exported.modality = modality.c_str();
|
|
287 exported.date = date.c_str();
|
|
288 exported.patientId = patientId.c_str();
|
|
289 exported.studyInstanceUid = studyInstanceUid.c_str();
|
|
290 exported.seriesInstanceUid = seriesInstanceUid.c_str();
|
|
291 exported.sopInstanceUid = sopInstanceUid.c_str();
|
|
292
|
|
293 OrthancPluginDatabaseAnswerExportedResource(context_, database_, &exported);
|
|
294 }
|
|
295 };
|
|
296
|
|
297
|
|
298 /**
|
|
299 * @ingroup Callbacks
|
|
300 **/
|
|
301 class IDatabaseBackend : public NonCopyable
|
|
302 {
|
|
303 friend class DatabaseBackendAdapter;
|
|
304
|
|
305 private:
|
|
306 DatabaseBackendOutput* output_;
|
|
307
|
|
308 void Finalize()
|
|
309 {
|
|
310 if (output_ != NULL)
|
|
311 {
|
|
312 delete output_;
|
|
313 output_ = NULL;
|
|
314 }
|
|
315 }
|
|
316
|
|
317 protected:
|
|
318 DatabaseBackendOutput& GetOutput()
|
|
319 {
|
|
320 return *output_;
|
|
321 }
|
|
322
|
|
323 public:
|
|
324 IDatabaseBackend() : output_(NULL)
|
|
325 {
|
|
326 }
|
|
327
|
|
328 virtual ~IDatabaseBackend()
|
|
329 {
|
|
330 Finalize();
|
|
331 }
|
|
332
|
|
333 // This takes the ownership
|
|
334 void RegisterOutput(DatabaseBackendOutput* output)
|
|
335 {
|
|
336 Finalize();
|
|
337 output_ = output;
|
|
338 }
|
|
339
|
|
340 virtual void Open() = 0;
|
|
341
|
|
342 virtual void Close() = 0;
|
|
343
|
|
344 virtual void AddAttachment(int64_t id,
|
|
345 const OrthancPluginAttachment& attachment) = 0;
|
|
346
|
|
347 virtual void AttachChild(int64_t parent,
|
|
348 int64_t child) = 0;
|
|
349
|
|
350 virtual void ClearChanges() = 0;
|
|
351
|
|
352 virtual void ClearExportedResources() = 0;
|
|
353
|
|
354 virtual int64_t CreateResource(const char* publicId,
|
|
355 OrthancPluginResourceType type) = 0;
|
|
356
|
|
357 virtual void DeleteAttachment(int64_t id,
|
|
358 int32_t attachment) = 0;
|
|
359
|
|
360 virtual void DeleteMetadata(int64_t id,
|
|
361 int32_t metadataType) = 0;
|
|
362
|
|
363 virtual void DeleteResource(int64_t id) = 0;
|
|
364
|
|
365 virtual void GetAllInternalIds(std::list<int64_t>& target,
|
|
366 OrthancPluginResourceType resourceType) = 0;
|
|
367
|
|
368 virtual void GetAllPublicIds(std::list<std::string>& target,
|
|
369 OrthancPluginResourceType resourceType) = 0;
|
|
370
|
|
371 virtual void GetAllPublicIds(std::list<std::string>& target,
|
|
372 OrthancPluginResourceType resourceType,
|
|
373 uint64_t since,
|
|
374 uint64_t limit) = 0;
|
|
375
|
|
376 /* Use GetOutput().AnswerChange() */
|
|
377 virtual void GetChanges(bool& done /*out*/,
|
|
378 int64_t since,
|
|
379 uint32_t maxResults) = 0;
|
|
380
|
|
381 virtual void GetChildrenInternalId(std::list<int64_t>& target /*out*/,
|
|
382 int64_t id) = 0;
|
|
383
|
|
384 virtual void GetChildrenPublicId(std::list<std::string>& target /*out*/,
|
|
385 int64_t id) = 0;
|
|
386
|
|
387 /* Use GetOutput().AnswerExportedResource() */
|
|
388 virtual void GetExportedResources(bool& done /*out*/,
|
|
389 int64_t since,
|
|
390 uint32_t maxResults) = 0;
|
|
391
|
|
392 /* Use GetOutput().AnswerChange() */
|
|
393 virtual void GetLastChange() = 0;
|
|
394
|
|
395 /* Use GetOutput().AnswerExportedResource() */
|
|
396 virtual void GetLastExportedResource() = 0;
|
|
397
|
|
398 /* Use GetOutput().AnswerDicomTag() */
|
|
399 virtual void GetMainDicomTags(int64_t id) = 0;
|
|
400
|
|
401 virtual std::string GetPublicId(int64_t resourceId) = 0;
|
|
402
|
|
403 virtual uint64_t GetResourceCount(OrthancPluginResourceType resourceType) = 0;
|
|
404
|
|
405 virtual OrthancPluginResourceType GetResourceType(int64_t resourceId) = 0;
|
|
406
|
|
407 virtual uint64_t GetTotalCompressedSize() = 0;
|
|
408
|
|
409 virtual uint64_t GetTotalUncompressedSize() = 0;
|
|
410
|
|
411 virtual bool IsExistingResource(int64_t internalId) = 0;
|
|
412
|
|
413 virtual bool IsProtectedPatient(int64_t internalId) = 0;
|
|
414
|
|
415 virtual void ListAvailableMetadata(std::list<int32_t>& target /*out*/,
|
|
416 int64_t id) = 0;
|
|
417
|
|
418 virtual void ListAvailableAttachments(std::list<int32_t>& target /*out*/,
|
|
419 int64_t id) = 0;
|
|
420
|
|
421 virtual void LogChange(const OrthancPluginChange& change) = 0;
|
|
422
|
|
423 virtual void LogExportedResource(const OrthancPluginExportedResource& resource) = 0;
|
|
424
|
|
425 /* Use GetOutput().AnswerAttachment() */
|
|
426 virtual bool LookupAttachment(int64_t id,
|
|
427 int32_t contentType) = 0;
|
|
428
|
|
429 virtual bool LookupGlobalProperty(std::string& target /*out*/,
|
|
430 int32_t property) = 0;
|
|
431
|
|
432 virtual void LookupIdentifier(std::list<int64_t>& target /*out*/,
|
|
433 OrthancPluginResourceType resourceType,
|
|
434 uint16_t group,
|
|
435 uint16_t element,
|
|
436 OrthancPluginIdentifierConstraint constraint,
|
|
437 const char* value) = 0;
|
|
438
|
|
439 virtual void LookupIdentifierRange(std::list<int64_t>& target /*out*/,
|
|
440 OrthancPluginResourceType resourceType,
|
|
441 uint16_t group,
|
|
442 uint16_t element,
|
|
443 const char* start,
|
|
444 const char* end) = 0;
|
|
445
|
|
446 virtual bool LookupMetadata(std::string& target /*out*/,
|
|
447 int64_t id,
|
|
448 int32_t metadataType) = 0;
|
|
449
|
|
450 virtual bool LookupParent(int64_t& parentId /*out*/,
|
|
451 int64_t resourceId) = 0;
|
|
452
|
|
453 virtual bool LookupResource(int64_t& id /*out*/,
|
|
454 OrthancPluginResourceType& type /*out*/,
|
|
455 const char* publicId) = 0;
|
|
456
|
|
457 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/) = 0;
|
|
458
|
|
459 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/,
|
|
460 int64_t patientIdToAvoid) = 0;
|
|
461
|
|
462 virtual void SetGlobalProperty(int32_t property,
|
|
463 const char* value) = 0;
|
|
464
|
|
465 virtual void SetMainDicomTag(int64_t id,
|
|
466 uint16_t group,
|
|
467 uint16_t element,
|
|
468 const char* value) = 0;
|
|
469
|
|
470 virtual void SetIdentifierTag(int64_t id,
|
|
471 uint16_t group,
|
|
472 uint16_t element,
|
|
473 const char* value) = 0;
|
|
474
|
|
475 virtual void SetMetadata(int64_t id,
|
|
476 int32_t metadataType,
|
|
477 const char* value) = 0;
|
|
478
|
|
479 virtual void SetProtectedPatient(int64_t internalId,
|
|
480 bool isProtected) = 0;
|
|
481
|
|
482 virtual void StartTransaction() = 0;
|
|
483
|
|
484 virtual void RollbackTransaction() = 0;
|
|
485
|
|
486 virtual void CommitTransaction() = 0;
|
|
487
|
|
488 virtual uint32_t GetDatabaseVersion() = 0;
|
|
489
|
|
490 /**
|
|
491 * Upgrade the database to the specified version of the database
|
|
492 * schema. The upgrade script is allowed to make calls to
|
|
493 * OrthancPluginReconstructMainDicomTags().
|
|
494 **/
|
|
495 virtual void UpgradeDatabase(uint32_t targetVersion,
|
|
496 OrthancPluginStorageArea* storageArea) = 0;
|
|
497
|
|
498 virtual void ClearMainDicomTags(int64_t internalId) = 0;
|
|
499 };
|
|
500
|
|
501
|
|
502
|
|
503 /**
|
|
504 * @brief Bridge between C and C++ database engines.
|
|
505 *
|
|
506 * Class creating the bridge between the C low-level primitives for
|
|
507 * custom database engines, and the high-level IDatabaseBackend C++
|
|
508 * interface.
|
|
509 *
|
|
510 * @ingroup Callbacks
|
|
511 **/
|
|
512 class DatabaseBackendAdapter
|
|
513 {
|
|
514 private:
|
|
515 // This class cannot be instantiated
|
|
516 DatabaseBackendAdapter()
|
|
517 {
|
|
518 }
|
|
519
|
|
520 static void LogError(IDatabaseBackend* backend,
|
|
521 const std::runtime_error& e)
|
|
522 {
|
|
523 backend->GetOutput().LogError("Exception in database back-end: " + std::string(e.what()));
|
|
524 }
|
|
525
|
|
526
|
|
527 static OrthancPluginErrorCode AddAttachment(void* payload,
|
|
528 int64_t id,
|
|
529 const OrthancPluginAttachment* attachment)
|
|
530 {
|
|
531 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
532 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
533
|
|
534 try
|
|
535 {
|
|
536 backend->AddAttachment(id, *attachment);
|
|
537 return OrthancPluginErrorCode_Success;
|
|
538 }
|
|
539 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
540 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
541 }
|
|
542
|
|
543
|
|
544 static OrthancPluginErrorCode AttachChild(void* payload,
|
|
545 int64_t parent,
|
|
546 int64_t child)
|
|
547 {
|
|
548 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
549 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
550
|
|
551 try
|
|
552 {
|
|
553 backend->AttachChild(parent, child);
|
|
554 return OrthancPluginErrorCode_Success;
|
|
555 }
|
|
556 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
557 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
558 }
|
|
559
|
|
560
|
|
561 static OrthancPluginErrorCode ClearChanges(void* payload)
|
|
562 {
|
|
563 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
564 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
565
|
|
566 try
|
|
567 {
|
|
568 backend->ClearChanges();
|
|
569 return OrthancPluginErrorCode_Success;
|
|
570 }
|
|
571 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
572 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
573 }
|
|
574
|
|
575
|
|
576 static OrthancPluginErrorCode ClearExportedResources(void* payload)
|
|
577 {
|
|
578 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
579 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
580
|
|
581 try
|
|
582 {
|
|
583 backend->ClearExportedResources();
|
|
584 return OrthancPluginErrorCode_Success;
|
|
585 }
|
|
586 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
587 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
588 }
|
|
589
|
|
590
|
|
591 static OrthancPluginErrorCode CreateResource(int64_t* id,
|
|
592 void* payload,
|
|
593 const char* publicId,
|
|
594 OrthancPluginResourceType resourceType)
|
|
595 {
|
|
596 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
597 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
598
|
|
599 try
|
|
600 {
|
|
601 *id = backend->CreateResource(publicId, resourceType);
|
|
602 return OrthancPluginErrorCode_Success;
|
|
603 }
|
|
604 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
605 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
606 }
|
|
607
|
|
608
|
|
609 static OrthancPluginErrorCode DeleteAttachment(void* payload,
|
|
610 int64_t id,
|
|
611 int32_t contentType)
|
|
612 {
|
|
613 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
614 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
615
|
|
616 try
|
|
617 {
|
|
618 backend->DeleteAttachment(id, contentType);
|
|
619 return OrthancPluginErrorCode_Success;
|
|
620 }
|
|
621 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
622 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
623 }
|
|
624
|
|
625
|
|
626 static OrthancPluginErrorCode DeleteMetadata(void* payload,
|
|
627 int64_t id,
|
|
628 int32_t metadataType)
|
|
629 {
|
|
630 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
631 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
632
|
|
633 try
|
|
634 {
|
|
635 backend->DeleteMetadata(id, metadataType);
|
|
636 return OrthancPluginErrorCode_Success;
|
|
637 }
|
|
638 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
639 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
640 }
|
|
641
|
|
642
|
|
643 static OrthancPluginErrorCode DeleteResource(void* payload,
|
|
644 int64_t id)
|
|
645 {
|
|
646 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
647 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
648
|
|
649 try
|
|
650 {
|
|
651 backend->DeleteResource(id);
|
|
652 return OrthancPluginErrorCode_Success;
|
|
653 }
|
|
654 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
655 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
656 }
|
|
657
|
|
658
|
|
659 static OrthancPluginErrorCode GetAllInternalIds(OrthancPluginDatabaseContext* context,
|
|
660 void* payload,
|
|
661 OrthancPluginResourceType resourceType)
|
|
662 {
|
|
663 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
664 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
665
|
|
666 try
|
|
667 {
|
|
668 std::list<int64_t> target;
|
|
669 backend->GetAllInternalIds(target, resourceType);
|
|
670
|
|
671 for (std::list<int64_t>::const_iterator
|
|
672 it = target.begin(); it != target.end(); ++it)
|
|
673 {
|
|
674 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
|
|
675 backend->GetOutput().database_, *it);
|
|
676 }
|
|
677
|
|
678 return OrthancPluginErrorCode_Success;
|
|
679 }
|
|
680 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
681 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
682 }
|
|
683
|
|
684
|
|
685 static OrthancPluginErrorCode GetAllPublicIds(OrthancPluginDatabaseContext* context,
|
|
686 void* payload,
|
|
687 OrthancPluginResourceType resourceType)
|
|
688 {
|
|
689 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
690 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
691
|
|
692 try
|
|
693 {
|
|
694 std::list<std::string> ids;
|
|
695 backend->GetAllPublicIds(ids, resourceType);
|
|
696
|
|
697 for (std::list<std::string>::const_iterator
|
|
698 it = ids.begin(); it != ids.end(); ++it)
|
|
699 {
|
|
700 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
|
|
701 backend->GetOutput().database_,
|
|
702 it->c_str());
|
|
703 }
|
|
704
|
|
705 return OrthancPluginErrorCode_Success;
|
|
706 }
|
|
707 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
708 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
709 }
|
|
710
|
|
711
|
|
712 static OrthancPluginErrorCode GetAllPublicIdsWithLimit(OrthancPluginDatabaseContext* context,
|
|
713 void* payload,
|
|
714 OrthancPluginResourceType resourceType,
|
|
715 uint64_t since,
|
|
716 uint64_t limit)
|
|
717 {
|
|
718 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
719 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
720
|
|
721 try
|
|
722 {
|
|
723 std::list<std::string> ids;
|
|
724 backend->GetAllPublicIds(ids, resourceType, since, limit);
|
|
725
|
|
726 for (std::list<std::string>::const_iterator
|
|
727 it = ids.begin(); it != ids.end(); ++it)
|
|
728 {
|
|
729 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
|
|
730 backend->GetOutput().database_,
|
|
731 it->c_str());
|
|
732 }
|
|
733
|
|
734 return OrthancPluginErrorCode_Success;
|
|
735 }
|
|
736 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
737 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
738 }
|
|
739
|
|
740
|
|
741 static OrthancPluginErrorCode GetChanges(OrthancPluginDatabaseContext* context,
|
|
742 void* payload,
|
|
743 int64_t since,
|
|
744 uint32_t maxResult)
|
|
745 {
|
|
746 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
747 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Change);
|
|
748
|
|
749 try
|
|
750 {
|
|
751 bool done;
|
|
752 backend->GetChanges(done, since, maxResult);
|
|
753
|
|
754 if (done)
|
|
755 {
|
|
756 OrthancPluginDatabaseAnswerChangesDone(backend->GetOutput().context_,
|
|
757 backend->GetOutput().database_);
|
|
758 }
|
|
759
|
|
760 return OrthancPluginErrorCode_Success;
|
|
761 }
|
|
762 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
763 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
764 }
|
|
765
|
|
766
|
|
767 static OrthancPluginErrorCode GetChildrenInternalId(OrthancPluginDatabaseContext* context,
|
|
768 void* payload,
|
|
769 int64_t id)
|
|
770 {
|
|
771 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
772 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
773
|
|
774 try
|
|
775 {
|
|
776 std::list<int64_t> target;
|
|
777 backend->GetChildrenInternalId(target, id);
|
|
778
|
|
779 for (std::list<int64_t>::const_iterator
|
|
780 it = target.begin(); it != target.end(); ++it)
|
|
781 {
|
|
782 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
|
|
783 backend->GetOutput().database_, *it);
|
|
784 }
|
|
785
|
|
786 return OrthancPluginErrorCode_Success;
|
|
787 }
|
|
788 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
789 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
790 }
|
|
791
|
|
792
|
|
793 static OrthancPluginErrorCode GetChildrenPublicId(OrthancPluginDatabaseContext* context,
|
|
794 void* payload,
|
|
795 int64_t id)
|
|
796 {
|
|
797 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
798 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
799
|
|
800 try
|
|
801 {
|
|
802 std::list<std::string> ids;
|
|
803 backend->GetChildrenPublicId(ids, id);
|
|
804
|
|
805 for (std::list<std::string>::const_iterator
|
|
806 it = ids.begin(); it != ids.end(); ++it)
|
|
807 {
|
|
808 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
|
|
809 backend->GetOutput().database_,
|
|
810 it->c_str());
|
|
811 }
|
|
812
|
|
813 return OrthancPluginErrorCode_Success;
|
|
814 }
|
|
815 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
816 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
817 }
|
|
818
|
|
819
|
|
820 static OrthancPluginErrorCode GetExportedResources(OrthancPluginDatabaseContext* context,
|
|
821 void* payload,
|
|
822 int64_t since,
|
|
823 uint32_t maxResult)
|
|
824 {
|
|
825 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
826 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_ExportedResource);
|
|
827
|
|
828 try
|
|
829 {
|
|
830 bool done;
|
|
831 backend->GetExportedResources(done, since, maxResult);
|
|
832
|
|
833 if (done)
|
|
834 {
|
|
835 OrthancPluginDatabaseAnswerExportedResourcesDone(backend->GetOutput().context_,
|
|
836 backend->GetOutput().database_);
|
|
837 }
|
|
838 return OrthancPluginErrorCode_Success;
|
|
839 }
|
|
840 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
841 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
842 }
|
|
843
|
|
844
|
|
845 static OrthancPluginErrorCode GetLastChange(OrthancPluginDatabaseContext* context,
|
|
846 void* payload)
|
|
847 {
|
|
848 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
849 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Change);
|
|
850
|
|
851 try
|
|
852 {
|
|
853 backend->GetLastChange();
|
|
854 return OrthancPluginErrorCode_Success;
|
|
855 }
|
|
856 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
857 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
858 }
|
|
859
|
|
860
|
|
861 static OrthancPluginErrorCode GetLastExportedResource(OrthancPluginDatabaseContext* context,
|
|
862 void* payload)
|
|
863 {
|
|
864 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
865 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_ExportedResource);
|
|
866
|
|
867 try
|
|
868 {
|
|
869 backend->GetLastExportedResource();
|
|
870 return OrthancPluginErrorCode_Success;
|
|
871 }
|
|
872 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
873 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
874 }
|
|
875
|
|
876
|
|
877 static OrthancPluginErrorCode GetMainDicomTags(OrthancPluginDatabaseContext* context,
|
|
878 void* payload,
|
|
879 int64_t id)
|
|
880 {
|
|
881 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
882 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_DicomTag);
|
|
883
|
|
884 try
|
|
885 {
|
|
886 backend->GetMainDicomTags(id);
|
|
887 return OrthancPluginErrorCode_Success;
|
|
888 }
|
|
889 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
890 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
891 }
|
|
892
|
|
893
|
|
894 static OrthancPluginErrorCode GetPublicId(OrthancPluginDatabaseContext* context,
|
|
895 void* payload,
|
|
896 int64_t id)
|
|
897 {
|
|
898 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
899 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
900
|
|
901 try
|
|
902 {
|
|
903 std::string s = backend->GetPublicId(id);
|
|
904 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
|
|
905 backend->GetOutput().database_,
|
|
906 s.c_str());
|
|
907
|
|
908 return OrthancPluginErrorCode_Success;
|
|
909 }
|
|
910 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
911 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
912 }
|
|
913
|
|
914
|
|
915 static OrthancPluginErrorCode GetResourceCount(uint64_t* target,
|
|
916 void* payload,
|
|
917 OrthancPluginResourceType resourceType)
|
|
918 {
|
|
919 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
920 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
921
|
|
922 try
|
|
923 {
|
|
924 *target = backend->GetResourceCount(resourceType);
|
|
925 return OrthancPluginErrorCode_Success;
|
|
926 }
|
|
927 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
928 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
929 }
|
|
930
|
|
931
|
|
932 static OrthancPluginErrorCode GetResourceType(OrthancPluginResourceType* resourceType,
|
|
933 void* payload,
|
|
934 int64_t id)
|
|
935 {
|
|
936 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
937 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
938
|
|
939 try
|
|
940 {
|
|
941 *resourceType = backend->GetResourceType(id);
|
|
942 return OrthancPluginErrorCode_Success;
|
|
943 }
|
|
944 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
945 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
946 }
|
|
947
|
|
948
|
|
949 static OrthancPluginErrorCode GetTotalCompressedSize(uint64_t* target,
|
|
950 void* payload)
|
|
951 {
|
|
952 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
953 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
954
|
|
955 try
|
|
956 {
|
|
957 *target = backend->GetTotalCompressedSize();
|
|
958 return OrthancPluginErrorCode_Success;
|
|
959 }
|
|
960 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
961 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
962 }
|
|
963
|
|
964
|
|
965 static OrthancPluginErrorCode GetTotalUncompressedSize(uint64_t* target,
|
|
966 void* payload)
|
|
967 {
|
|
968 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
969 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
970
|
|
971 try
|
|
972 {
|
|
973 *target = backend->GetTotalUncompressedSize();
|
|
974 return OrthancPluginErrorCode_Success;
|
|
975 }
|
|
976 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
977 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
978 }
|
|
979
|
|
980
|
|
981 static OrthancPluginErrorCode IsExistingResource(int32_t* existing,
|
|
982 void* payload,
|
|
983 int64_t id)
|
|
984 {
|
|
985 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
986 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
987
|
|
988 try
|
|
989 {
|
|
990 *existing = backend->IsExistingResource(id);
|
|
991 return OrthancPluginErrorCode_Success;
|
|
992 }
|
|
993 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
994 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
995 }
|
|
996
|
|
997
|
|
998 static OrthancPluginErrorCode IsProtectedPatient(int32_t* isProtected,
|
|
999 void* payload,
|
|
1000 int64_t id)
|
|
1001 {
|
|
1002 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1003 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1004
|
|
1005 try
|
|
1006 {
|
|
1007 *isProtected = backend->IsProtectedPatient(id);
|
|
1008 return OrthancPluginErrorCode_Success;
|
|
1009 }
|
|
1010 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1011 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1012 }
|
|
1013
|
|
1014
|
|
1015 static OrthancPluginErrorCode ListAvailableMetadata(OrthancPluginDatabaseContext* context,
|
|
1016 void* payload,
|
|
1017 int64_t id)
|
|
1018 {
|
|
1019 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1020 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1021
|
|
1022 try
|
|
1023 {
|
|
1024 std::list<int32_t> target;
|
|
1025 backend->ListAvailableMetadata(target, id);
|
|
1026
|
|
1027 for (std::list<int32_t>::const_iterator
|
|
1028 it = target.begin(); it != target.end(); ++it)
|
|
1029 {
|
|
1030 OrthancPluginDatabaseAnswerInt32(backend->GetOutput().context_,
|
|
1031 backend->GetOutput().database_,
|
|
1032 *it);
|
|
1033 }
|
|
1034
|
|
1035 return OrthancPluginErrorCode_Success;
|
|
1036 }
|
|
1037 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1038 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1039 }
|
|
1040
|
|
1041
|
|
1042 static OrthancPluginErrorCode ListAvailableAttachments(OrthancPluginDatabaseContext* context,
|
|
1043 void* payload,
|
|
1044 int64_t id)
|
|
1045 {
|
|
1046 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1047 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1048
|
|
1049 try
|
|
1050 {
|
|
1051 std::list<int32_t> target;
|
|
1052 backend->ListAvailableAttachments(target, id);
|
|
1053
|
|
1054 for (std::list<int32_t>::const_iterator
|
|
1055 it = target.begin(); it != target.end(); ++it)
|
|
1056 {
|
|
1057 OrthancPluginDatabaseAnswerInt32(backend->GetOutput().context_,
|
|
1058 backend->GetOutput().database_,
|
|
1059 *it);
|
|
1060 }
|
|
1061
|
|
1062 return OrthancPluginErrorCode_Success;
|
|
1063 }
|
|
1064 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1065 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1066 }
|
|
1067
|
|
1068
|
|
1069 static OrthancPluginErrorCode LogChange(void* payload,
|
|
1070 const OrthancPluginChange* change)
|
|
1071 {
|
|
1072 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1073 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1074
|
|
1075 try
|
|
1076 {
|
|
1077 backend->LogChange(*change);
|
|
1078 return OrthancPluginErrorCode_Success;
|
|
1079 }
|
|
1080 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1081 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1082 }
|
|
1083
|
|
1084
|
|
1085 static OrthancPluginErrorCode LogExportedResource(void* payload,
|
|
1086 const OrthancPluginExportedResource* exported)
|
|
1087 {
|
|
1088 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1089 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1090
|
|
1091 try
|
|
1092 {
|
|
1093 backend->LogExportedResource(*exported);
|
|
1094 return OrthancPluginErrorCode_Success;
|
|
1095 }
|
|
1096 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1097 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1098 }
|
|
1099
|
|
1100
|
|
1101 static OrthancPluginErrorCode LookupAttachment(OrthancPluginDatabaseContext* context,
|
|
1102 void* payload,
|
|
1103 int64_t id,
|
|
1104 int32_t contentType)
|
|
1105 {
|
|
1106 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1107 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Attachment);
|
|
1108
|
|
1109 try
|
|
1110 {
|
|
1111 backend->LookupAttachment(id, contentType);
|
|
1112 return OrthancPluginErrorCode_Success;
|
|
1113 }
|
|
1114 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1115 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1116 }
|
|
1117
|
|
1118
|
|
1119 static OrthancPluginErrorCode LookupGlobalProperty(OrthancPluginDatabaseContext* context,
|
|
1120 void* payload,
|
|
1121 int32_t property)
|
|
1122 {
|
|
1123 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1124 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1125
|
|
1126 try
|
|
1127 {
|
|
1128 std::string s;
|
|
1129 if (backend->LookupGlobalProperty(s, property))
|
|
1130 {
|
|
1131 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
|
|
1132 backend->GetOutput().database_,
|
|
1133 s.c_str());
|
|
1134 }
|
|
1135
|
|
1136 return OrthancPluginErrorCode_Success;
|
|
1137 }
|
|
1138 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1139 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1140 }
|
|
1141
|
|
1142
|
|
1143 static OrthancPluginErrorCode LookupIdentifier3(OrthancPluginDatabaseContext* context,
|
|
1144 void* payload,
|
|
1145 OrthancPluginResourceType resourceType,
|
|
1146 const OrthancPluginDicomTag* tag,
|
|
1147 OrthancPluginIdentifierConstraint constraint)
|
|
1148 {
|
|
1149 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1150 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1151
|
|
1152 try
|
|
1153 {
|
|
1154 std::list<int64_t> target;
|
|
1155 backend->LookupIdentifier(target, resourceType, tag->group, tag->element, constraint, tag->value);
|
|
1156
|
|
1157 for (std::list<int64_t>::const_iterator
|
|
1158 it = target.begin(); it != target.end(); ++it)
|
|
1159 {
|
|
1160 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
|
|
1161 backend->GetOutput().database_, *it);
|
|
1162 }
|
|
1163
|
|
1164 return OrthancPluginErrorCode_Success;
|
|
1165 }
|
|
1166 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1167 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1168 }
|
|
1169
|
|
1170
|
|
1171 static OrthancPluginErrorCode LookupIdentifierRange(OrthancPluginDatabaseContext* context,
|
|
1172 void* payload,
|
|
1173 OrthancPluginResourceType resourceType,
|
|
1174 uint16_t group,
|
|
1175 uint16_t element,
|
|
1176 const char* start,
|
|
1177 const char* end)
|
|
1178 {
|
|
1179 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1180 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1181
|
|
1182 try
|
|
1183 {
|
|
1184 std::list<int64_t> target;
|
|
1185 backend->LookupIdentifierRange(target, resourceType, group, element, start, end);
|
|
1186
|
|
1187 for (std::list<int64_t>::const_iterator
|
|
1188 it = target.begin(); it != target.end(); ++it)
|
|
1189 {
|
|
1190 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
|
|
1191 backend->GetOutput().database_, *it);
|
|
1192 }
|
|
1193
|
|
1194 return OrthancPluginErrorCode_Success;
|
|
1195 }
|
|
1196 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1197 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1198 }
|
|
1199
|
|
1200
|
|
1201 static OrthancPluginErrorCode LookupMetadata(OrthancPluginDatabaseContext* context,
|
|
1202 void* payload,
|
|
1203 int64_t id,
|
|
1204 int32_t metadata)
|
|
1205 {
|
|
1206 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1207 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1208
|
|
1209 try
|
|
1210 {
|
|
1211 std::string s;
|
|
1212 if (backend->LookupMetadata(s, id, metadata))
|
|
1213 {
|
|
1214 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
|
|
1215 backend->GetOutput().database_, s.c_str());
|
|
1216 }
|
|
1217
|
|
1218 return OrthancPluginErrorCode_Success;
|
|
1219 }
|
|
1220 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1221 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1222 }
|
|
1223
|
|
1224
|
|
1225 static OrthancPluginErrorCode LookupParent(OrthancPluginDatabaseContext* context,
|
|
1226 void* payload,
|
|
1227 int64_t id)
|
|
1228 {
|
|
1229 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1230 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1231
|
|
1232 try
|
|
1233 {
|
|
1234 int64_t parent;
|
|
1235 if (backend->LookupParent(parent, id))
|
|
1236 {
|
|
1237 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
|
|
1238 backend->GetOutput().database_, parent);
|
|
1239 }
|
|
1240
|
|
1241 return OrthancPluginErrorCode_Success;
|
|
1242 }
|
|
1243 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1244 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1245 }
|
|
1246
|
|
1247
|
|
1248 static OrthancPluginErrorCode LookupResource(OrthancPluginDatabaseContext* context,
|
|
1249 void* payload,
|
|
1250 const char* publicId)
|
|
1251 {
|
|
1252 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1253 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1254
|
|
1255 try
|
|
1256 {
|
|
1257 int64_t id;
|
|
1258 OrthancPluginResourceType type;
|
|
1259 if (backend->LookupResource(id, type, publicId))
|
|
1260 {
|
|
1261 OrthancPluginDatabaseAnswerResource(backend->GetOutput().context_,
|
|
1262 backend->GetOutput().database_,
|
|
1263 id, type);
|
|
1264 }
|
|
1265
|
|
1266 return OrthancPluginErrorCode_Success;
|
|
1267 }
|
|
1268 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1269 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1270 }
|
|
1271
|
|
1272
|
|
1273 static OrthancPluginErrorCode SelectPatientToRecycle(OrthancPluginDatabaseContext* context,
|
|
1274 void* payload)
|
|
1275 {
|
|
1276 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1277 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1278
|
|
1279 try
|
|
1280 {
|
|
1281 int64_t id;
|
|
1282 if (backend->SelectPatientToRecycle(id))
|
|
1283 {
|
|
1284 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
|
|
1285 backend->GetOutput().database_, id);
|
|
1286 }
|
|
1287
|
|
1288 return OrthancPluginErrorCode_Success;
|
|
1289 }
|
|
1290 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1291 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1292 }
|
|
1293
|
|
1294
|
|
1295 static OrthancPluginErrorCode SelectPatientToRecycle2(OrthancPluginDatabaseContext* context,
|
|
1296 void* payload,
|
|
1297 int64_t patientIdToAvoid)
|
|
1298 {
|
|
1299 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1300 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1301
|
|
1302 try
|
|
1303 {
|
|
1304 int64_t id;
|
|
1305 if (backend->SelectPatientToRecycle(id, patientIdToAvoid))
|
|
1306 {
|
|
1307 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
|
|
1308 backend->GetOutput().database_, id);
|
|
1309 }
|
|
1310
|
|
1311 return OrthancPluginErrorCode_Success;
|
|
1312 }
|
|
1313 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1314 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1315 }
|
|
1316
|
|
1317
|
|
1318 static OrthancPluginErrorCode SetGlobalProperty(void* payload,
|
|
1319 int32_t property,
|
|
1320 const char* value)
|
|
1321 {
|
|
1322 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1323 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1324
|
|
1325 try
|
|
1326 {
|
|
1327 backend->SetGlobalProperty(property, value);
|
|
1328 return OrthancPluginErrorCode_Success;
|
|
1329 }
|
|
1330 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1331 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1332 }
|
|
1333
|
|
1334
|
|
1335 static OrthancPluginErrorCode SetMainDicomTag(void* payload,
|
|
1336 int64_t id,
|
|
1337 const OrthancPluginDicomTag* tag)
|
|
1338 {
|
|
1339 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1340 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1341
|
|
1342 try
|
|
1343 {
|
|
1344 backend->SetMainDicomTag(id, tag->group, tag->element, tag->value);
|
|
1345 return OrthancPluginErrorCode_Success;
|
|
1346 }
|
|
1347 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1348 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1349 }
|
|
1350
|
|
1351
|
|
1352 static OrthancPluginErrorCode SetIdentifierTag(void* payload,
|
|
1353 int64_t id,
|
|
1354 const OrthancPluginDicomTag* tag)
|
|
1355 {
|
|
1356 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1357 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1358
|
|
1359 try
|
|
1360 {
|
|
1361 backend->SetIdentifierTag(id, tag->group, tag->element, tag->value);
|
|
1362 return OrthancPluginErrorCode_Success;
|
|
1363 }
|
|
1364 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1365 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1366 }
|
|
1367
|
|
1368
|
|
1369 static OrthancPluginErrorCode SetMetadata(void* payload,
|
|
1370 int64_t id,
|
|
1371 int32_t metadata,
|
|
1372 const char* value)
|
|
1373 {
|
|
1374 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1375 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1376
|
|
1377 try
|
|
1378 {
|
|
1379 backend->SetMetadata(id, metadata, value);
|
|
1380 return OrthancPluginErrorCode_Success;
|
|
1381 }
|
|
1382 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1383 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1384 }
|
|
1385
|
|
1386
|
|
1387 static OrthancPluginErrorCode SetProtectedPatient(void* payload,
|
|
1388 int64_t id,
|
|
1389 int32_t isProtected)
|
|
1390 {
|
|
1391 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1392 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1393
|
|
1394 try
|
|
1395 {
|
|
1396 backend->SetProtectedPatient(id, (isProtected != 0));
|
|
1397 return OrthancPluginErrorCode_Success;
|
|
1398 }
|
|
1399 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1400 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1401 }
|
|
1402
|
|
1403
|
|
1404 static OrthancPluginErrorCode StartTransaction(void* payload)
|
|
1405 {
|
|
1406 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1407 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1408
|
|
1409 try
|
|
1410 {
|
|
1411 backend->StartTransaction();
|
|
1412 return OrthancPluginErrorCode_Success;
|
|
1413 }
|
|
1414 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1415 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1416 }
|
|
1417
|
|
1418
|
|
1419 static OrthancPluginErrorCode RollbackTransaction(void* payload)
|
|
1420 {
|
|
1421 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1422 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1423
|
|
1424 try
|
|
1425 {
|
|
1426 backend->RollbackTransaction();
|
|
1427 return OrthancPluginErrorCode_Success;
|
|
1428 }
|
|
1429 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1430 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1431 }
|
|
1432
|
|
1433
|
|
1434 static OrthancPluginErrorCode CommitTransaction(void* payload)
|
|
1435 {
|
|
1436 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1437 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1438
|
|
1439 try
|
|
1440 {
|
|
1441 backend->CommitTransaction();
|
|
1442 return OrthancPluginErrorCode_Success;
|
|
1443 }
|
|
1444 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1445 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1446 }
|
|
1447
|
|
1448
|
|
1449 static OrthancPluginErrorCode Open(void* payload)
|
|
1450 {
|
|
1451 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1452 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1453
|
|
1454 try
|
|
1455 {
|
|
1456 backend->Open();
|
|
1457 return OrthancPluginErrorCode_Success;
|
|
1458 }
|
|
1459 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1460 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1461 }
|
|
1462
|
|
1463
|
|
1464 static OrthancPluginErrorCode Close(void* payload)
|
|
1465 {
|
|
1466 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1467 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
|
|
1468
|
|
1469 try
|
|
1470 {
|
|
1471 backend->Close();
|
|
1472 return OrthancPluginErrorCode_Success;
|
|
1473 }
|
|
1474 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1475 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1476 }
|
|
1477
|
|
1478
|
|
1479 static OrthancPluginErrorCode GetDatabaseVersion(uint32_t* version,
|
|
1480 void* payload)
|
|
1481 {
|
|
1482 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1483
|
|
1484 try
|
|
1485 {
|
|
1486 *version = backend->GetDatabaseVersion();
|
|
1487 return OrthancPluginErrorCode_Success;
|
|
1488 }
|
|
1489 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1490 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1491 }
|
|
1492
|
|
1493
|
|
1494 static OrthancPluginErrorCode UpgradeDatabase(void* payload,
|
|
1495 uint32_t targetVersion,
|
|
1496 OrthancPluginStorageArea* storageArea)
|
|
1497 {
|
|
1498 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1499
|
|
1500 try
|
|
1501 {
|
|
1502 backend->UpgradeDatabase(targetVersion, storageArea);
|
|
1503 return OrthancPluginErrorCode_Success;
|
|
1504 }
|
|
1505 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1506 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1507 }
|
|
1508
|
|
1509
|
|
1510 static OrthancPluginErrorCode ClearMainDicomTags(void* payload,
|
|
1511 int64_t internalId)
|
|
1512 {
|
|
1513 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload);
|
|
1514
|
|
1515 try
|
|
1516 {
|
|
1517 backend->ClearMainDicomTags(internalId);
|
|
1518 return OrthancPluginErrorCode_Success;
|
|
1519 }
|
|
1520 ORTHANC_PLUGINS_DATABASE_CATCH_ORTHANC
|
|
1521 ORTHANC_PLUGINS_DATABASE_CATCH_COMMON
|
|
1522 }
|
|
1523
|
|
1524
|
|
1525 public:
|
|
1526 /**
|
|
1527 * Register a custom database back-end written in C++.
|
|
1528 *
|
|
1529 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
1530 * @param backend Your custom database engine.
|
|
1531 **/
|
|
1532
|
|
1533 static void Register(OrthancPluginContext* context,
|
|
1534 IDatabaseBackend& backend)
|
|
1535 {
|
|
1536 OrthancPluginDatabaseBackend params;
|
|
1537 memset(¶ms, 0, sizeof(params));
|
|
1538
|
|
1539 OrthancPluginDatabaseExtensions extensions;
|
|
1540 memset(&extensions, 0, sizeof(extensions));
|
|
1541
|
|
1542 params.addAttachment = AddAttachment;
|
|
1543 params.attachChild = AttachChild;
|
|
1544 params.clearChanges = ClearChanges;
|
|
1545 params.clearExportedResources = ClearExportedResources;
|
|
1546 params.createResource = CreateResource;
|
|
1547 params.deleteAttachment = DeleteAttachment;
|
|
1548 params.deleteMetadata = DeleteMetadata;
|
|
1549 params.deleteResource = DeleteResource;
|
|
1550 params.getAllPublicIds = GetAllPublicIds;
|
|
1551 params.getChanges = GetChanges;
|
|
1552 params.getChildrenInternalId = GetChildrenInternalId;
|
|
1553 params.getChildrenPublicId = GetChildrenPublicId;
|
|
1554 params.getExportedResources = GetExportedResources;
|
|
1555 params.getLastChange = GetLastChange;
|
|
1556 params.getLastExportedResource = GetLastExportedResource;
|
|
1557 params.getMainDicomTags = GetMainDicomTags;
|
|
1558 params.getPublicId = GetPublicId;
|
|
1559 params.getResourceCount = GetResourceCount;
|
|
1560 params.getResourceType = GetResourceType;
|
|
1561 params.getTotalCompressedSize = GetTotalCompressedSize;
|
|
1562 params.getTotalUncompressedSize = GetTotalUncompressedSize;
|
|
1563 params.isExistingResource = IsExistingResource;
|
|
1564 params.isProtectedPatient = IsProtectedPatient;
|
|
1565 params.listAvailableMetadata = ListAvailableMetadata;
|
|
1566 params.listAvailableAttachments = ListAvailableAttachments;
|
|
1567 params.logChange = LogChange;
|
|
1568 params.logExportedResource = LogExportedResource;
|
|
1569 params.lookupAttachment = LookupAttachment;
|
|
1570 params.lookupGlobalProperty = LookupGlobalProperty;
|
|
1571 params.lookupIdentifier = NULL; // Unused starting with Orthanc 0.9.5 (db v6)
|
|
1572 params.lookupIdentifier2 = NULL; // Unused starting with Orthanc 0.9.5 (db v6)
|
|
1573 params.lookupMetadata = LookupMetadata;
|
|
1574 params.lookupParent = LookupParent;
|
|
1575 params.lookupResource = LookupResource;
|
|
1576 params.selectPatientToRecycle = SelectPatientToRecycle;
|
|
1577 params.selectPatientToRecycle2 = SelectPatientToRecycle2;
|
|
1578 params.setGlobalProperty = SetGlobalProperty;
|
|
1579 params.setMainDicomTag = SetMainDicomTag;
|
|
1580 params.setIdentifierTag = SetIdentifierTag;
|
|
1581 params.setMetadata = SetMetadata;
|
|
1582 params.setProtectedPatient = SetProtectedPatient;
|
|
1583 params.startTransaction = StartTransaction;
|
|
1584 params.rollbackTransaction = RollbackTransaction;
|
|
1585 params.commitTransaction = CommitTransaction;
|
|
1586 params.open = Open;
|
|
1587 params.close = Close;
|
|
1588
|
|
1589 extensions.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit;
|
|
1590 extensions.getDatabaseVersion = GetDatabaseVersion;
|
|
1591 extensions.upgradeDatabase = UpgradeDatabase;
|
|
1592 extensions.clearMainDicomTags = ClearMainDicomTags;
|
|
1593 extensions.getAllInternalIds = GetAllInternalIds; // New in Orthanc 0.9.5 (db v6)
|
|
1594 extensions.lookupIdentifier3 = LookupIdentifier3; // New in Orthanc 0.9.5 (db v6)
|
|
1595
|
|
1596 bool performanceWarning = true;
|
|
1597
|
|
1598 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1
|
|
1599 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 4, 0)
|
|
1600 extensions.lookupIdentifierRange = LookupIdentifierRange; // New in Orthanc 1.4.0
|
|
1601 performanceWarning = false;
|
|
1602 # endif
|
|
1603 #endif
|
|
1604
|
|
1605 if (performanceWarning)
|
|
1606 {
|
|
1607 OrthancPluginLogWarning(context, "Performance warning: The database plugin was compiled "
|
|
1608 "against an old version of the Orthanc SDK, consider upgrading");
|
|
1609 }
|
|
1610
|
|
1611 OrthancPluginDatabaseContext* database = OrthancPluginRegisterDatabaseBackendV2(context, ¶ms, &extensions, &backend);
|
|
1612 if (!context)
|
|
1613 {
|
|
1614 throw std::runtime_error("Unable to register the database backend");
|
|
1615 }
|
|
1616
|
|
1617 backend.RegisterOutput(new DatabaseBackendOutput(context, database));
|
|
1618 }
|
|
1619 };
|
|
1620 }
|