405
|
1 /**
|
|
2 * @ingroup CInterface
|
|
3 **/
|
|
4
|
|
5 /**
|
|
6 * Orthanc - A Lightweight, RESTful DICOM Store
|
|
7 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
|
|
8 * Department, University Hospital of Liege, Belgium
|
|
9 * Copyright (C) 2017-2023 Osimis S.A., Belgium
|
|
10 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
|
|
11 *
|
|
12 * This program is free software: you can redistribute it and/or
|
|
13 * modify it under the terms of the GNU General Public License as
|
|
14 * published by the Free Software Foundation, either version 3 of the
|
|
15 * License, or (at your option) any later version.
|
|
16 *
|
|
17 * This program is distributed in the hope that it will be useful, but
|
|
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
20 * General Public License for more details.
|
|
21 *
|
|
22 * You should have received a copy of the GNU General Public License
|
|
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
24 **/
|
|
25
|
|
26
|
|
27
|
|
28 #pragma once
|
|
29
|
|
30 #include "OrthancCPlugin.h"
|
|
31
|
|
32
|
|
33 /** @{ */
|
|
34
|
|
35 #ifdef __cplusplus
|
|
36 extern "C"
|
|
37 {
|
|
38 #endif
|
|
39
|
|
40
|
|
41 /**
|
|
42 * Opaque structure that represents the context of a custom database engine.
|
|
43 * @ingroup Callbacks
|
|
44 **/
|
|
45 typedef struct _OrthancPluginDatabaseContext_t OrthancPluginDatabaseContext;
|
|
46
|
|
47
|
|
48 /**
|
|
49 * Opaque structure that represents a transaction of a custom database engine.
|
|
50 * New in Orthanc 1.9.2.
|
|
51 * @ingroup Callbacks
|
|
52 **/
|
|
53 typedef struct _OrthancPluginDatabaseTransaction_t OrthancPluginDatabaseTransaction;
|
|
54
|
|
55
|
|
56 /*<! @cond Doxygen_Suppress */
|
|
57 typedef enum
|
|
58 {
|
|
59 _OrthancPluginDatabaseAnswerType_None = 0,
|
|
60
|
|
61 /* Events */
|
|
62 _OrthancPluginDatabaseAnswerType_DeletedAttachment = 1,
|
|
63 _OrthancPluginDatabaseAnswerType_DeletedResource = 2,
|
|
64 _OrthancPluginDatabaseAnswerType_RemainingAncestor = 3,
|
|
65
|
|
66 /* Return value */
|
|
67 _OrthancPluginDatabaseAnswerType_Attachment = 10,
|
|
68 _OrthancPluginDatabaseAnswerType_Change = 11,
|
|
69 _OrthancPluginDatabaseAnswerType_DicomTag = 12,
|
|
70 _OrthancPluginDatabaseAnswerType_ExportedResource = 13,
|
|
71 _OrthancPluginDatabaseAnswerType_Int32 = 14,
|
|
72 _OrthancPluginDatabaseAnswerType_Int64 = 15,
|
|
73 _OrthancPluginDatabaseAnswerType_Resource = 16,
|
|
74 _OrthancPluginDatabaseAnswerType_String = 17,
|
|
75 _OrthancPluginDatabaseAnswerType_MatchingResource = 18, /* New in Orthanc 1.5.2 */
|
|
76 _OrthancPluginDatabaseAnswerType_Metadata = 19, /* New in Orthanc 1.5.4 */
|
|
77
|
|
78 _OrthancPluginDatabaseAnswerType_INTERNAL = 0x7fffffff
|
|
79 } _OrthancPluginDatabaseAnswerType;
|
|
80
|
|
81
|
|
82 typedef struct
|
|
83 {
|
|
84 const char* uuid;
|
|
85 int32_t contentType;
|
|
86 uint64_t uncompressedSize;
|
|
87 const char* uncompressedHash;
|
|
88 int32_t compressionType;
|
|
89 uint64_t compressedSize;
|
|
90 const char* compressedHash;
|
|
91 } OrthancPluginAttachment;
|
|
92
|
|
93 typedef struct
|
|
94 {
|
|
95 uint16_t group;
|
|
96 uint16_t element;
|
|
97 const char* value;
|
|
98 } OrthancPluginDicomTag;
|
|
99
|
|
100 typedef struct
|
|
101 {
|
|
102 int64_t seq;
|
|
103 int32_t changeType;
|
|
104 OrthancPluginResourceType resourceType;
|
|
105 const char* publicId;
|
|
106 const char* date;
|
|
107 } OrthancPluginChange;
|
|
108
|
|
109 typedef struct
|
|
110 {
|
|
111 int64_t seq;
|
|
112 OrthancPluginResourceType resourceType;
|
|
113 const char* publicId;
|
|
114 const char* modality;
|
|
115 const char* date;
|
|
116 const char* patientId;
|
|
117 const char* studyInstanceUid;
|
|
118 const char* seriesInstanceUid;
|
|
119 const char* sopInstanceUid;
|
|
120 } OrthancPluginExportedResource;
|
|
121
|
|
122 typedef struct /* New in Orthanc 1.5.2 */
|
|
123 {
|
|
124 OrthancPluginResourceType level;
|
|
125 uint16_t tagGroup;
|
|
126 uint16_t tagElement;
|
|
127 uint8_t isIdentifierTag;
|
|
128 uint8_t isCaseSensitive;
|
|
129 uint8_t isMandatory;
|
|
130 OrthancPluginConstraintType type;
|
|
131 uint32_t valuesCount;
|
|
132 const char* const* values;
|
|
133 } OrthancPluginDatabaseConstraint;
|
|
134
|
|
135 typedef struct /* New in Orthanc 1.5.2 */
|
|
136 {
|
|
137 const char* resourceId;
|
|
138 const char* someInstanceId; /* Can be NULL if not requested */
|
|
139 } OrthancPluginMatchingResource;
|
|
140
|
|
141 typedef struct /* New in Orthanc 1.5.2 */
|
|
142 {
|
|
143 /* Mandatory field */
|
|
144 uint8_t isNewInstance;
|
|
145 int64_t instanceId;
|
|
146
|
|
147 /* The following fields must only be set if "isNewInstance" is "true" */
|
|
148 uint8_t isNewPatient;
|
|
149 uint8_t isNewStudy;
|
|
150 uint8_t isNewSeries;
|
|
151 int64_t patientId;
|
|
152 int64_t studyId;
|
|
153 int64_t seriesId;
|
|
154 } OrthancPluginCreateInstanceResult;
|
|
155
|
|
156 typedef struct /* New in Orthanc 1.5.2 */
|
|
157 {
|
|
158 int64_t resource;
|
|
159 uint16_t group;
|
|
160 uint16_t element;
|
|
161 const char* value;
|
|
162 } OrthancPluginResourcesContentTags;
|
|
163
|
|
164 typedef struct /* New in Orthanc 1.5.2 */
|
|
165 {
|
|
166 int64_t resource;
|
|
167 int32_t metadata;
|
|
168 const char* value;
|
|
169 } OrthancPluginResourcesContentMetadata;
|
|
170
|
|
171
|
|
172 typedef struct
|
|
173 {
|
|
174 OrthancPluginDatabaseContext* database;
|
|
175 _OrthancPluginDatabaseAnswerType type;
|
|
176 int32_t valueInt32;
|
|
177 uint32_t valueUint32;
|
|
178 int64_t valueInt64;
|
|
179 const char *valueString;
|
|
180 const void *valueGeneric;
|
|
181 } _OrthancPluginDatabaseAnswer;
|
|
182
|
|
183 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerString(
|
|
184 OrthancPluginContext* context,
|
|
185 OrthancPluginDatabaseContext* database,
|
|
186 const char* value)
|
|
187 {
|
|
188 _OrthancPluginDatabaseAnswer params;
|
|
189 memset(¶ms, 0, sizeof(params));
|
|
190 params.database = database;
|
|
191 params.type = _OrthancPluginDatabaseAnswerType_String;
|
|
192 params.valueString = value;
|
|
193 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
194 }
|
|
195
|
|
196 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerChange(
|
|
197 OrthancPluginContext* context,
|
|
198 OrthancPluginDatabaseContext* database,
|
|
199 const OrthancPluginChange* change)
|
|
200 {
|
|
201 _OrthancPluginDatabaseAnswer params;
|
|
202 memset(¶ms, 0, sizeof(params));
|
|
203
|
|
204 params.database = database;
|
|
205 params.type = _OrthancPluginDatabaseAnswerType_Change;
|
|
206 params.valueUint32 = 0;
|
|
207 params.valueGeneric = change;
|
|
208
|
|
209 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
210 }
|
|
211
|
|
212 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerChangesDone(
|
|
213 OrthancPluginContext* context,
|
|
214 OrthancPluginDatabaseContext* database)
|
|
215 {
|
|
216 _OrthancPluginDatabaseAnswer params;
|
|
217 memset(¶ms, 0, sizeof(params));
|
|
218
|
|
219 params.database = database;
|
|
220 params.type = _OrthancPluginDatabaseAnswerType_Change;
|
|
221 params.valueUint32 = 1;
|
|
222 params.valueGeneric = NULL;
|
|
223
|
|
224 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
225 }
|
|
226
|
|
227 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerInt32(
|
|
228 OrthancPluginContext* context,
|
|
229 OrthancPluginDatabaseContext* database,
|
|
230 int32_t value)
|
|
231 {
|
|
232 _OrthancPluginDatabaseAnswer params;
|
|
233 memset(¶ms, 0, sizeof(params));
|
|
234 params.database = database;
|
|
235 params.type = _OrthancPluginDatabaseAnswerType_Int32;
|
|
236 params.valueInt32 = value;
|
|
237 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
238 }
|
|
239
|
|
240 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerInt64(
|
|
241 OrthancPluginContext* context,
|
|
242 OrthancPluginDatabaseContext* database,
|
|
243 int64_t value)
|
|
244 {
|
|
245 _OrthancPluginDatabaseAnswer params;
|
|
246 memset(¶ms, 0, sizeof(params));
|
|
247 params.database = database;
|
|
248 params.type = _OrthancPluginDatabaseAnswerType_Int64;
|
|
249 params.valueInt64 = value;
|
|
250 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
251 }
|
|
252
|
|
253 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerExportedResource(
|
|
254 OrthancPluginContext* context,
|
|
255 OrthancPluginDatabaseContext* database,
|
|
256 const OrthancPluginExportedResource* exported)
|
|
257 {
|
|
258 _OrthancPluginDatabaseAnswer params;
|
|
259 memset(¶ms, 0, sizeof(params));
|
|
260
|
|
261 params.database = database;
|
|
262 params.type = _OrthancPluginDatabaseAnswerType_ExportedResource;
|
|
263 params.valueUint32 = 0;
|
|
264 params.valueGeneric = exported;
|
|
265 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
266 }
|
|
267
|
|
268 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerExportedResourcesDone(
|
|
269 OrthancPluginContext* context,
|
|
270 OrthancPluginDatabaseContext* database)
|
|
271 {
|
|
272 _OrthancPluginDatabaseAnswer params;
|
|
273 memset(¶ms, 0, sizeof(params));
|
|
274
|
|
275 params.database = database;
|
|
276 params.type = _OrthancPluginDatabaseAnswerType_ExportedResource;
|
|
277 params.valueUint32 = 1;
|
|
278 params.valueGeneric = NULL;
|
|
279 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
280 }
|
|
281
|
|
282 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerDicomTag(
|
|
283 OrthancPluginContext* context,
|
|
284 OrthancPluginDatabaseContext* database,
|
|
285 const OrthancPluginDicomTag* tag)
|
|
286 {
|
|
287 _OrthancPluginDatabaseAnswer params;
|
|
288 memset(¶ms, 0, sizeof(params));
|
|
289 params.database = database;
|
|
290 params.type = _OrthancPluginDatabaseAnswerType_DicomTag;
|
|
291 params.valueGeneric = tag;
|
|
292 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
293 }
|
|
294
|
|
295 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerAttachment(
|
|
296 OrthancPluginContext* context,
|
|
297 OrthancPluginDatabaseContext* database,
|
|
298 const OrthancPluginAttachment* attachment)
|
|
299 {
|
|
300 _OrthancPluginDatabaseAnswer params;
|
|
301 memset(¶ms, 0, sizeof(params));
|
|
302 params.database = database;
|
|
303 params.type = _OrthancPluginDatabaseAnswerType_Attachment;
|
|
304 params.valueGeneric = attachment;
|
|
305 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
306 }
|
|
307
|
|
308 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerResource(
|
|
309 OrthancPluginContext* context,
|
|
310 OrthancPluginDatabaseContext* database,
|
|
311 int64_t id,
|
|
312 OrthancPluginResourceType resourceType)
|
|
313 {
|
|
314 _OrthancPluginDatabaseAnswer params;
|
|
315 memset(¶ms, 0, sizeof(params));
|
|
316 params.database = database;
|
|
317 params.type = _OrthancPluginDatabaseAnswerType_Resource;
|
|
318 params.valueInt64 = id;
|
|
319 params.valueInt32 = (int32_t) resourceType;
|
|
320 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
321 }
|
|
322
|
|
323 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerMatchingResource(
|
|
324 OrthancPluginContext* context,
|
|
325 OrthancPluginDatabaseContext* database,
|
|
326 const OrthancPluginMatchingResource* match)
|
|
327 {
|
|
328 _OrthancPluginDatabaseAnswer params;
|
|
329 memset(¶ms, 0, sizeof(params));
|
|
330 params.database = database;
|
|
331 params.type = _OrthancPluginDatabaseAnswerType_MatchingResource;
|
|
332 params.valueGeneric = match;
|
|
333 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
334 }
|
|
335
|
|
336 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerMetadata(
|
|
337 OrthancPluginContext* context,
|
|
338 OrthancPluginDatabaseContext* database,
|
|
339 int64_t resourceId,
|
|
340 int32_t type,
|
|
341 const char* value)
|
|
342 {
|
|
343 OrthancPluginResourcesContentMetadata metadata;
|
|
344 _OrthancPluginDatabaseAnswer params;
|
|
345 metadata.resource = resourceId;
|
|
346 metadata.metadata = type;
|
|
347 metadata.value = value;
|
|
348 memset(¶ms, 0, sizeof(params));
|
|
349 params.database = database;
|
|
350 params.type = _OrthancPluginDatabaseAnswerType_Metadata;
|
|
351 params.valueGeneric = &metadata;
|
|
352 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
353 }
|
|
354
|
|
355 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseSignalDeletedAttachment(
|
|
356 OrthancPluginContext* context,
|
|
357 OrthancPluginDatabaseContext* database,
|
|
358 const OrthancPluginAttachment* attachment)
|
|
359 {
|
|
360 _OrthancPluginDatabaseAnswer params;
|
|
361 memset(¶ms, 0, sizeof(params));
|
|
362 params.database = database;
|
|
363 params.type = _OrthancPluginDatabaseAnswerType_DeletedAttachment;
|
|
364 params.valueGeneric = attachment;
|
|
365 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
366 }
|
|
367
|
|
368 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseSignalDeletedResource(
|
|
369 OrthancPluginContext* context,
|
|
370 OrthancPluginDatabaseContext* database,
|
|
371 const char* publicId,
|
|
372 OrthancPluginResourceType resourceType)
|
|
373 {
|
|
374 _OrthancPluginDatabaseAnswer params;
|
|
375 memset(¶ms, 0, sizeof(params));
|
|
376 params.database = database;
|
|
377 params.type = _OrthancPluginDatabaseAnswerType_DeletedResource;
|
|
378 params.valueString = publicId;
|
|
379 params.valueInt32 = (int32_t) resourceType;
|
|
380 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
381 }
|
|
382
|
|
383 ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseSignalRemainingAncestor(
|
|
384 OrthancPluginContext* context,
|
|
385 OrthancPluginDatabaseContext* database,
|
|
386 const char* ancestorId,
|
|
387 OrthancPluginResourceType ancestorType)
|
|
388 {
|
|
389 _OrthancPluginDatabaseAnswer params;
|
|
390 memset(¶ms, 0, sizeof(params));
|
|
391 params.database = database;
|
|
392 params.type = _OrthancPluginDatabaseAnswerType_RemainingAncestor;
|
|
393 params.valueString = ancestorId;
|
|
394 params.valueInt32 = (int32_t) ancestorType;
|
|
395 context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, ¶ms);
|
|
396 }
|
|
397
|
|
398
|
|
399
|
|
400
|
|
401
|
|
402 typedef struct
|
|
403 {
|
|
404 OrthancPluginErrorCode (*addAttachment) (
|
|
405 /* inputs */
|
|
406 void* payload,
|
|
407 int64_t id,
|
|
408 const OrthancPluginAttachment* attachment);
|
|
409
|
|
410 OrthancPluginErrorCode (*attachChild) (
|
|
411 /* inputs */
|
|
412 void* payload,
|
|
413 int64_t parent,
|
|
414 int64_t child);
|
|
415
|
|
416 OrthancPluginErrorCode (*clearChanges) (
|
|
417 /* inputs */
|
|
418 void* payload);
|
|
419
|
|
420 OrthancPluginErrorCode (*clearExportedResources) (
|
|
421 /* inputs */
|
|
422 void* payload);
|
|
423
|
|
424 OrthancPluginErrorCode (*createResource) (
|
|
425 /* outputs */
|
|
426 int64_t* id,
|
|
427 /* inputs */
|
|
428 void* payload,
|
|
429 const char* publicId,
|
|
430 OrthancPluginResourceType resourceType);
|
|
431
|
|
432 OrthancPluginErrorCode (*deleteAttachment) (
|
|
433 /* inputs */
|
|
434 void* payload,
|
|
435 int64_t id,
|
|
436 int32_t contentType);
|
|
437
|
|
438 OrthancPluginErrorCode (*deleteMetadata) (
|
|
439 /* inputs */
|
|
440 void* payload,
|
|
441 int64_t id,
|
|
442 int32_t metadataType);
|
|
443
|
|
444 OrthancPluginErrorCode (*deleteResource) (
|
|
445 /* inputs */
|
|
446 void* payload,
|
|
447 int64_t id);
|
|
448
|
|
449 /* Output: Use OrthancPluginDatabaseAnswerString() */
|
|
450 OrthancPluginErrorCode (*getAllPublicIds) (
|
|
451 /* outputs */
|
|
452 OrthancPluginDatabaseContext* context,
|
|
453 /* inputs */
|
|
454 void* payload,
|
|
455 OrthancPluginResourceType resourceType);
|
|
456
|
|
457 /* Output: Use OrthancPluginDatabaseAnswerChange() and
|
|
458 * OrthancPluginDatabaseAnswerChangesDone() */
|
|
459 OrthancPluginErrorCode (*getChanges) (
|
|
460 /* outputs */
|
|
461 OrthancPluginDatabaseContext* context,
|
|
462 /* inputs */
|
|
463 void* payload,
|
|
464 int64_t since,
|
|
465 uint32_t maxResult);
|
|
466
|
|
467 /* Output: Use OrthancPluginDatabaseAnswerInt64() */
|
|
468 OrthancPluginErrorCode (*getChildrenInternalId) (
|
|
469 /* outputs */
|
|
470 OrthancPluginDatabaseContext* context,
|
|
471 /* inputs */
|
|
472 void* payload,
|
|
473 int64_t id);
|
|
474
|
|
475 /* Output: Use OrthancPluginDatabaseAnswerString() */
|
|
476 OrthancPluginErrorCode (*getChildrenPublicId) (
|
|
477 /* outputs */
|
|
478 OrthancPluginDatabaseContext* context,
|
|
479 /* inputs */
|
|
480 void* payload,
|
|
481 int64_t id);
|
|
482
|
|
483 /* Output: Use OrthancPluginDatabaseAnswerExportedResource() and
|
|
484 * OrthancPluginDatabaseAnswerExportedResourcesDone() */
|
|
485 OrthancPluginErrorCode (*getExportedResources) (
|
|
486 /* outputs */
|
|
487 OrthancPluginDatabaseContext* context,
|
|
488 /* inputs */
|
|
489 void* payload,
|
|
490 int64_t since,
|
|
491 uint32_t maxResult);
|
|
492
|
|
493 /* Output: Use OrthancPluginDatabaseAnswerChange() */
|
|
494 OrthancPluginErrorCode (*getLastChange) (
|
|
495 /* outputs */
|
|
496 OrthancPluginDatabaseContext* context,
|
|
497 /* inputs */
|
|
498 void* payload);
|
|
499
|
|
500 /* Output: Use OrthancPluginDatabaseAnswerExportedResource() */
|
|
501 OrthancPluginErrorCode (*getLastExportedResource) (
|
|
502 /* outputs */
|
|
503 OrthancPluginDatabaseContext* context,
|
|
504 /* inputs */
|
|
505 void* payload);
|
|
506
|
|
507 /* Output: Use OrthancPluginDatabaseAnswerDicomTag() */
|
|
508 OrthancPluginErrorCode (*getMainDicomTags) (
|
|
509 /* outputs */
|
|
510 OrthancPluginDatabaseContext* context,
|
|
511 /* inputs */
|
|
512 void* payload,
|
|
513 int64_t id);
|
|
514
|
|
515 /* Output: Use OrthancPluginDatabaseAnswerString() */
|
|
516 OrthancPluginErrorCode (*getPublicId) (
|
|
517 /* outputs */
|
|
518 OrthancPluginDatabaseContext* context,
|
|
519 /* inputs */
|
|
520 void* payload,
|
|
521 int64_t id);
|
|
522
|
|
523 OrthancPluginErrorCode (*getResourceCount) (
|
|
524 /* outputs */
|
|
525 uint64_t* target,
|
|
526 /* inputs */
|
|
527 void* payload,
|
|
528 OrthancPluginResourceType resourceType);
|
|
529
|
|
530 OrthancPluginErrorCode (*getResourceType) (
|
|
531 /* outputs */
|
|
532 OrthancPluginResourceType* resourceType,
|
|
533 /* inputs */
|
|
534 void* payload,
|
|
535 int64_t id);
|
|
536
|
|
537 OrthancPluginErrorCode (*getTotalCompressedSize) (
|
|
538 /* outputs */
|
|
539 uint64_t* target,
|
|
540 /* inputs */
|
|
541 void* payload);
|
|
542
|
|
543 OrthancPluginErrorCode (*getTotalUncompressedSize) (
|
|
544 /* outputs */
|
|
545 uint64_t* target,
|
|
546 /* inputs */
|
|
547 void* payload);
|
|
548
|
|
549 OrthancPluginErrorCode (*isExistingResource) (
|
|
550 /* outputs */
|
|
551 int32_t* existing,
|
|
552 /* inputs */
|
|
553 void* payload,
|
|
554 int64_t id);
|
|
555
|
|
556 OrthancPluginErrorCode (*isProtectedPatient) (
|
|
557 /* outputs */
|
|
558 int32_t* isProtected,
|
|
559 /* inputs */
|
|
560 void* payload,
|
|
561 int64_t id);
|
|
562
|
|
563 /* Output: Use OrthancPluginDatabaseAnswerInt32() */
|
|
564 OrthancPluginErrorCode (*listAvailableMetadata) (
|
|
565 /* outputs */
|
|
566 OrthancPluginDatabaseContext* context,
|
|
567 /* inputs */
|
|
568 void* payload,
|
|
569 int64_t id);
|
|
570
|
|
571 /* Output: Use OrthancPluginDatabaseAnswerInt32() */
|
|
572 OrthancPluginErrorCode (*listAvailableAttachments) (
|
|
573 /* outputs */
|
|
574 OrthancPluginDatabaseContext* context,
|
|
575 /* inputs */
|
|
576 void* payload,
|
|
577 int64_t id);
|
|
578
|
|
579 OrthancPluginErrorCode (*logChange) (
|
|
580 /* inputs */
|
|
581 void* payload,
|
|
582 const OrthancPluginChange* change);
|
|
583
|
|
584 OrthancPluginErrorCode (*logExportedResource) (
|
|
585 /* inputs */
|
|
586 void* payload,
|
|
587 const OrthancPluginExportedResource* exported);
|
|
588
|
|
589 /* Output: Use OrthancPluginDatabaseAnswerAttachment() */
|
|
590 OrthancPluginErrorCode (*lookupAttachment) (
|
|
591 /* outputs */
|
|
592 OrthancPluginDatabaseContext* context,
|
|
593 /* inputs */
|
|
594 void* payload,
|
|
595 int64_t id,
|
|
596 int32_t contentType);
|
|
597
|
|
598 /* Output: Use OrthancPluginDatabaseAnswerString() */
|
|
599 OrthancPluginErrorCode (*lookupGlobalProperty) (
|
|
600 /* outputs */
|
|
601 OrthancPluginDatabaseContext* context,
|
|
602 /* inputs */
|
|
603 void* payload,
|
|
604 int32_t property);
|
|
605
|
|
606 /* Use "OrthancPluginDatabaseExtensions::lookupIdentifier3"
|
|
607 instead of this function as of Orthanc 0.9.5 (db v6), can be set to NULL.
|
|
608 Output: Use OrthancPluginDatabaseAnswerInt64() */
|
|
609 OrthancPluginErrorCode (*lookupIdentifier) (
|
|
610 /* outputs */
|
|
611 OrthancPluginDatabaseContext* context,
|
|
612 /* inputs */
|
|
613 void* payload,
|
|
614 const OrthancPluginDicomTag* tag);
|
|
615
|
|
616 /* Unused starting with Orthanc 0.9.5 (db v6), can be set to NULL.
|
|
617 Output: Use OrthancPluginDatabaseAnswerInt64() */
|
|
618 OrthancPluginErrorCode (*lookupIdentifier2) (
|
|
619 /* outputs */
|
|
620 OrthancPluginDatabaseContext* context,
|
|
621 /* inputs */
|
|
622 void* payload,
|
|
623 const char* value);
|
|
624
|
|
625 /* Output: Use OrthancPluginDatabaseAnswerString() */
|
|
626 OrthancPluginErrorCode (*lookupMetadata) (
|
|
627 /* outputs */
|
|
628 OrthancPluginDatabaseContext* context,
|
|
629 /* inputs */
|
|
630 void* payload,
|
|
631 int64_t id,
|
|
632 int32_t metadata);
|
|
633
|
|
634 /* Output: Use OrthancPluginDatabaseAnswerInt64() */
|
|
635 OrthancPluginErrorCode (*lookupParent) (
|
|
636 /* outputs */
|
|
637 OrthancPluginDatabaseContext* context,
|
|
638 /* inputs */
|
|
639 void* payload,
|
|
640 int64_t id);
|
|
641
|
|
642 /* Output: Use OrthancPluginDatabaseAnswerResource() */
|
|
643 OrthancPluginErrorCode (*lookupResource) (
|
|
644 /* outputs */
|
|
645 OrthancPluginDatabaseContext* context,
|
|
646 /* inputs */
|
|
647 void* payload,
|
|
648 const char* publicId);
|
|
649
|
|
650 /* Output: Use OrthancPluginDatabaseAnswerInt64() */
|
|
651 OrthancPluginErrorCode (*selectPatientToRecycle) (
|
|
652 /* outputs */
|
|
653 OrthancPluginDatabaseContext* context,
|
|
654 /* inputs */
|
|
655 void* payload);
|
|
656
|
|
657 /* Output: Use OrthancPluginDatabaseAnswerInt64() */
|
|
658 OrthancPluginErrorCode (*selectPatientToRecycle2) (
|
|
659 /* outputs */
|
|
660 OrthancPluginDatabaseContext* context,
|
|
661 /* inputs */
|
|
662 void* payload,
|
|
663 int64_t patientIdToAvoid);
|
|
664
|
|
665 OrthancPluginErrorCode (*setGlobalProperty) (
|
|
666 /* inputs */
|
|
667 void* payload,
|
|
668 int32_t property,
|
|
669 const char* value);
|
|
670
|
|
671 OrthancPluginErrorCode (*setMainDicomTag) (
|
|
672 /* inputs */
|
|
673 void* payload,
|
|
674 int64_t id,
|
|
675 const OrthancPluginDicomTag* tag);
|
|
676
|
|
677 OrthancPluginErrorCode (*setIdentifierTag) (
|
|
678 /* inputs */
|
|
679 void* payload,
|
|
680 int64_t id,
|
|
681 const OrthancPluginDicomTag* tag);
|
|
682
|
|
683 OrthancPluginErrorCode (*setMetadata) (
|
|
684 /* inputs */
|
|
685 void* payload,
|
|
686 int64_t id,
|
|
687 int32_t metadata,
|
|
688 const char* value);
|
|
689
|
|
690 OrthancPluginErrorCode (*setProtectedPatient) (
|
|
691 /* inputs */
|
|
692 void* payload,
|
|
693 int64_t id,
|
|
694 int32_t isProtected);
|
|
695
|
|
696 OrthancPluginErrorCode (*startTransaction) (
|
|
697 /* inputs */
|
|
698 void* payload);
|
|
699
|
|
700 OrthancPluginErrorCode (*rollbackTransaction) (
|
|
701 /* inputs */
|
|
702 void* payload);
|
|
703
|
|
704 OrthancPluginErrorCode (*commitTransaction) (
|
|
705 /* inputs */
|
|
706 void* payload);
|
|
707
|
|
708 OrthancPluginErrorCode (*open) (
|
|
709 /* inputs */
|
|
710 void* payload);
|
|
711
|
|
712 OrthancPluginErrorCode (*close) (
|
|
713 /* inputs */
|
|
714 void* payload);
|
|
715
|
|
716 } OrthancPluginDatabaseBackend;
|
|
717
|
|
718
|
|
719 typedef struct
|
|
720 {
|
|
721 /**
|
|
722 * Base extensions since Orthanc 1.0.0
|
|
723 **/
|
|
724
|
|
725 /* Output: Use OrthancPluginDatabaseAnswerString() */
|
|
726 OrthancPluginErrorCode (*getAllPublicIdsWithLimit) (
|
|
727 /* outputs */
|
|
728 OrthancPluginDatabaseContext* context,
|
|
729 /* inputs */
|
|
730 void* payload,
|
|
731 OrthancPluginResourceType resourceType,
|
|
732 uint64_t since,
|
|
733 uint64_t limit);
|
|
734
|
|
735 OrthancPluginErrorCode (*getDatabaseVersion) (
|
|
736 /* outputs */
|
|
737 uint32_t* version,
|
|
738 /* inputs */
|
|
739 void* payload);
|
|
740
|
|
741 OrthancPluginErrorCode (*upgradeDatabase) (
|
|
742 /* inputs */
|
|
743 void* payload,
|
|
744 uint32_t targetVersion,
|
|
745 OrthancPluginStorageArea* storageArea);
|
|
746
|
|
747 OrthancPluginErrorCode (*clearMainDicomTags) (
|
|
748 /* inputs */
|
|
749 void* payload,
|
|
750 int64_t id);
|
|
751
|
|
752 /* Output: Use OrthancPluginDatabaseAnswerInt64() */
|
|
753 OrthancPluginErrorCode (*getAllInternalIds) (
|
|
754 /* outputs */
|
|
755 OrthancPluginDatabaseContext* context,
|
|
756 /* inputs */
|
|
757 void* payload,
|
|
758 OrthancPluginResourceType resourceType);
|
|
759
|
|
760 /* Output: Use OrthancPluginDatabaseAnswerInt64() */
|
|
761 OrthancPluginErrorCode (*lookupIdentifier3) (
|
|
762 /* outputs */
|
|
763 OrthancPluginDatabaseContext* context,
|
|
764 /* inputs */
|
|
765 void* payload,
|
|
766 OrthancPluginResourceType resourceType,
|
|
767 const OrthancPluginDicomTag* tag,
|
|
768 OrthancPluginIdentifierConstraint constraint);
|
|
769
|
|
770
|
|
771 /**
|
|
772 * Extensions since Orthanc 1.4.0
|
|
773 **/
|
|
774
|
|
775 /* Output: Use OrthancPluginDatabaseAnswerInt64() */
|
|
776 OrthancPluginErrorCode (*lookupIdentifierRange) (
|
|
777 /* outputs */
|
|
778 OrthancPluginDatabaseContext* context,
|
|
779 /* inputs */
|
|
780 void* payload,
|
|
781 OrthancPluginResourceType resourceType,
|
|
782 uint16_t group,
|
|
783 uint16_t element,
|
|
784 const char* start,
|
|
785 const char* end);
|
|
786
|
|
787
|
|
788 /**
|
|
789 * Extensions since Orthanc 1.5.2
|
|
790 **/
|
|
791
|
|
792 /* Ouput: Use OrthancPluginDatabaseAnswerMatchingResource */
|
|
793 OrthancPluginErrorCode (*lookupResources) (
|
|
794 /* outputs */
|
|
795 OrthancPluginDatabaseContext* context,
|
|
796 /* inputs */
|
|
797 void* payload,
|
|
798 uint32_t constraintsCount,
|
|
799 const OrthancPluginDatabaseConstraint* constraints,
|
|
800 OrthancPluginResourceType queryLevel,
|
|
801 uint32_t limit,
|
|
802 uint8_t requestSomeInstance);
|
|
803
|
|
804 OrthancPluginErrorCode (*createInstance) (
|
|
805 /* output */
|
|
806 OrthancPluginCreateInstanceResult* output,
|
|
807 /* inputs */
|
|
808 void* payload,
|
|
809 const char* hashPatient,
|
|
810 const char* hashStudy,
|
|
811 const char* hashSeries,
|
|
812 const char* hashInstance);
|
|
813
|
|
814 OrthancPluginErrorCode (*setResourcesContent) (
|
|
815 /* inputs */
|
|
816 void* payload,
|
|
817 uint32_t countIdentifierTags,
|
|
818 const OrthancPluginResourcesContentTags* identifierTags,
|
|
819 uint32_t countMainDicomTags,
|
|
820 const OrthancPluginResourcesContentTags* mainDicomTags,
|
|
821 uint32_t countMetadata,
|
|
822 const OrthancPluginResourcesContentMetadata* metadata);
|
|
823
|
|
824 /* Ouput: Use OrthancPluginDatabaseAnswerString */
|
|
825 OrthancPluginErrorCode (*getChildrenMetadata) (
|
|
826 /* outputs */
|
|
827 OrthancPluginDatabaseContext* context,
|
|
828 /* inputs */
|
|
829 void* payload,
|
|
830 int64_t resourceId,
|
|
831 int32_t metadata);
|
|
832
|
|
833 OrthancPluginErrorCode (*getLastChangeIndex) (
|
|
834 /* outputs */
|
|
835 int64_t* target,
|
|
836 /* inputs */
|
|
837 void* payload);
|
|
838
|
|
839 OrthancPluginErrorCode (*tagMostRecentPatient) (
|
|
840 /* inputs */
|
|
841 void* payload,
|
|
842 int64_t patientId);
|
|
843
|
|
844
|
|
845 /**
|
|
846 * Extensions since Orthanc 1.5.4
|
|
847 **/
|
|
848
|
|
849 /* Ouput: Use OrthancPluginDatabaseAnswerMetadata */
|
|
850 OrthancPluginErrorCode (*getAllMetadata) (
|
|
851 /* outputs */
|
|
852 OrthancPluginDatabaseContext* context,
|
|
853 /* inputs */
|
|
854 void* payload,
|
|
855 int64_t resourceId);
|
|
856
|
|
857 /* Ouput: Use OrthancPluginDatabaseAnswerString to send
|
|
858 the public ID of the parent (if the resource is not a patient) */
|
|
859 OrthancPluginErrorCode (*lookupResourceAndParent) (
|
|
860 /* outputs */
|
|
861 OrthancPluginDatabaseContext* context,
|
|
862 uint8_t* isExisting,
|
|
863 int64_t* id,
|
|
864 OrthancPluginResourceType* type,
|
|
865
|
|
866 /* inputs */
|
|
867 void* payload,
|
|
868 const char* publicId);
|
|
869
|
|
870 } OrthancPluginDatabaseExtensions;
|
|
871
|
|
872 /*<! @endcond */
|
|
873
|
|
874
|
|
875 typedef struct
|
|
876 {
|
|
877 OrthancPluginDatabaseContext** result;
|
|
878 const OrthancPluginDatabaseBackend* backend;
|
|
879 void* payload;
|
|
880 } _OrthancPluginRegisterDatabaseBackend;
|
|
881
|
|
882 /**
|
|
883 * Register a custom database back-end (for legacy plugins).
|
|
884 *
|
|
885 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
886 * @param backend The callbacks of the custom database engine.
|
|
887 * @param payload Pointer containing private information for the database engine.
|
|
888 * @return The context of the database engine (it must not be manually freed).
|
|
889 * @ingroup Callbacks
|
|
890 * @deprecated
|
|
891 * @see OrthancPluginRegisterDatabaseBackendV2
|
|
892 **/
|
|
893 ORTHANC_PLUGIN_INLINE OrthancPluginDatabaseContext* OrthancPluginRegisterDatabaseBackend(
|
|
894 OrthancPluginContext* context,
|
|
895 const OrthancPluginDatabaseBackend* backend,
|
|
896 void* payload)
|
|
897 {
|
|
898 OrthancPluginDatabaseContext* result = NULL;
|
|
899 _OrthancPluginRegisterDatabaseBackend params;
|
|
900
|
|
901 if (sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType))
|
|
902 {
|
|
903 return NULL;
|
|
904 }
|
|
905
|
|
906 memset(¶ms, 0, sizeof(params));
|
|
907 params.backend = backend;
|
|
908 params.result = &result;
|
|
909 params.payload = payload;
|
|
910
|
|
911 if (context->InvokeService(context, _OrthancPluginService_RegisterDatabaseBackend, ¶ms) ||
|
|
912 result == NULL)
|
|
913 {
|
|
914 /* Error */
|
|
915 return NULL;
|
|
916 }
|
|
917 else
|
|
918 {
|
|
919 return result;
|
|
920 }
|
|
921 }
|
|
922
|
|
923
|
|
924 typedef struct
|
|
925 {
|
|
926 OrthancPluginDatabaseContext** result;
|
|
927 const OrthancPluginDatabaseBackend* backend;
|
|
928 void* payload;
|
|
929 const OrthancPluginDatabaseExtensions* extensions;
|
|
930 uint32_t extensionsSize;
|
|
931 } _OrthancPluginRegisterDatabaseBackendV2;
|
|
932
|
|
933
|
|
934 /**
|
|
935 * Register a custom database back-end.
|
|
936 *
|
|
937 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
|
|
938 * @param backend The callbacks of the custom database engine.
|
|
939 * @param payload Pointer containing private information for the database engine.
|
|
940 * @param extensions Extensions to the base database SDK that was shipped until Orthanc 0.9.3.
|
|
941 * @return The context of the database engine (it must not be manually freed).
|
|
942 * @ingroup Callbacks
|
|
943 **/
|
|
944 ORTHANC_PLUGIN_INLINE OrthancPluginDatabaseContext* OrthancPluginRegisterDatabaseBackendV2(
|
|
945 OrthancPluginContext* context,
|
|
946 const OrthancPluginDatabaseBackend* backend,
|
|
947 const OrthancPluginDatabaseExtensions* extensions,
|
|
948 void* payload)
|
|
949 {
|
|
950 OrthancPluginDatabaseContext* result = NULL;
|
|
951 _OrthancPluginRegisterDatabaseBackendV2 params;
|
|
952
|
|
953 if (sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType))
|
|
954 {
|
|
955 return NULL;
|
|
956 }
|
|
957
|
|
958 memset(¶ms, 0, sizeof(params));
|
|
959 params.backend = backend;
|
|
960 params.result = &result;
|
|
961 params.payload = payload;
|
|
962 params.extensions = extensions;
|
|
963 params.extensionsSize = sizeof(OrthancPluginDatabaseExtensions);
|
|
964
|
|
965 if (context->InvokeService(context, _OrthancPluginService_RegisterDatabaseBackendV2, ¶ms) ||
|
|
966 result == NULL)
|
|
967 {
|
|
968 /* Error */
|
|
969 return NULL;
|
|
970 }
|
|
971 else
|
|
972 {
|
|
973 return result;
|
|
974 }
|
|
975 }
|
|
976
|
|
977
|
|
978
|
|
979 /**
|
|
980 * New interface starting with Orthanc 1.9.2
|
|
981 **/
|
|
982
|
|
983 /*<! @cond Doxygen_Suppress */
|
|
984 typedef enum
|
|
985 {
|
|
986 OrthancPluginDatabaseTransactionType_ReadOnly = 1,
|
|
987 OrthancPluginDatabaseTransactionType_ReadWrite = 2,
|
|
988 OrthancPluginDatabaseTransactionType_INTERNAL = 0x7fffffff
|
|
989 } OrthancPluginDatabaseTransactionType;
|
|
990
|
|
991
|
|
992 typedef enum
|
|
993 {
|
|
994 OrthancPluginDatabaseEventType_DeletedAttachment = 1,
|
|
995 OrthancPluginDatabaseEventType_DeletedResource = 2,
|
|
996 OrthancPluginDatabaseEventType_RemainingAncestor = 3,
|
|
997 OrthancPluginDatabaseEventType_INTERNAL = 0x7fffffff
|
|
998 } OrthancPluginDatabaseEventType;
|
|
999
|
|
1000
|
|
1001 typedef struct
|
|
1002 {
|
|
1003 OrthancPluginDatabaseEventType type;
|
|
1004
|
|
1005 union
|
|
1006 {
|
|
1007 struct
|
|
1008 {
|
|
1009 /* For ""DeletedResource" and "RemainingAncestor" */
|
|
1010 OrthancPluginResourceType level;
|
|
1011 const char* publicId;
|
|
1012 } resource;
|
|
1013
|
|
1014 /* For "DeletedAttachment" */
|
|
1015 OrthancPluginAttachment attachment;
|
|
1016
|
|
1017 } content;
|
|
1018
|
|
1019 } OrthancPluginDatabaseEvent;
|
|
1020
|
|
1021
|
|
1022 typedef struct
|
|
1023 {
|
|
1024 /**
|
|
1025 * Functions to read the answers inside a transaction
|
|
1026 **/
|
|
1027
|
|
1028 OrthancPluginErrorCode (*readAnswersCount) (OrthancPluginDatabaseTransaction* transaction,
|
|
1029 uint32_t* target /* out */);
|
|
1030
|
|
1031 OrthancPluginErrorCode (*readAnswerAttachment) (OrthancPluginDatabaseTransaction* transaction,
|
|
1032 OrthancPluginAttachment* target /* out */,
|
|
1033 uint32_t index);
|
|
1034
|
|
1035 OrthancPluginErrorCode (*readAnswerChange) (OrthancPluginDatabaseTransaction* transaction,
|
|
1036 OrthancPluginChange* target /* out */,
|
|
1037 uint32_t index);
|
|
1038
|
|
1039 OrthancPluginErrorCode (*readAnswerDicomTag) (OrthancPluginDatabaseTransaction* transaction,
|
|
1040 uint16_t* group,
|
|
1041 uint16_t* element,
|
|
1042 const char** value,
|
|
1043 uint32_t index);
|
|
1044
|
|
1045 OrthancPluginErrorCode (*readAnswerExportedResource) (OrthancPluginDatabaseTransaction* transaction,
|
|
1046 OrthancPluginExportedResource* target /* out */,
|
|
1047 uint32_t index);
|
|
1048
|
|
1049 OrthancPluginErrorCode (*readAnswerInt32) (OrthancPluginDatabaseTransaction* transaction,
|
|
1050 int32_t* target /* out */,
|
|
1051 uint32_t index);
|
|
1052
|
|
1053 OrthancPluginErrorCode (*readAnswerInt64) (OrthancPluginDatabaseTransaction* transaction,
|
|
1054 int64_t* target /* out */,
|
|
1055 uint32_t index);
|
|
1056
|
|
1057 OrthancPluginErrorCode (*readAnswerMatchingResource) (OrthancPluginDatabaseTransaction* transaction,
|
|
1058 OrthancPluginMatchingResource* target /* out */,
|
|
1059 uint32_t index);
|
|
1060
|
|
1061 OrthancPluginErrorCode (*readAnswerMetadata) (OrthancPluginDatabaseTransaction* transaction,
|
|
1062 int32_t* metadata /* out */,
|
|
1063 const char** value /* out */,
|
|
1064 uint32_t index);
|
|
1065
|
|
1066 OrthancPluginErrorCode (*readAnswerString) (OrthancPluginDatabaseTransaction* transaction,
|
|
1067 const char** target /* out */,
|
|
1068 uint32_t index);
|
|
1069
|
|
1070 OrthancPluginErrorCode (*readEventsCount) (OrthancPluginDatabaseTransaction* transaction,
|
|
1071 uint32_t* target /* out */);
|
|
1072
|
|
1073 OrthancPluginErrorCode (*readEvent) (OrthancPluginDatabaseTransaction* transaction,
|
|
1074 OrthancPluginDatabaseEvent* event /* out */,
|
|
1075 uint32_t index);
|
|
1076
|
|
1077
|
|
1078
|
|
1079 /**
|
|
1080 * Functions to access the global database object
|
|
1081 * (cf. "IDatabaseWrapper" class in Orthanc)
|
|
1082 **/
|
|
1083
|
|
1084 OrthancPluginErrorCode (*open) (void* database);
|
|
1085
|
|
1086 OrthancPluginErrorCode (*close) (void* database);
|
|
1087
|
|
1088 OrthancPluginErrorCode (*destructDatabase) (void* database);
|
|
1089
|
|
1090 OrthancPluginErrorCode (*getDatabaseVersion) (void* database,
|
|
1091 uint32_t* target /* out */);
|
|
1092
|
|
1093 OrthancPluginErrorCode (*hasRevisionsSupport) (void* database,
|
|
1094 uint8_t* target /* out */);
|
|
1095
|
|
1096 OrthancPluginErrorCode (*upgradeDatabase) (void* database,
|
|
1097 OrthancPluginStorageArea* storageArea,
|
|
1098 uint32_t targetVersion);
|
|
1099
|
|
1100 OrthancPluginErrorCode (*startTransaction) (void* database,
|
|
1101 OrthancPluginDatabaseTransaction** target /* out */,
|
|
1102 OrthancPluginDatabaseTransactionType type);
|
|
1103
|
|
1104 OrthancPluginErrorCode (*destructTransaction) (OrthancPluginDatabaseTransaction* transaction);
|
|
1105
|
|
1106
|
|
1107 /**
|
|
1108 * Functions to run operations within a database transaction
|
|
1109 * (cf. "IDatabaseWrapper::ITransaction" class in Orthanc)
|
|
1110 **/
|
|
1111
|
|
1112 OrthancPluginErrorCode (*rollback) (OrthancPluginDatabaseTransaction* transaction);
|
|
1113
|
|
1114 OrthancPluginErrorCode (*commit) (OrthancPluginDatabaseTransaction* transaction,
|
|
1115 int64_t fileSizeDelta);
|
|
1116
|
|
1117 /* A call to "addAttachment()" guarantees that this attachment is not already existing ("INSERT") */
|
|
1118 OrthancPluginErrorCode (*addAttachment) (OrthancPluginDatabaseTransaction* transaction,
|
|
1119 int64_t id,
|
|
1120 const OrthancPluginAttachment* attachment,
|
|
1121 int64_t revision);
|
|
1122
|
|
1123 OrthancPluginErrorCode (*clearChanges) (OrthancPluginDatabaseTransaction* transaction);
|
|
1124
|
|
1125 OrthancPluginErrorCode (*clearExportedResources) (OrthancPluginDatabaseTransaction* transaction);
|
|
1126
|
|
1127 OrthancPluginErrorCode (*clearMainDicomTags) (OrthancPluginDatabaseTransaction* transaction,
|
|
1128 int64_t resourceId);
|
|
1129
|
|
1130 OrthancPluginErrorCode (*createInstance) (OrthancPluginDatabaseTransaction* transaction,
|
|
1131 OrthancPluginCreateInstanceResult* target /* out */,
|
|
1132 const char* hashPatient,
|
|
1133 const char* hashStudy,
|
|
1134 const char* hashSeries,
|
|
1135 const char* hashInstance);
|
|
1136
|
|
1137 OrthancPluginErrorCode (*deleteAttachment) (OrthancPluginDatabaseTransaction* transaction,
|
|
1138 int64_t id,
|
|
1139 int32_t contentType);
|
|
1140
|
|
1141 OrthancPluginErrorCode (*deleteMetadata) (OrthancPluginDatabaseTransaction* transaction,
|
|
1142 int64_t id,
|
|
1143 int32_t metadataType);
|
|
1144
|
|
1145 OrthancPluginErrorCode (*deleteResource) (OrthancPluginDatabaseTransaction* transaction,
|
|
1146 int64_t id);
|
|
1147
|
|
1148 /* Answers are read using "readAnswerMetadata()" */
|
|
1149 OrthancPluginErrorCode (*getAllMetadata) (OrthancPluginDatabaseTransaction* transaction,
|
|
1150 int64_t id);
|
|
1151
|
|
1152 /* Answers are read using "readAnswerString()" */
|
|
1153 OrthancPluginErrorCode (*getAllPublicIds) (OrthancPluginDatabaseTransaction* transaction,
|
|
1154 OrthancPluginResourceType resourceType);
|
|
1155
|
|
1156 /* Answers are read using "readAnswerString()" */
|
|
1157 OrthancPluginErrorCode (*getAllPublicIdsWithLimit) (OrthancPluginDatabaseTransaction* transaction,
|
|
1158 OrthancPluginResourceType resourceType,
|
|
1159 uint64_t since,
|
|
1160 uint64_t limit);
|
|
1161
|
|
1162 /* Answers are read using "readAnswerChange()" */
|
|
1163 OrthancPluginErrorCode (*getChanges) (OrthancPluginDatabaseTransaction* transaction,
|
|
1164 uint8_t* targetDone /* out */,
|
|
1165 int64_t since,
|
|
1166 uint32_t maxResults);
|
|
1167
|
|
1168 /* Answers are read using "readAnswerInt64()" */
|
|
1169 OrthancPluginErrorCode (*getChildrenInternalId) (OrthancPluginDatabaseTransaction* transaction,
|
|
1170 int64_t id);
|
|
1171
|
|
1172 /* Answers are read using "readAnswerString()" */
|
|
1173 OrthancPluginErrorCode (*getChildrenMetadata) (OrthancPluginDatabaseTransaction* transaction,
|
|
1174 int64_t resourceId,
|
|
1175 int32_t metadata);
|
|
1176
|
|
1177 /* Answers are read using "readAnswerString()" */
|
|
1178 OrthancPluginErrorCode (*getChildrenPublicId) (OrthancPluginDatabaseTransaction* transaction,
|
|
1179 int64_t id);
|
|
1180
|
|
1181 /* Answers are read using "readAnswerExportedResource()" */
|
|
1182 OrthancPluginErrorCode (*getExportedResources) (OrthancPluginDatabaseTransaction* transaction,
|
|
1183 uint8_t* targetDone /* out */,
|
|
1184 int64_t since,
|
|
1185 uint32_t maxResults);
|
|
1186
|
|
1187 /* Answer is read using "readAnswerChange()" */
|
|
1188 OrthancPluginErrorCode (*getLastChange) (OrthancPluginDatabaseTransaction* transaction);
|
|
1189
|
|
1190 OrthancPluginErrorCode (*getLastChangeIndex) (OrthancPluginDatabaseTransaction* transaction,
|
|
1191 int64_t* target /* out */);
|
|
1192
|
|
1193 /* Answer is read using "readAnswerExportedResource()" */
|
|
1194 OrthancPluginErrorCode (*getLastExportedResource) (OrthancPluginDatabaseTransaction* transaction);
|
|
1195
|
|
1196 /* Answers are read using "readAnswerDicomTag()" */
|
|
1197 OrthancPluginErrorCode (*getMainDicomTags) (OrthancPluginDatabaseTransaction* transaction,
|
|
1198 int64_t id);
|
|
1199
|
|
1200 /* Answer is read using "readAnswerString()" */
|
|
1201 OrthancPluginErrorCode (*getPublicId) (OrthancPluginDatabaseTransaction* transaction,
|
|
1202 int64_t internalId);
|
|
1203
|
|
1204 OrthancPluginErrorCode (*getResourcesCount) (OrthancPluginDatabaseTransaction* transaction,
|
|
1205 uint64_t* target /* out */,
|
|
1206 OrthancPluginResourceType resourceType);
|
|
1207
|
|
1208 OrthancPluginErrorCode (*getResourceType) (OrthancPluginDatabaseTransaction* transaction,
|
|
1209 OrthancPluginResourceType* target /* out */,
|
|
1210 uint64_t resourceId);
|
|
1211
|
|
1212 OrthancPluginErrorCode (*getTotalCompressedSize) (OrthancPluginDatabaseTransaction* transaction,
|
|
1213 uint64_t* target /* out */);
|
|
1214
|
|
1215 OrthancPluginErrorCode (*getTotalUncompressedSize) (OrthancPluginDatabaseTransaction* transaction,
|
|
1216 uint64_t* target /* out */);
|
|
1217
|
|
1218 OrthancPluginErrorCode (*isDiskSizeAbove) (OrthancPluginDatabaseTransaction* transaction,
|
|
1219 uint8_t* target /* out */,
|
|
1220 uint64_t threshold);
|
|
1221
|
|
1222 OrthancPluginErrorCode (*isExistingResource) (OrthancPluginDatabaseTransaction* transaction,
|
|
1223 uint8_t* target /* out */,
|
|
1224 int64_t resourceId);
|
|
1225
|
|
1226 OrthancPluginErrorCode (*isProtectedPatient) (OrthancPluginDatabaseTransaction* transaction,
|
|
1227 uint8_t* target /* out */,
|
|
1228 int64_t resourceId);
|
|
1229
|
|
1230 /* Answers are read using "readAnswerInt32()" */
|
|
1231 OrthancPluginErrorCode (*listAvailableAttachments) (OrthancPluginDatabaseTransaction* transaction,
|
|
1232 int64_t internalId);
|
|
1233
|
|
1234 OrthancPluginErrorCode (*logChange) (OrthancPluginDatabaseTransaction* transaction,
|
|
1235 int32_t changeType,
|
|
1236 int64_t resourceId,
|
|
1237 OrthancPluginResourceType resourceType,
|
|
1238 const char* date);
|
|
1239
|
|
1240 OrthancPluginErrorCode (*logExportedResource) (OrthancPluginDatabaseTransaction* transaction,
|
|
1241 OrthancPluginResourceType resourceType,
|
|
1242 const char* publicId,
|
|
1243 const char* modality,
|
|
1244 const char* date,
|
|
1245 const char* patientId,
|
|
1246 const char* studyInstanceUid,
|
|
1247 const char* seriesInstanceUid,
|
|
1248 const char* sopInstanceUid);
|
|
1249
|
|
1250 /* Answer is read using "readAnswerAttachment()" */
|
|
1251 OrthancPluginErrorCode (*lookupAttachment) (OrthancPluginDatabaseTransaction* transaction,
|
|
1252 int64_t* revision /* out */,
|
|
1253 int64_t resourceId,
|
|
1254 int32_t contentType);
|
|
1255
|
|
1256 /* Answer is read using "readAnswerString()" */
|
|
1257 OrthancPluginErrorCode (*lookupGlobalProperty) (OrthancPluginDatabaseTransaction* transaction,
|
|
1258 const char* serverIdentifier,
|
|
1259 int32_t property);
|
|
1260
|
|
1261 /* Answer is read using "readAnswerString()" */
|
|
1262 OrthancPluginErrorCode (*lookupMetadata) (OrthancPluginDatabaseTransaction* transaction,
|
|
1263 int64_t* revision /* out */,
|
|
1264 int64_t id,
|
|
1265 int32_t metadata);
|
|
1266
|
|
1267 OrthancPluginErrorCode (*lookupParent) (OrthancPluginDatabaseTransaction* transaction,
|
|
1268 uint8_t* isExisting /* out */,
|
|
1269 int64_t* parentId /* out */,
|
|
1270 int64_t id);
|
|
1271
|
|
1272 OrthancPluginErrorCode (*lookupResource) (OrthancPluginDatabaseTransaction* transaction,
|
|
1273 uint8_t* isExisting /* out */,
|
|
1274 int64_t* id /* out */,
|
|
1275 OrthancPluginResourceType* type /* out */,
|
|
1276 const char* publicId);
|
|
1277
|
|
1278 /* Answers are read using "readAnswerMatchingResource()" */
|
|
1279 OrthancPluginErrorCode (*lookupResources) (OrthancPluginDatabaseTransaction* transaction,
|
|
1280 uint32_t constraintsCount,
|
|
1281 const OrthancPluginDatabaseConstraint* constraints,
|
|
1282 OrthancPluginResourceType queryLevel,
|
|
1283 uint32_t limit,
|
|
1284 uint8_t requestSomeInstanceId);
|
|
1285
|
|
1286 /* The public ID of the parent resource is read using "readAnswerString()" */
|
|
1287 OrthancPluginErrorCode (*lookupResourceAndParent) (OrthancPluginDatabaseTransaction* transaction,
|
|
1288 uint8_t* isExisting /* out */,
|
|
1289 int64_t* id /* out */,
|
|
1290 OrthancPluginResourceType* type /* out */,
|
|
1291 const char* publicId);
|
|
1292
|
|
1293 OrthancPluginErrorCode (*selectPatientToRecycle) (OrthancPluginDatabaseTransaction* transaction,
|
|
1294 uint8_t* patientAvailable /* out */,
|
|
1295 int64_t* patientId /* out */);
|
|
1296
|
|
1297 OrthancPluginErrorCode (*selectPatientToRecycle2) (OrthancPluginDatabaseTransaction* transaction,
|
|
1298 uint8_t* patientAvailable /* out */,
|
|
1299 int64_t* patientId /* out */,
|
|
1300 int64_t patientIdToAvoid);
|
|
1301
|
|
1302 OrthancPluginErrorCode (*setGlobalProperty) (OrthancPluginDatabaseTransaction* transaction,
|
|
1303 const char* serverIdentifier,
|
|
1304 int32_t property,
|
|
1305 const char* value);
|
|
1306
|
|
1307 /* In "setMetadata()", the metadata might already be existing ("INSERT OR REPLACE") */
|
|
1308 OrthancPluginErrorCode (*setMetadata) (OrthancPluginDatabaseTransaction* transaction,
|
|
1309 int64_t id,
|
|
1310 int32_t metadata,
|
|
1311 const char* value,
|
|
1312 int64_t revision);
|
|
1313
|
|
1314 OrthancPluginErrorCode (*setProtectedPatient) (OrthancPluginDatabaseTransaction* transaction,
|
|
1315 int64_t id,
|
|
1316 uint8_t isProtected);
|
|
1317
|
|
1318 OrthancPluginErrorCode (*setResourcesContent) (OrthancPluginDatabaseTransaction* transaction,
|
|
1319 uint32_t countIdentifierTags,
|
|
1320 const OrthancPluginResourcesContentTags* identifierTags,
|
|
1321 uint32_t countMainDicomTags,
|
|
1322 const OrthancPluginResourcesContentTags* mainDicomTags,
|
|
1323 uint32_t countMetadata,
|
|
1324 const OrthancPluginResourcesContentMetadata* metadata);
|
|
1325
|
|
1326
|
|
1327 } OrthancPluginDatabaseBackendV3;
|
|
1328
|
|
1329 /*<! @endcond */
|
|
1330
|
|
1331
|
|
1332 typedef struct
|
|
1333 {
|
|
1334 const OrthancPluginDatabaseBackendV3* backend;
|
|
1335 uint32_t backendSize;
|
|
1336 uint32_t maxDatabaseRetries;
|
|
1337 void* database;
|
|
1338 } _OrthancPluginRegisterDatabaseBackendV3;
|
|
1339
|
|
1340
|
|
1341 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDatabaseBackendV3(
|
|
1342 OrthancPluginContext* context,
|
|
1343 const OrthancPluginDatabaseBackendV3* backend,
|
|
1344 uint32_t backendSize,
|
|
1345 uint32_t maxDatabaseRetries, /* To handle "OrthancPluginErrorCode_DatabaseCannotSerialize" */
|
|
1346 void* database)
|
|
1347 {
|
|
1348 _OrthancPluginRegisterDatabaseBackendV3 params;
|
|
1349
|
|
1350 if (sizeof(int32_t) != sizeof(_OrthancPluginDatabaseAnswerType))
|
|
1351 {
|
|
1352 return OrthancPluginErrorCode_Plugin;
|
|
1353 }
|
|
1354
|
|
1355 memset(¶ms, 0, sizeof(params));
|
|
1356 params.backend = backend;
|
|
1357 params.backendSize = sizeof(OrthancPluginDatabaseBackendV3);
|
|
1358 params.maxDatabaseRetries = maxDatabaseRetries;
|
|
1359 params.database = database;
|
|
1360
|
|
1361 return context->InvokeService(context, _OrthancPluginService_RegisterDatabaseBackendV3, ¶ms);
|
|
1362 }
|
|
1363
|
|
1364 #ifdef __cplusplus
|
|
1365 }
|
|
1366 #endif
|
|
1367
|
|
1368
|
|
1369 /** @} */
|
|
1370
|