37 #include "OrthancCDatabasePlugin.h"
50 NonCopyable(
const NonCopyable&);
52 NonCopyable& operator= (
const NonCopyable&);
102 AllowedAnswers_Attachment,
103 AllowedAnswers_Change,
104 AllowedAnswers_DicomTag,
105 AllowedAnswers_ExportedResource
110 AllowedAnswers allowedAnswers_;
112 void SetAllowedAnswers(AllowedAnswers allowed)
114 allowedAnswers_ = allowed;
122 allowedAnswers_(AllowedAnswers_All )
131 void LogError(
const std::string& message)
136 void LogWarning(
const std::string& message)
141 void LogInfo(
const std::string& message)
146 void SignalDeletedAttachment(
const std::string& uuid,
148 uint64_t uncompressedSize,
149 const std::string& uncompressedHash,
150 int32_t compressionType,
151 uint64_t compressedSize,
152 const std::string& compressedHash)
154 OrthancPluginAttachment attachment;
155 attachment.uuid = uuid.c_str();
156 attachment.contentType = contentType;
157 attachment.uncompressedSize = uncompressedSize;
158 attachment.uncompressedHash = uncompressedHash.c_str();
159 attachment.compressionType = compressionType;
160 attachment.compressedSize = compressedSize;
161 attachment.compressedHash = compressedHash.c_str();
163 OrthancPluginDatabaseSignalDeletedAttachment(context_, database_, &attachment);
166 void SignalDeletedResource(
const std::string& publicId,
169 OrthancPluginDatabaseSignalDeletedResource(context_, database_, publicId.c_str(), resourceType);
172 void SignalRemainingAncestor(
const std::string& ancestorId,
175 OrthancPluginDatabaseSignalRemainingAncestor(context_, database_, ancestorId.c_str(), ancestorType);
178 void AnswerAttachment(
const std::string& uuid,
180 uint64_t uncompressedSize,
181 const std::string& uncompressedHash,
182 int32_t compressionType,
183 uint64_t compressedSize,
184 const std::string& compressedHash)
186 if (allowedAnswers_ != AllowedAnswers_All &&
187 allowedAnswers_ != AllowedAnswers_Attachment)
189 throw std::runtime_error(
"Cannot answer with an attachment in the current state");
192 OrthancPluginAttachment attachment;
193 attachment.uuid = uuid.c_str();
194 attachment.contentType = contentType;
195 attachment.uncompressedSize = uncompressedSize;
196 attachment.uncompressedHash = uncompressedHash.c_str();
197 attachment.compressionType = compressionType;
198 attachment.compressedSize = compressedSize;
199 attachment.compressedHash = compressedHash.c_str();
201 OrthancPluginDatabaseAnswerAttachment(context_, database_, &attachment);
204 void AnswerChange(int64_t seq,
207 const std::string& publicId,
208 const std::string& date)
210 if (allowedAnswers_ != AllowedAnswers_All &&
211 allowedAnswers_ != AllowedAnswers_Change)
213 throw std::runtime_error(
"Cannot answer with a change in the current state");
216 OrthancPluginChange change;
218 change.changeType = changeType;
219 change.resourceType = resourceType;
220 change.publicId = publicId.c_str();
221 change.date = date.c_str();
223 OrthancPluginDatabaseAnswerChange(context_, database_, &change);
226 void AnswerDicomTag(uint16_t group,
228 const std::string& value)
230 if (allowedAnswers_ != AllowedAnswers_All &&
231 allowedAnswers_ != AllowedAnswers_DicomTag)
233 throw std::runtime_error(
"Cannot answer with a DICOM tag in the current state");
236 OrthancPluginDicomTag tag;
238 tag.element = element;
239 tag.value = value.c_str();
241 OrthancPluginDatabaseAnswerDicomTag(context_, database_, &tag);
244 void AnswerExportedResource(int64_t seq,
246 const std::string& publicId,
247 const std::string& modality,
248 const std::string& date,
249 const std::string& patientId,
250 const std::string& studyInstanceUid,
251 const std::string& seriesInstanceUid,
252 const std::string& sopInstanceUid)
254 if (allowedAnswers_ != AllowedAnswers_All &&
255 allowedAnswers_ != AllowedAnswers_ExportedResource)
257 throw std::runtime_error(
"Cannot answer with an exported resource in the current state");
260 OrthancPluginExportedResource exported;
262 exported.resourceType = resourceType;
263 exported.publicId = publicId.c_str();
264 exported.modality = modality.c_str();
265 exported.date = date.c_str();
266 exported.patientId = patientId.c_str();
267 exported.studyInstanceUid = studyInstanceUid.c_str();
268 exported.seriesInstanceUid = seriesInstanceUid.c_str();
269 exported.sopInstanceUid = sopInstanceUid.c_str();
271 OrthancPluginDatabaseAnswerExportedResource(context_, database_, &exported);
318 virtual void Open() = 0;
320 virtual void Close() = 0;
322 virtual void AddAttachment(int64_t
id,
323 const OrthancPluginAttachment& attachment) = 0;
325 virtual void AttachChild(int64_t parent,
328 virtual void ClearChanges() = 0;
330 virtual void ClearExportedResources() = 0;
332 virtual int64_t CreateResource(
const char* publicId,
335 virtual void DeleteAttachment(int64_t
id,
336 int32_t attachment) = 0;
338 virtual void DeleteMetadata(int64_t
id,
339 int32_t metadataType) = 0;
341 virtual void DeleteResource(int64_t
id) = 0;
343 virtual void GetAllInternalIds(std::list<int64_t>& target,
346 virtual void GetAllPublicIds(std::list<std::string>& target,
349 virtual void GetAllPublicIds(std::list<std::string>& target,
355 virtual void GetChanges(
bool& done ,
357 uint32_t maxResults) = 0;
359 virtual void GetChildrenInternalId(std::list<int64_t>& target ,
362 virtual void GetChildrenPublicId(std::list<std::string>& target ,
366 virtual void GetExportedResources(
bool& done ,
368 uint32_t maxResults) = 0;
371 virtual void GetLastChange() = 0;
374 virtual void GetLastExportedResource() = 0;
377 virtual void GetMainDicomTags(int64_t
id) = 0;
379 virtual std::string GetPublicId(int64_t resourceId) = 0;
385 virtual uint64_t GetTotalCompressedSize() = 0;
387 virtual uint64_t GetTotalUncompressedSize() = 0;
389 virtual bool IsExistingResource(int64_t internalId) = 0;
391 virtual bool IsProtectedPatient(int64_t internalId) = 0;
393 virtual void ListAvailableMetadata(std::list<int32_t>& target ,
396 virtual void ListAvailableAttachments(std::list<int32_t>& target ,
399 virtual void LogChange(
const OrthancPluginChange& change) = 0;
401 virtual void LogExportedResource(
const OrthancPluginExportedResource& resource) = 0;
404 virtual bool LookupAttachment(int64_t
id,
405 int32_t contentType) = 0;
407 virtual bool LookupGlobalProperty(std::string& target ,
408 int32_t property) = 0;
410 virtual void LookupIdentifier(std::list<int64_t>& target ,
415 const char* value) = 0;
417 virtual bool LookupMetadata(std::string& target ,
419 int32_t metadataType) = 0;
421 virtual bool LookupParent(int64_t& parentId ,
422 int64_t resourceId) = 0;
424 virtual bool LookupResource(int64_t&
id ,
426 const char* publicId) = 0;
428 virtual bool SelectPatientToRecycle(int64_t& internalId ) = 0;
430 virtual bool SelectPatientToRecycle(int64_t& internalId ,
431 int64_t patientIdToAvoid) = 0;
433 virtual void SetGlobalProperty(int32_t property,
434 const char* value) = 0;
436 virtual void SetMainDicomTag(int64_t
id,
439 const char* value) = 0;
441 virtual void SetIdentifierTag(int64_t
id,
444 const char* value) = 0;
446 virtual void SetMetadata(int64_t
id,
447 int32_t metadataType,
448 const char* value) = 0;
450 virtual void SetProtectedPatient(int64_t internalId,
451 bool isProtected) = 0;
453 virtual void StartTransaction() = 0;
455 virtual void RollbackTransaction() = 0;
457 virtual void CommitTransaction() = 0;
459 virtual uint32_t GetDatabaseVersion() = 0;
469 virtual void ClearMainDicomTags(int64_t internalId) = 0;
492 const std::runtime_error& e)
494 backend->GetOutput().LogError(
"Exception in database back-end: " + std::string(e.what()));
500 const OrthancPluginAttachment* attachment)
503 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
507 backend->AddAttachment(
id, *attachment);
510 catch (std::runtime_error& e)
512 LogError(backend, e);
517 return e.GetErrorCode();
527 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
531 backend->AttachChild(parent, child);
534 catch (std::runtime_error& e)
536 LogError(backend, e);
541 return e.GetErrorCode();
549 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
553 backend->ClearChanges();
556 catch (std::runtime_error& e)
558 LogError(backend, e);
563 return e.GetErrorCode();
571 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
575 backend->ClearExportedResources();
578 catch (std::runtime_error& e)
580 LogError(backend, e);
585 return e.GetErrorCode();
592 const char* publicId,
596 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
600 *
id = backend->CreateResource(publicId, resourceType);
603 catch (std::runtime_error& e)
605 LogError(backend, e);
610 return e.GetErrorCode();
620 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
624 backend->DeleteAttachment(
id, contentType);
627 catch (std::runtime_error& e)
629 LogError(backend, e);
634 return e.GetErrorCode();
641 int32_t metadataType)
644 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
648 backend->DeleteMetadata(
id, metadataType);
651 catch (std::runtime_error& e)
653 LogError(backend, e);
658 return e.GetErrorCode();
667 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
671 backend->DeleteResource(
id);
674 catch (std::runtime_error& e)
676 LogError(backend, e);
681 return e.GetErrorCode();
691 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
695 std::list<int64_t> target;
696 backend->GetAllInternalIds(target, resourceType);
698 for (std::list<int64_t>::const_iterator
699 it = target.begin(); it != target.end(); ++it)
701 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
702 backend->GetOutput().database_, *it);
707 catch (std::runtime_error& e)
709 LogError(backend, e);
714 return e.GetErrorCode();
724 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
728 std::list<std::string> ids;
729 backend->GetAllPublicIds(ids, resourceType);
731 for (std::list<std::string>::const_iterator
732 it = ids.begin(); it != ids.end(); ++it)
734 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
735 backend->GetOutput().database_,
741 catch (std::runtime_error& e)
743 LogError(backend, e);
748 return e.GetErrorCode();
760 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
764 std::list<std::string> ids;
765 backend->GetAllPublicIds(ids, resourceType, since, limit);
767 for (std::list<std::string>::const_iterator
768 it = ids.begin(); it != ids.end(); ++it)
770 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
771 backend->GetOutput().database_,
777 catch (std::runtime_error& e)
779 LogError(backend, e);
784 return e.GetErrorCode();
795 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Change);
800 backend->GetChanges(done, since, maxResult);
804 OrthancPluginDatabaseAnswerChangesDone(backend->GetOutput().context_,
805 backend->GetOutput().database_);
810 catch (std::runtime_error& e)
812 LogError(backend, e);
817 return e.GetErrorCode();
827 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
831 std::list<int64_t> target;
832 backend->GetChildrenInternalId(target,
id);
834 for (std::list<int64_t>::const_iterator
835 it = target.begin(); it != target.end(); ++it)
837 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
838 backend->GetOutput().database_, *it);
843 catch (std::runtime_error& e)
845 LogError(backend, e);
850 return e.GetErrorCode();
860 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
864 std::list<std::string> ids;
865 backend->GetChildrenPublicId(ids,
id);
867 for (std::list<std::string>::const_iterator
868 it = ids.begin(); it != ids.end(); ++it)
870 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
871 backend->GetOutput().database_,
877 catch (std::runtime_error& e)
879 LogError(backend, e);
884 return e.GetErrorCode();
895 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_ExportedResource);
900 backend->GetExportedResources(done, since, maxResult);
904 OrthancPluginDatabaseAnswerExportedResourcesDone(backend->GetOutput().context_,
905 backend->GetOutput().database_);
909 catch (std::runtime_error& e)
911 LogError(backend, e);
916 return e.GetErrorCode();
925 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Change);
929 backend->GetLastChange();
932 catch (std::runtime_error& e)
934 LogError(backend, e);
939 return e.GetErrorCode();
948 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_ExportedResource);
952 backend->GetLastExportedResource();
955 catch (std::runtime_error& e)
957 LogError(backend, e);
962 return e.GetErrorCode();
972 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_DicomTag);
976 backend->GetMainDicomTags(
id);
979 catch (std::runtime_error& e)
981 LogError(backend, e);
986 return e.GetErrorCode();
996 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1000 std::string s = backend->GetPublicId(
id);
1001 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
1002 backend->GetOutput().database_,
1007 catch (std::runtime_error& e)
1009 LogError(backend, e);
1014 return e.GetErrorCode();
1024 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1028 *target = backend->GetResourceCount(resourceType);
1031 catch (std::runtime_error& e)
1033 LogError(backend, e);
1038 return e.GetErrorCode();
1048 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1052 *resourceType = backend->GetResourceType(
id);
1055 catch (std::runtime_error& e)
1057 LogError(backend, e);
1062 return e.GetErrorCode();
1071 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1075 *target = backend->GetTotalCompressedSize();
1078 catch (std::runtime_error& e)
1080 LogError(backend, e);
1085 return e.GetErrorCode();
1094 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1098 *target = backend->GetTotalUncompressedSize();
1101 catch (std::runtime_error& e)
1103 LogError(backend, e);
1108 return e.GetErrorCode();
1118 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1122 *existing = backend->IsExistingResource(
id);
1125 catch (std::runtime_error& e)
1127 LogError(backend, e);
1132 return e.GetErrorCode();
1142 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1146 *isProtected = backend->IsProtectedPatient(
id);
1149 catch (std::runtime_error& e)
1151 LogError(backend, e);
1156 return e.GetErrorCode();
1166 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1170 std::list<int32_t> target;
1171 backend->ListAvailableMetadata(target,
id);
1173 for (std::list<int32_t>::const_iterator
1174 it = target.begin(); it != target.end(); ++it)
1176 OrthancPluginDatabaseAnswerInt32(backend->GetOutput().context_,
1177 backend->GetOutput().database_,
1183 catch (std::runtime_error& e)
1185 LogError(backend, e);
1190 return e.GetErrorCode();
1200 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1204 std::list<int32_t> target;
1205 backend->ListAvailableAttachments(target,
id);
1207 for (std::list<int32_t>::const_iterator
1208 it = target.begin(); it != target.end(); ++it)
1210 OrthancPluginDatabaseAnswerInt32(backend->GetOutput().context_,
1211 backend->GetOutput().database_,
1217 catch (std::runtime_error& e)
1219 LogError(backend, e);
1224 return e.GetErrorCode();
1230 const OrthancPluginChange* change)
1233 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1237 backend->LogChange(*change);
1240 catch (std::runtime_error& e)
1242 LogError(backend, e);
1247 return e.GetErrorCode();
1253 const OrthancPluginExportedResource* exported)
1256 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1260 backend->LogExportedResource(*exported);
1263 catch (std::runtime_error& e)
1265 LogError(backend, e);
1270 return e.GetErrorCode();
1278 int32_t contentType)
1281 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Attachment);
1285 backend->LookupAttachment(
id, contentType);
1288 catch (std::runtime_error& e)
1290 LogError(backend, e);
1295 return e.GetErrorCode();
1305 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1310 if (backend->LookupGlobalProperty(s, property))
1312 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
1313 backend->GetOutput().database_,
1319 catch (std::runtime_error& e)
1321 LogError(backend, e);
1326 return e.GetErrorCode();
1334 const OrthancPluginDicomTag* tag,
1338 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1342 std::list<int64_t> target;
1343 backend->LookupIdentifier(target, resourceType, tag->group, tag->element, constraint, tag->value);
1345 for (std::list<int64_t>::const_iterator
1346 it = target.begin(); it != target.end(); ++it)
1348 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
1349 backend->GetOutput().database_, *it);
1354 catch (std::runtime_error& e)
1356 LogError(backend, e);
1361 return e.GetErrorCode();
1372 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1377 if (backend->LookupMetadata(s,
id, metadata))
1379 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_,
1380 backend->GetOutput().database_, s.c_str());
1385 catch (std::runtime_error& e)
1387 LogError(backend, e);
1392 return e.GetErrorCode();
1402 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1407 if (backend->LookupParent(parent,
id))
1409 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
1410 backend->GetOutput().database_, parent);
1415 catch (std::runtime_error& e)
1417 LogError(backend, e);
1422 return e.GetErrorCode();
1429 const char* publicId)
1432 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1438 if (backend->LookupResource(
id, type, publicId))
1440 OrthancPluginDatabaseAnswerResource(backend->GetOutput().context_,
1441 backend->GetOutput().database_,
1447 catch (std::runtime_error& e)
1449 LogError(backend, e);
1454 return e.GetErrorCode();
1463 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1468 if (backend->SelectPatientToRecycle(
id))
1470 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
1471 backend->GetOutput().database_,
id);
1476 catch (std::runtime_error& e)
1478 LogError(backend, e);
1483 return e.GetErrorCode();
1490 int64_t patientIdToAvoid)
1493 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1498 if (backend->SelectPatientToRecycle(
id, patientIdToAvoid))
1500 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_,
1501 backend->GetOutput().database_,
id);
1506 catch (std::runtime_error& e)
1508 LogError(backend, e);
1513 return e.GetErrorCode();
1523 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1527 backend->SetGlobalProperty(property, value);
1530 catch (std::runtime_error& e)
1532 LogError(backend, e);
1537 return e.GetErrorCode();
1544 const OrthancPluginDicomTag* tag)
1547 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1551 backend->SetMainDicomTag(
id, tag->group, tag->element, tag->value);
1554 catch (std::runtime_error& e)
1556 LogError(backend, e);
1561 return e.GetErrorCode();
1568 const OrthancPluginDicomTag* tag)
1571 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1575 backend->SetIdentifierTag(
id, tag->group, tag->element, tag->value);
1578 catch (std::runtime_error& e)
1580 LogError(backend, e);
1585 return e.GetErrorCode();
1596 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1600 backend->SetMetadata(
id, metadata, value);
1603 catch (std::runtime_error& e)
1605 LogError(backend, e);
1610 return e.GetErrorCode();
1617 int32_t isProtected)
1620 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1624 backend->SetProtectedPatient(
id, (isProtected != 0));
1627 catch (std::runtime_error& e)
1629 LogError(backend, e);
1634 return e.GetErrorCode();
1642 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1646 backend->StartTransaction();
1649 catch (std::runtime_error& e)
1651 LogError(backend, e);
1656 return e.GetErrorCode();
1664 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1668 backend->RollbackTransaction();
1671 catch (std::runtime_error& e)
1673 LogError(backend, e);
1678 return e.GetErrorCode();
1686 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1690 backend->CommitTransaction();
1693 catch (std::runtime_error& e)
1695 LogError(backend, e);
1700 return e.GetErrorCode();
1708 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1715 catch (std::runtime_error& e)
1717 LogError(backend, e);
1722 return e.GetErrorCode();
1730 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None);
1737 catch (std::runtime_error& e)
1739 LogError(backend, e);
1744 return e.GetErrorCode();
1756 *version = backend->GetDatabaseVersion();
1759 catch (std::runtime_error& e)
1761 LogError(backend, e);
1766 return e.GetErrorCode();
1772 uint32_t targetVersion,
1782 catch (std::runtime_error& e)
1784 LogError(backend, e);
1789 return e.GetErrorCode();
1801 backend->ClearMainDicomTags(internalId);
1804 catch (std::runtime_error& e)
1806 LogError(backend, e);
1811 return e.GetErrorCode();
1827 OrthancPluginDatabaseBackend params;
1828 memset(¶ms, 0,
sizeof(params));
1830 OrthancPluginDatabaseExtensions extensions;
1831 memset(&extensions, 0,
sizeof(extensions));
1833 params.addAttachment = AddAttachment;
1834 params.attachChild = AttachChild;
1835 params.clearChanges = ClearChanges;
1836 params.clearExportedResources = ClearExportedResources;
1837 params.createResource = CreateResource;
1838 params.deleteAttachment = DeleteAttachment;
1839 params.deleteMetadata = DeleteMetadata;
1840 params.deleteResource = DeleteResource;
1841 params.getAllPublicIds = GetAllPublicIds;
1842 params.getChanges = GetChanges;
1843 params.getChildrenInternalId = GetChildrenInternalId;
1844 params.getChildrenPublicId = GetChildrenPublicId;
1845 params.getExportedResources = GetExportedResources;
1846 params.getLastChange = GetLastChange;
1847 params.getLastExportedResource = GetLastExportedResource;
1848 params.getMainDicomTags = GetMainDicomTags;
1849 params.getPublicId = GetPublicId;
1850 params.getResourceCount = GetResourceCount;
1851 params.getResourceType = GetResourceType;
1852 params.getTotalCompressedSize = GetTotalCompressedSize;
1853 params.getTotalUncompressedSize = GetTotalUncompressedSize;
1854 params.isExistingResource = IsExistingResource;
1855 params.isProtectedPatient = IsProtectedPatient;
1856 params.listAvailableMetadata = ListAvailableMetadata;
1857 params.listAvailableAttachments = ListAvailableAttachments;
1858 params.logChange = LogChange;
1859 params.logExportedResource = LogExportedResource;
1860 params.lookupAttachment = LookupAttachment;
1861 params.lookupGlobalProperty = LookupGlobalProperty;
1862 params.lookupIdentifier = NULL;
1863 params.lookupIdentifier2 = NULL;
1864 params.lookupMetadata = LookupMetadata;
1865 params.lookupParent = LookupParent;
1866 params.lookupResource = LookupResource;
1867 params.selectPatientToRecycle = SelectPatientToRecycle;
1868 params.selectPatientToRecycle2 = SelectPatientToRecycle2;
1869 params.setGlobalProperty = SetGlobalProperty;
1870 params.setMainDicomTag = SetMainDicomTag;
1871 params.setIdentifierTag = SetIdentifierTag;
1872 params.setMetadata = SetMetadata;
1873 params.setProtectedPatient = SetProtectedPatient;
1874 params.startTransaction = StartTransaction;
1875 params.rollbackTransaction = RollbackTransaction;
1876 params.commitTransaction = CommitTransaction;
1878 params.close = Close;
1880 extensions.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit;
1881 extensions.getDatabaseVersion = GetDatabaseVersion;
1882 extensions.upgradeDatabase = UpgradeDatabase;
1883 extensions.clearMainDicomTags = ClearMainDicomTags;
1884 extensions.getAllInternalIds = GetAllInternalIds;
1885 extensions.lookupIdentifier3 = LookupIdentifier3;
1890 throw std::runtime_error(
"Unable to register the database backend");