OrthancCDatabasePlugin.h
#pragma once
#include "OrthancCPlugin.h"
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct _OrthancPluginDatabaseContext_t OrthancPluginDatabaseContext;
/*<! @cond Doxygen_Suppress */
typedef enum
{
_OrthancPluginDatabaseAnswerType_None = 0,
/* Events */
_OrthancPluginDatabaseAnswerType_DeletedAttachment = 1,
_OrthancPluginDatabaseAnswerType_DeletedResource = 2,
_OrthancPluginDatabaseAnswerType_RemainingAncestor = 3,
/* Return value */
_OrthancPluginDatabaseAnswerType_Attachment = 10,
_OrthancPluginDatabaseAnswerType_Change = 11,
_OrthancPluginDatabaseAnswerType_DicomTag = 12,
_OrthancPluginDatabaseAnswerType_ExportedResource = 13,
_OrthancPluginDatabaseAnswerType_Int32 = 14,
_OrthancPluginDatabaseAnswerType_Int64 = 15,
_OrthancPluginDatabaseAnswerType_Resource = 16,
_OrthancPluginDatabaseAnswerType_String = 17,
_OrthancPluginDatabaseAnswerType_INTERNAL = 0x7fffffff
} _OrthancPluginDatabaseAnswerType;
typedef struct
{
const char* uuid;
int32_t contentType;
uint64_t uncompressedSize;
const char* uncompressedHash;
int32_t compressionType;
uint64_t compressedSize;
const char* compressedHash;
} OrthancPluginAttachment;
typedef struct
{
uint16_t group;
uint16_t element;
const char* value;
} OrthancPluginDicomTag;
typedef struct
{
int64_t seq;
int32_t changeType;
OrthancPluginResourceType resourceType;
const char* publicId;
const char* date;
} OrthancPluginChange;
typedef struct
{
int64_t seq;
OrthancPluginResourceType resourceType;
const char* publicId;
const char* modality;
const char* date;
const char* patientId;
const char* studyInstanceUid;
const char* seriesInstanceUid;
const char* sopInstanceUid;
} OrthancPluginExportedResource;
typedef struct
{
OrthancPluginDatabaseContext* database;
_OrthancPluginDatabaseAnswerType type;
int32_t valueInt32;
uint32_t valueUint32;
int64_t valueInt64;
const char *valueString;
const void *valueGeneric;
} _OrthancPluginDatabaseAnswer;
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerString(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
const char* value)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_String;
params.valueString = value;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerChange(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
const OrthancPluginChange* change)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_Change;
params.valueUint32 = 0;
params.valueGeneric = change;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerChangesDone(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_Change;
params.valueUint32 = 1;
params.valueGeneric = NULL;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerInt32(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
int32_t value)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_Int32;
params.valueInt32 = value;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerInt64(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
int64_t value)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_Int64;
params.valueInt64 = value;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerExportedResource(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
const OrthancPluginExportedResource* exported)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_ExportedResource;
params.valueUint32 = 0;
params.valueGeneric = exported;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerExportedResourcesDone(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_ExportedResource;
params.valueUint32 = 1;
params.valueGeneric = NULL;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerDicomTag(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
const OrthancPluginDicomTag* tag)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_DicomTag;
params.valueGeneric = tag;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerAttachment(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
const OrthancPluginAttachment* attachment)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_Attachment;
params.valueGeneric = attachment;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerResource(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
int64_t id,
OrthancPluginResourceType resourceType)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_Resource;
params.valueInt64 = id;
params.valueInt32 = (int32_t) resourceType;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseSignalDeletedAttachment(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
const OrthancPluginAttachment* attachment)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_DeletedAttachment;
params.valueGeneric = attachment;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseSignalDeletedResource(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
const char* publicId,
OrthancPluginResourceType resourceType)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_DeletedResource;
params.valueString = publicId;
params.valueInt32 = (int32_t) resourceType;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseSignalRemainingAncestor(
OrthancPluginContext* context,
OrthancPluginDatabaseContext* database,
const char* ancestorId,
OrthancPluginResourceType ancestorType)
{
_OrthancPluginDatabaseAnswer params;
memset(&params, 0, sizeof(params));
params.database = database;
params.type = _OrthancPluginDatabaseAnswerType_RemainingAncestor;
params.valueString = ancestorId;
params.valueInt32 = (int32_t) ancestorType;
context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
}
typedef struct
{
OrthancPluginErrorCode (*addAttachment) (
/* inputs */
void* payload,
int64_t id,
const OrthancPluginAttachment* attachment);
OrthancPluginErrorCode (*attachChild) (
/* inputs */
void* payload,
int64_t parent,
int64_t child);
OrthancPluginErrorCode (*clearChanges) (
/* inputs */
void* payload);
OrthancPluginErrorCode (*clearExportedResources) (
/* inputs */
void* payload);
OrthancPluginErrorCode (*createResource) (
/* outputs */
int64_t* id,
/* inputs */
void* payload,
const char* publicId,
OrthancPluginResourceType resourceType);
OrthancPluginErrorCode (*deleteAttachment) (
/* inputs */
void* payload,
int64_t id,
int32_t contentType);
OrthancPluginErrorCode (*deleteMetadata) (
/* inputs */
void* payload,
int64_t id,
int32_t metadataType);
OrthancPluginErrorCode (*deleteResource) (
/* inputs */
void* payload,
int64_t id);
/* Output: Use OrthancPluginDatabaseAnswerString() */
OrthancPluginErrorCode (*getAllPublicIds) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
OrthancPluginResourceType resourceType);
/* Output: Use OrthancPluginDatabaseAnswerChange() and
* OrthancPluginDatabaseAnswerChangesDone() */
OrthancPluginErrorCode (*getChanges) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t since,
uint32_t maxResult);
/* Output: Use OrthancPluginDatabaseAnswerInt64() */
OrthancPluginErrorCode (*getChildrenInternalId) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t id);
/* Output: Use OrthancPluginDatabaseAnswerString() */
OrthancPluginErrorCode (*getChildrenPublicId) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t id);
/* Output: Use OrthancPluginDatabaseAnswerExportedResource() and
* OrthancPluginDatabaseAnswerExportedResourcesDone() */
OrthancPluginErrorCode (*getExportedResources) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t since,
uint32_t maxResult);
/* Output: Use OrthancPluginDatabaseAnswerChange() */
OrthancPluginErrorCode (*getLastChange) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload);
/* Output: Use OrthancPluginDatabaseAnswerExportedResource() */
OrthancPluginErrorCode (*getLastExportedResource) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload);
/* Output: Use OrthancPluginDatabaseAnswerDicomTag() */
OrthancPluginErrorCode (*getMainDicomTags) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t id);
/* Output: Use OrthancPluginDatabaseAnswerString() */
OrthancPluginErrorCode (*getPublicId) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t id);
OrthancPluginErrorCode (*getResourceCount) (
/* outputs */
uint64_t* target,
/* inputs */
void* payload,
OrthancPluginResourceType resourceType);
OrthancPluginErrorCode (*getResourceType) (
/* outputs */
OrthancPluginResourceType* resourceType,
/* inputs */
void* payload,
int64_t id);
OrthancPluginErrorCode (*getTotalCompressedSize) (
/* outputs */
uint64_t* target,
/* inputs */
void* payload);
OrthancPluginErrorCode (*getTotalUncompressedSize) (
/* outputs */
uint64_t* target,
/* inputs */
void* payload);
OrthancPluginErrorCode (*isExistingResource) (
/* outputs */
int32_t* existing,
/* inputs */
void* payload,
int64_t id);
OrthancPluginErrorCode (*isProtectedPatient) (
/* outputs */
int32_t* isProtected,
/* inputs */
void* payload,
int64_t id);
/* Output: Use OrthancPluginDatabaseAnswerInt32() */
OrthancPluginErrorCode (*listAvailableMetadata) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t id);
/* Output: Use OrthancPluginDatabaseAnswerInt32() */
OrthancPluginErrorCode (*listAvailableAttachments) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t id);
OrthancPluginErrorCode (*logChange) (
/* inputs */
void* payload,
const OrthancPluginChange* change);
OrthancPluginErrorCode (*logExportedResource) (
/* inputs */
void* payload,
const OrthancPluginExportedResource* exported);
/* Output: Use OrthancPluginDatabaseAnswerAttachment() */
OrthancPluginErrorCode (*lookupAttachment) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t id,
int32_t contentType);
/* Output: Use OrthancPluginDatabaseAnswerString() */
OrthancPluginErrorCode (*lookupGlobalProperty) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int32_t property);
/* Use "OrthancPluginDatabaseExtensions::lookupIdentifier3"
instead of this function as of Orthanc 0.9.5 (db v6), can be set to NULL.
Output: Use OrthancPluginDatabaseAnswerInt64() */
OrthancPluginErrorCode (*lookupIdentifier) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
const OrthancPluginDicomTag* tag);
/* Unused starting with Orthanc 0.9.5 (db v6), can be set to NULL.
Output: Use OrthancPluginDatabaseAnswerInt64() */
OrthancPluginErrorCode (*lookupIdentifier2) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
const char* value);
/* Output: Use OrthancPluginDatabaseAnswerString() */
OrthancPluginErrorCode (*lookupMetadata) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t id,
int32_t metadata);
/* Output: Use OrthancPluginDatabaseAnswerInt64() */
OrthancPluginErrorCode (*lookupParent) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t id);
/* Output: Use OrthancPluginDatabaseAnswerResource() */
OrthancPluginErrorCode (*lookupResource) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
const char* publicId);
/* Output: Use OrthancPluginDatabaseAnswerInt64() */
OrthancPluginErrorCode (*selectPatientToRecycle) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload);
/* Output: Use OrthancPluginDatabaseAnswerInt64() */
OrthancPluginErrorCode (*selectPatientToRecycle2) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
int64_t patientIdToAvoid);
OrthancPluginErrorCode (*setGlobalProperty) (
/* inputs */
void* payload,
int32_t property,
const char* value);
OrthancPluginErrorCode (*setMainDicomTag) (
/* inputs */
void* payload,
int64_t id,
const OrthancPluginDicomTag* tag);
OrthancPluginErrorCode (*setIdentifierTag) (
/* inputs */
void* payload,
int64_t id,
const OrthancPluginDicomTag* tag);
OrthancPluginErrorCode (*setMetadata) (
/* inputs */
void* payload,
int64_t id,
int32_t metadata,
const char* value);
OrthancPluginErrorCode (*setProtectedPatient) (
/* inputs */
void* payload,
int64_t id,
int32_t isProtected);
OrthancPluginErrorCode (*startTransaction) (
/* inputs */
void* payload);
OrthancPluginErrorCode (*rollbackTransaction) (
/* inputs */
void* payload);
OrthancPluginErrorCode (*commitTransaction) (
/* inputs */
void* payload);
OrthancPluginErrorCode (*open) (
/* inputs */
void* payload);
OrthancPluginErrorCode (*close) (
/* inputs */
void* payload);
} OrthancPluginDatabaseBackend;
typedef struct
{
/* Output: Use OrthancPluginDatabaseAnswerString() */
OrthancPluginErrorCode (*getAllPublicIdsWithLimit) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
OrthancPluginResourceType resourceType,
uint64_t since,
uint64_t limit);
OrthancPluginErrorCode (*getDatabaseVersion) (
/* outputs */
uint32_t* version,
/* inputs */
void* payload);
OrthancPluginErrorCode (*upgradeDatabase) (
/* inputs */
void* payload,
uint32_t targetVersion,
OrthancPluginStorageArea* storageArea);
OrthancPluginErrorCode (*clearMainDicomTags) (
/* inputs */
void* payload,
int64_t id);
/* Output: Use OrthancPluginDatabaseAnswerInt64() */
OrthancPluginErrorCode (*getAllInternalIds) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
OrthancPluginResourceType resourceType);
/* Output: Use OrthancPluginDatabaseAnswerInt64() */
OrthancPluginErrorCode (*lookupIdentifier3) (
/* outputs */
OrthancPluginDatabaseContext* context,
/* inputs */
void* payload,
OrthancPluginResourceType resourceType,
const OrthancPluginDicomTag* tag,
OrthancPluginIdentifierConstraint constraint);
} OrthancPluginDatabaseExtensions;
/*<! @endcond */
typedef struct
{
OrthancPluginDatabaseContext** result;
const OrthancPluginDatabaseBackend* backend;
void* payload;
} _OrthancPluginRegisterDatabaseBackend;
ORTHANC_PLUGIN_INLINE OrthancPluginDatabaseContext* OrthancPluginRegisterDatabaseBackend(
OrthancPluginContext* context,
const OrthancPluginDatabaseBackend* backend,
void* payload)
{
OrthancPluginDatabaseContext* result = NULL;
_OrthancPluginRegisterDatabaseBackend params;
if (sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType))
{
return NULL;
}
memset(&params, 0, sizeof(params));
params.backend = backend;
params.result = &result;
params.payload = payload;
if (context->InvokeService(context, _OrthancPluginService_RegisterDatabaseBackend, &params) ||
result == NULL)
{
/* Error */
return NULL;
}
else
{
return result;
}
}
typedef struct
{
OrthancPluginDatabaseContext** result;
const OrthancPluginDatabaseBackend* backend;
void* payload;
const OrthancPluginDatabaseExtensions* extensions;
uint32_t extensionsSize;
} _OrthancPluginRegisterDatabaseBackendV2;
ORTHANC_PLUGIN_INLINE OrthancPluginDatabaseContext* OrthancPluginRegisterDatabaseBackendV2(
OrthancPluginContext* context,
const OrthancPluginDatabaseBackend* backend,
const OrthancPluginDatabaseExtensions* extensions,
void* payload)
{
OrthancPluginDatabaseContext* result = NULL;
_OrthancPluginRegisterDatabaseBackendV2 params;
if (sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType))
{
return NULL;
}
memset(&params, 0, sizeof(params));
params.backend = backend;
params.result = &result;
params.payload = payload;
params.extensions = extensions;
params.extensionsSize = sizeof(OrthancPluginDatabaseExtensions);
if (context->InvokeService(context, _OrthancPluginService_RegisterDatabaseBackendV2, &params) ||
result == NULL)
{
/* Error */
return NULL;
}
else
{
return result;
}
}
#ifdef __cplusplus
}
#endif
OrthancPluginErrorCode
OrthancPluginErrorCode
Definition: OrthancCPlugin.h:188
OrthancPluginContext
struct _OrthancPluginContext_t OrthancPluginContext
Data structure that contains information about the Orthanc core.
OrthancPluginStorageArea
struct _OrthancPluginStorageArea_t OrthancPluginStorageArea
Opaque structure that represents the storage area that is actually used by Orthanc.
Definition: OrthancCPlugin.h:829
OrthancPluginResourceType
OrthancPluginResourceType
Definition: OrthancCPlugin.h:595
OrthancPluginRegisterDatabaseBackend
OrthancPluginDatabaseContext * OrthancPluginRegisterDatabaseBackend(OrthancPluginContext *context, const OrthancPluginDatabaseBackend *backend, void *payload)
Definition: OrthancCDatabasePlugin.h:713
OrthancPluginDatabaseContext
struct _OrthancPluginDatabaseContext_t OrthancPluginDatabaseContext
Definition: OrthancCDatabasePlugin.h:56
OrthancPluginRegisterDatabaseBackendV2
OrthancPluginDatabaseContext * OrthancPluginRegisterDatabaseBackendV2(OrthancPluginContext *context, const OrthancPluginDatabaseBackend *backend, const OrthancPluginDatabaseExtensions *extensions, void *payload)
Definition: OrthancCDatabasePlugin.h:769
OrthancPluginIdentifierConstraint
OrthancPluginIdentifierConstraint
Definition: OrthancCPlugin.h:753