Mercurial > hg > orthanc-webviewer
comparison Orthanc/Sdk-0.9.4/orthanc/OrthancCPlugin.h @ 101:2932473a9b19 refactoring
fix prefetching
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 27 Nov 2015 22:05:51 +0100 |
parents | d6da56f86e5a |
children |
comparison
equal
deleted
inserted
replaced
100:f5b1a9267da0 | 101:2932473a9b19 |
---|---|
16 * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback(). | 16 * - Register all its REST callbacks using ::OrthancPluginRegisterRestCallback(). |
17 * - Possibly register its callback for received DICOM instances using ::OrthancPluginRegisterOnStoredInstanceCallback(). | 17 * - Possibly register its callback for received DICOM instances using ::OrthancPluginRegisterOnStoredInstanceCallback(). |
18 * - Possibly register its callback for changes to the DICOM store using ::OrthancPluginRegisterOnChangeCallback(). | 18 * - Possibly register its callback for changes to the DICOM store using ::OrthancPluginRegisterOnChangeCallback(). |
19 * - Possibly register a custom storage area using ::OrthancPluginRegisterStorageArea(). | 19 * - Possibly register a custom storage area using ::OrthancPluginRegisterStorageArea(). |
20 * - Possibly register a custom database back-end area using OrthancPluginRegisterDatabaseBackendV2(). | 20 * - Possibly register a custom database back-end area using OrthancPluginRegisterDatabaseBackendV2(). |
21 * - Possibly register a handler for C-Find SCP against DICOM worklists using OrthancPluginRegisterWorklistCallback(). | |
22 * - Possibly register a custom decoder for DICOM images using OrthancPluginRegisterDecodeImageCallback(). | |
21 * -# <tt>void OrthancPluginFinalize()</tt>: | 23 * -# <tt>void OrthancPluginFinalize()</tt>: |
22 * This function is invoked by Orthanc during its shutdown. The plugin | 24 * This function is invoked by Orthanc during its shutdown. The plugin |
23 * must free all its memory. | 25 * must free all its memory. |
24 * -# <tt>const char* OrthancPluginGetName()</tt>: | 26 * -# <tt>const char* OrthancPluginGetName()</tt>: |
25 * The plugin must return a short string to identify itself. | 27 * The plugin must return a short string to identify itself. |
46 * @defgroup REST REST | 48 * @defgroup REST REST |
47 * @brief Functions to answer REST requests in a callback. | 49 * @brief Functions to answer REST requests in a callback. |
48 * | 50 * |
49 * @defgroup Callbacks Callbacks | 51 * @defgroup Callbacks Callbacks |
50 * @brief Functions to register and manage callbacks by the plugins. | 52 * @brief Functions to register and manage callbacks by the plugins. |
53 * | |
54 * @defgroup Worklists Worklists | |
55 * @brief Functions to register and manage worklists. | |
51 * | 56 * |
52 * @defgroup Orthanc Orthanc | 57 * @defgroup Orthanc Orthanc |
53 * @brief Functions to access the content of the Orthanc server. | 58 * @brief Functions to access the content of the Orthanc server. |
54 **/ | 59 **/ |
55 | 60 |
107 #define ORTHANC_PLUGINS_API | 112 #define ORTHANC_PLUGINS_API |
108 #endif | 113 #endif |
109 | 114 |
110 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 0 | 115 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 0 |
111 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 9 | 116 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 9 |
112 #define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 4 | 117 #define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 5 |
113 | 118 |
114 | 119 |
115 | 120 |
116 /******************************************************************** | 121 /******************************************************************** |
117 ** Check that function inlining is properly supported. The use of | 122 ** Check that function inlining is properly supported. The use of |
208 OrthancPluginErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */, | 213 OrthancPluginErrorCode_UnknownPluginService = 26 /*!< Plugin invoking an unknown service */, |
209 OrthancPluginErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */, | 214 OrthancPluginErrorCode_UnknownDicomTag = 27 /*!< Unknown DICOM tag */, |
210 OrthancPluginErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */, | 215 OrthancPluginErrorCode_BadJson = 28 /*!< Cannot parse a JSON document */, |
211 OrthancPluginErrorCode_Unauthorized = 29 /*!< Bad credentials were provided to an HTTP request */, | 216 OrthancPluginErrorCode_Unauthorized = 29 /*!< Bad credentials were provided to an HTTP request */, |
212 OrthancPluginErrorCode_BadFont = 30 /*!< Badly formatted font file */, | 217 OrthancPluginErrorCode_BadFont = 30 /*!< Badly formatted font file */, |
218 OrthancPluginErrorCode_DatabasePlugin = 31 /*!< The plugin implementing a custom database back-end does not fulfill the proper interface */, | |
219 OrthancPluginErrorCode_StorageAreaPlugin = 32 /*!< Error in the plugin implementing a custom storage area */, | |
220 OrthancPluginErrorCode_EmptyRequest = 33 /*!< The request is empty */, | |
221 OrthancPluginErrorCode_NotAcceptable = 34 /*!< Cannot send a response which is acceptable according to the Accept HTTP header */, | |
213 OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, | 222 OrthancPluginErrorCode_SQLiteNotOpened = 1000 /*!< SQLite: The database is not opened */, |
214 OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, | 223 OrthancPluginErrorCode_SQLiteAlreadyOpened = 1001 /*!< SQLite: Connection is already open */, |
215 OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */, | 224 OrthancPluginErrorCode_SQLiteCannotOpen = 1002 /*!< SQLite: Unable to open the database */, |
216 OrthancPluginErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */, | 225 OrthancPluginErrorCode_SQLiteStatementAlreadyUsed = 1003 /*!< SQLite: This cached statement is already being referred to */, |
217 OrthancPluginErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */, | 226 OrthancPluginErrorCode_SQLiteExecute = 1004 /*!< SQLite: Cannot execute a command */, |
260 OrthancPluginErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */, | 269 OrthancPluginErrorCode_CannotExecuteLua = 2031 /*!< Cannot execute a Lua command */, |
261 OrthancPluginErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */, | 270 OrthancPluginErrorCode_LuaAlreadyExecuted = 2032 /*!< Arguments cannot be pushed after the Lua function is executed */, |
262 OrthancPluginErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */, | 271 OrthancPluginErrorCode_LuaBadOutput = 2033 /*!< The Lua function does not give the expected number of outputs */, |
263 OrthancPluginErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */, | 272 OrthancPluginErrorCode_NotLuaPredicate = 2034 /*!< The Lua function is not a predicate (only true/false outputs allowed) */, |
264 OrthancPluginErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */, | 273 OrthancPluginErrorCode_LuaReturnsNoString = 2035 /*!< The Lua function does not return a string */, |
274 OrthancPluginErrorCode_StorageAreaAlreadyRegistered = 2036 /*!< Another plugin has already registered a custom storage area */, | |
275 OrthancPluginErrorCode_DatabaseBackendAlreadyRegistered = 2037 /*!< Another plugin has already registered a custom database back-end */, | |
276 OrthancPluginErrorCode_DatabaseNotInitialized = 2038 /*!< Plugin trying to call the database during its initialization */, | |
277 OrthancPluginErrorCode_SslDisabled = 2039 /*!< Orthanc has been built without SSL support */, | |
278 OrthancPluginErrorCode_CannotOrderSlices = 2040 /*!< Unable to order the slices of the series */, | |
279 OrthancPluginErrorCode_NoWorklistHandler = 2041 /*!< No request handler factory for DICOM C-Find Modality SCP */, | |
265 | 280 |
266 _OrthancPluginErrorCode_INTERNAL = 0x7fffffff | 281 _OrthancPluginErrorCode_INTERNAL = 0x7fffffff |
267 } OrthancPluginErrorCode; | 282 } OrthancPluginErrorCode; |
268 | 283 |
269 | 284 |
376 _OrthancPluginService_BufferCompression = 14, | 391 _OrthancPluginService_BufferCompression = 14, |
377 _OrthancPluginService_ReadFile = 15, | 392 _OrthancPluginService_ReadFile = 15, |
378 _OrthancPluginService_WriteFile = 16, | 393 _OrthancPluginService_WriteFile = 16, |
379 _OrthancPluginService_GetErrorDescription = 17, | 394 _OrthancPluginService_GetErrorDescription = 17, |
380 _OrthancPluginService_CallHttpClient = 18, | 395 _OrthancPluginService_CallHttpClient = 18, |
396 _OrthancPluginService_RegisterErrorCode = 19, | |
397 _OrthancPluginService_RegisterDictionaryTag = 20, | |
398 _OrthancPluginService_DicomBufferToJson = 21, | |
399 _OrthancPluginService_DicomInstanceToJson = 22, | |
400 _OrthancPluginService_CreateDicom = 23, | |
401 _OrthancPluginService_ComputeMd5 = 24, | |
402 _OrthancPluginService_ComputeSha1 = 25, | |
381 | 403 |
382 /* Registration of callbacks */ | 404 /* Registration of callbacks */ |
383 _OrthancPluginService_RegisterRestCallback = 1000, | 405 _OrthancPluginService_RegisterRestCallback = 1000, |
384 _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001, | 406 _OrthancPluginService_RegisterOnStoredInstanceCallback = 1001, |
385 _OrthancPluginService_RegisterStorageArea = 1002, | 407 _OrthancPluginService_RegisterStorageArea = 1002, |
386 _OrthancPluginService_RegisterOnChangeCallback = 1003, | 408 _OrthancPluginService_RegisterOnChangeCallback = 1003, |
387 _OrthancPluginService_RegisterRestCallbackNoLock = 1004, | 409 _OrthancPluginService_RegisterRestCallbackNoLock = 1004, |
410 _OrthancPluginService_RegisterWorklistCallback = 1005, | |
411 _OrthancPluginService_RegisterDecodeImageCallback = 1006, | |
388 | 412 |
389 /* Sending answers to REST calls */ | 413 /* Sending answers to REST calls */ |
390 _OrthancPluginService_AnswerBuffer = 2000, | 414 _OrthancPluginService_AnswerBuffer = 2000, |
391 _OrthancPluginService_CompressAndAnswerPngImage = 2001, /* Unused as of Orthanc 0.9.4 */ | 415 _OrthancPluginService_CompressAndAnswerPngImage = 2001, /* Unused as of Orthanc 0.9.4 */ |
392 _OrthancPluginService_Redirect = 2002, | 416 _OrthancPluginService_Redirect = 2002, |
413 _OrthancPluginService_LookupStudyWithAccessionNumber = 3009, | 437 _OrthancPluginService_LookupStudyWithAccessionNumber = 3009, |
414 _OrthancPluginService_RestApiGetAfterPlugins = 3010, | 438 _OrthancPluginService_RestApiGetAfterPlugins = 3010, |
415 _OrthancPluginService_RestApiPostAfterPlugins = 3011, | 439 _OrthancPluginService_RestApiPostAfterPlugins = 3011, |
416 _OrthancPluginService_RestApiDeleteAfterPlugins = 3012, | 440 _OrthancPluginService_RestApiDeleteAfterPlugins = 3012, |
417 _OrthancPluginService_RestApiPutAfterPlugins = 3013, | 441 _OrthancPluginService_RestApiPutAfterPlugins = 3013, |
442 _OrthancPluginService_ReconstructMainDicomTags = 3014, | |
443 _OrthancPluginService_RestApiGet2 = 3015, | |
418 | 444 |
419 /* Access to DICOM instances */ | 445 /* Access to DICOM instances */ |
420 _OrthancPluginService_GetInstanceRemoteAet = 4000, | 446 _OrthancPluginService_GetInstanceRemoteAet = 4000, |
421 _OrthancPluginService_GetInstanceSize = 4001, | 447 _OrthancPluginService_GetInstanceSize = 4001, |
422 _OrthancPluginService_GetInstanceData = 4002, | 448 _OrthancPluginService_GetInstanceData = 4002, |
423 _OrthancPluginService_GetInstanceJson = 4003, | 449 _OrthancPluginService_GetInstanceJson = 4003, |
424 _OrthancPluginService_GetInstanceSimplifiedJson = 4004, | 450 _OrthancPluginService_GetInstanceSimplifiedJson = 4004, |
425 _OrthancPluginService_HasInstanceMetadata = 4005, | 451 _OrthancPluginService_HasInstanceMetadata = 4005, |
426 _OrthancPluginService_GetInstanceMetadata = 4006, | 452 _OrthancPluginService_GetInstanceMetadata = 4006, |
453 _OrthancPluginService_GetInstanceOrigin = 4007, | |
427 | 454 |
428 /* Services for plugins implementing a database back-end */ | 455 /* Services for plugins implementing a database back-end */ |
429 _OrthancPluginService_RegisterDatabaseBackend = 5000, | 456 _OrthancPluginService_RegisterDatabaseBackend = 5000, |
430 _OrthancPluginService_DatabaseAnswer = 5001, | 457 _OrthancPluginService_DatabaseAnswer = 5001, |
431 _OrthancPluginService_RegisterDatabaseBackendV2 = 5002, | 458 _OrthancPluginService_RegisterDatabaseBackendV2 = 5002, |
444 _OrthancPluginService_CompressImage = 6007, | 471 _OrthancPluginService_CompressImage = 6007, |
445 _OrthancPluginService_ConvertPixelFormat = 6008, | 472 _OrthancPluginService_ConvertPixelFormat = 6008, |
446 _OrthancPluginService_GetFontsCount = 6009, | 473 _OrthancPluginService_GetFontsCount = 6009, |
447 _OrthancPluginService_GetFontInfo = 6010, | 474 _OrthancPluginService_GetFontInfo = 6010, |
448 _OrthancPluginService_DrawText = 6011, | 475 _OrthancPluginService_DrawText = 6011, |
476 _OrthancPluginService_CreateImage = 6012, | |
477 _OrthancPluginService_CreateImageAccessor = 6013, | |
478 _OrthancPluginService_DecodeDicomImage = 6014, | |
479 | |
480 /* Primitives for handling worklists */ | |
481 _OrthancPluginService_WorklistAddAnswer = 7000, | |
482 _OrthancPluginService_WorklistMarkIncomplete = 7001, | |
483 _OrthancPluginService_WorklistIsMatch = 7002, | |
484 _OrthancPluginService_WorklistGetDicomQuery = 7003, | |
449 | 485 |
450 _OrthancPluginService_INTERNAL = 0x7fffffff | 486 _OrthancPluginService_INTERNAL = 0x7fffffff |
451 } _OrthancPluginService; | 487 } _OrthancPluginService; |
452 | 488 |
453 | 489 |
536 { | 572 { |
537 OrthancPluginResourceType_Patient = 0, /*!< Patient */ | 573 OrthancPluginResourceType_Patient = 0, /*!< Patient */ |
538 OrthancPluginResourceType_Study = 1, /*!< Study */ | 574 OrthancPluginResourceType_Study = 1, /*!< Study */ |
539 OrthancPluginResourceType_Series = 2, /*!< Series */ | 575 OrthancPluginResourceType_Series = 2, /*!< Series */ |
540 OrthancPluginResourceType_Instance = 3, /*!< Instance */ | 576 OrthancPluginResourceType_Instance = 3, /*!< Instance */ |
577 OrthancPluginResourceType_None = 4, /*!< Unavailable resource type */ | |
541 | 578 |
542 _OrthancPluginResourceType_INTERNAL = 0x7fffffff | 579 _OrthancPluginResourceType_INTERNAL = 0x7fffffff |
543 } OrthancPluginResourceType; | 580 } OrthancPluginResourceType; |
544 | 581 |
545 | 582 |
558 OrthancPluginChangeType_NewSeries = 5, /*!< New series created */ | 595 OrthancPluginChangeType_NewSeries = 5, /*!< New series created */ |
559 OrthancPluginChangeType_NewStudy = 6, /*!< New study created */ | 596 OrthancPluginChangeType_NewStudy = 6, /*!< New study created */ |
560 OrthancPluginChangeType_StablePatient = 7, /*!< Timeout: No new instance in this patient */ | 597 OrthancPluginChangeType_StablePatient = 7, /*!< Timeout: No new instance in this patient */ |
561 OrthancPluginChangeType_StableSeries = 8, /*!< Timeout: No new instance in this series */ | 598 OrthancPluginChangeType_StableSeries = 8, /*!< Timeout: No new instance in this series */ |
562 OrthancPluginChangeType_StableStudy = 9, /*!< Timeout: No new instance in this study */ | 599 OrthancPluginChangeType_StableStudy = 9, /*!< Timeout: No new instance in this study */ |
600 OrthancPluginChangeType_OrthancStarted = 10, /*!< Orthanc has started */ | |
601 OrthancPluginChangeType_OrthancStopped = 11, /*!< Orthanc is stopping */ | |
602 OrthancPluginChangeType_UpdatedAttachment = 12, /*!< Some user-defined attachment has changed for this resource */ | |
603 OrthancPluginChangeType_UpdatedMetadata = 13, /*!< Some user-defined metadata has changed for this resource */ | |
563 | 604 |
564 _OrthancPluginChangeType_INTERNAL = 0x7fffffff | 605 _OrthancPluginChangeType_INTERNAL = 0x7fffffff |
565 } OrthancPluginChangeType; | 606 } OrthancPluginChangeType; |
566 | 607 |
567 | 608 |
584 * The image formats that are supported by the Orthanc core. | 625 * The image formats that are supported by the Orthanc core. |
585 * @ingroup Images | 626 * @ingroup Images |
586 **/ | 627 **/ |
587 typedef enum | 628 typedef enum |
588 { | 629 { |
589 OrthancPluginImageFormat_Png = 0, /*!< Image compressed using PNG */ | 630 OrthancPluginImageFormat_Png = 0, /*!< Image compressed using PNG */ |
590 OrthancPluginImageFormat_Jpeg = 1, /*!< Image compressed using JPEG */ | 631 OrthancPluginImageFormat_Jpeg = 1, /*!< Image compressed using JPEG */ |
632 OrthancPluginImageFormat_Dicom = 2, /*!< Image compressed using DICOM */ | |
591 | 633 |
592 _OrthancPluginImageFormat_INTERNAL = 0x7fffffff | 634 _OrthancPluginImageFormat_INTERNAL = 0x7fffffff |
593 } OrthancPluginImageFormat; | 635 } OrthancPluginImageFormat; |
594 | 636 |
637 | |
638 /** | |
639 * The value representations present in the DICOM standard (version 2013). | |
640 * @ingroup Toolbox | |
641 **/ | |
642 typedef enum | |
643 { | |
644 OrthancPluginValueRepresentation_AE = 1, /*!< Application Entity */ | |
645 OrthancPluginValueRepresentation_AS = 2, /*!< Age String */ | |
646 OrthancPluginValueRepresentation_AT = 3, /*!< Attribute Tag */ | |
647 OrthancPluginValueRepresentation_CS = 4, /*!< Code String */ | |
648 OrthancPluginValueRepresentation_DA = 5, /*!< Date */ | |
649 OrthancPluginValueRepresentation_DS = 6, /*!< Decimal String */ | |
650 OrthancPluginValueRepresentation_DT = 7, /*!< Date Time */ | |
651 OrthancPluginValueRepresentation_FD = 8, /*!< Floating Point Double */ | |
652 OrthancPluginValueRepresentation_FL = 9, /*!< Floating Point Single */ | |
653 OrthancPluginValueRepresentation_IS = 10, /*!< Integer String */ | |
654 OrthancPluginValueRepresentation_LO = 11, /*!< Long String */ | |
655 OrthancPluginValueRepresentation_LT = 12, /*!< Long Text */ | |
656 OrthancPluginValueRepresentation_OB = 13, /*!< Other Byte String */ | |
657 OrthancPluginValueRepresentation_OF = 14, /*!< Other Float String */ | |
658 OrthancPluginValueRepresentation_OW = 15, /*!< Other Word String */ | |
659 OrthancPluginValueRepresentation_PN = 16, /*!< Person Name */ | |
660 OrthancPluginValueRepresentation_SH = 17, /*!< Short String */ | |
661 OrthancPluginValueRepresentation_SL = 18, /*!< Signed Long */ | |
662 OrthancPluginValueRepresentation_SQ = 19, /*!< Sequence of Items */ | |
663 OrthancPluginValueRepresentation_SS = 20, /*!< Signed Short */ | |
664 OrthancPluginValueRepresentation_ST = 21, /*!< Short Text */ | |
665 OrthancPluginValueRepresentation_TM = 22, /*!< Time */ | |
666 OrthancPluginValueRepresentation_UI = 23, /*!< Unique Identifier (UID) */ | |
667 OrthancPluginValueRepresentation_UL = 24, /*!< Unsigned Long */ | |
668 OrthancPluginValueRepresentation_UN = 25, /*!< Unknown */ | |
669 OrthancPluginValueRepresentation_US = 26, /*!< Unsigned Short */ | |
670 OrthancPluginValueRepresentation_UT = 27, /*!< Unlimited Text */ | |
671 | |
672 _OrthancPluginValueRepresentation_INTERNAL = 0x7fffffff | |
673 } OrthancPluginValueRepresentation; | |
674 | |
675 | |
676 /** | |
677 * The possible output formats for a DICOM-to-JSON conversion. | |
678 * @ingroup Toolbox | |
679 * @see OrthancPluginDicomToJson() | |
680 **/ | |
681 typedef enum | |
682 { | |
683 OrthancPluginDicomToJsonFormat_Full = 1, /*!< Full output, with most details */ | |
684 OrthancPluginDicomToJsonFormat_Short = 2, /*!< Tags output as hexadecimal numbers */ | |
685 OrthancPluginDicomToJsonFormat_Simple = 3, /*!< Human-readable JSON */ | |
686 | |
687 _OrthancPluginDicomToJsonFormat_INTERNAL = 0x7fffffff | |
688 } OrthancPluginDicomToJsonFormat; | |
689 | |
690 | |
691 /** | |
692 * Flags to customize a DICOM-to-JSON conversion. By default, binary | |
693 * tags are formatted using Data URI scheme. | |
694 * @ingroup Toolbox | |
695 **/ | |
696 typedef enum | |
697 { | |
698 OrthancPluginDicomToJsonFlags_IncludeBinary = (1 << 0), /*!< Include the binary tags */ | |
699 OrthancPluginDicomToJsonFlags_IncludePrivateTags = (1 << 1), /*!< Include the private tags */ | |
700 OrthancPluginDicomToJsonFlags_IncludeUnknownTags = (1 << 2), /*!< Include the tags unknown by the dictionary */ | |
701 OrthancPluginDicomToJsonFlags_IncludePixelData = (1 << 3), /*!< Include the pixel data */ | |
702 OrthancPluginDicomToJsonFlags_ConvertBinaryToAscii = (1 << 4), /*!< Output binary tags as-is, dropping non-ASCII */ | |
703 OrthancPluginDicomToJsonFlags_ConvertBinaryToNull = (1 << 5), /*!< Signal binary tags as null values */ | |
704 | |
705 _OrthancPluginDicomToJsonFlags_INTERNAL = 0x7fffffff | |
706 } OrthancPluginDicomToJsonFlags; | |
707 | |
708 | |
709 /** | |
710 * Flags to the creation of a DICOM file. | |
711 * @ingroup Toolbox | |
712 * @see OrthancPluginCreateDicom() | |
713 **/ | |
714 typedef enum | |
715 { | |
716 OrthancPluginCreateDicomFlags_DecodeDataUriScheme = (1 << 0), /*!< Decode fields encoded using data URI scheme */ | |
717 OrthancPluginCreateDicomFlags_GenerateIdentifiers = (1 << 1), /*!< Automatically generate DICOM identifiers */ | |
718 | |
719 _OrthancPluginCreateDicomFlags_INTERNAL = 0x7fffffff | |
720 } OrthancPluginCreateDicomFlags; | |
721 | |
722 | |
723 /** | |
724 * The constraints on the DICOM identifiers that must be supported | |
725 * by the database plugins. | |
726 **/ | |
727 typedef enum | |
728 { | |
729 OrthancPluginIdentifierConstraint_Equal = 1, /*!< Equal */ | |
730 OrthancPluginIdentifierConstraint_SmallerOrEqual = 2, /*!< Less or equal */ | |
731 OrthancPluginIdentifierConstraint_GreaterOrEqual = 3, /*!< More or equal */ | |
732 OrthancPluginIdentifierConstraint_Wildcard = 4, /*!< Case-sensitive wildcard matching (with * and ?) */ | |
733 | |
734 _OrthancPluginIdentifierConstraint_INTERNAL = 0x7fffffff | |
735 } OrthancPluginIdentifierConstraint; | |
736 | |
737 | |
738 /** | |
739 * The origin of a DICOM instance that has been received by Orthanc. | |
740 **/ | |
741 typedef enum | |
742 { | |
743 OrthancPluginInstanceOrigin_Unknown = 1, /*!< Unknown origin */ | |
744 OrthancPluginInstanceOrigin_DicomProtocol = 2, /*!< Instance received through DICOM protocol */ | |
745 OrthancPluginInstanceOrigin_RestApi = 3, /*!< Instance received through REST API of Orthanc */ | |
746 OrthancPluginInstanceOrigin_Plugin = 4, /*!< Instance added to Orthanc by a plugin */ | |
747 OrthancPluginInstanceOrigin_Lua = 5, /*!< Instance added to Orthanc by a Lua script */ | |
748 | |
749 _OrthancPluginInstanceOrigin_INTERNAL = 0x7fffffff | |
750 } OrthancPluginInstanceOrigin; | |
595 | 751 |
596 | 752 |
597 /** | 753 /** |
598 * @brief A memory buffer allocated by the core system of Orthanc. | 754 * @brief A memory buffer allocated by the core system of Orthanc. |
599 * | 755 * |
647 typedef struct _OrthancPluginStorageArea_t OrthancPluginStorageArea; | 803 typedef struct _OrthancPluginStorageArea_t OrthancPluginStorageArea; |
648 | 804 |
649 | 805 |
650 | 806 |
651 /** | 807 /** |
808 * @brief Opaque structure to an object that represents a C-Find query. | |
809 * @ingroup Worklists | |
810 **/ | |
811 typedef struct _OrthancPluginWorklistQuery_t OrthancPluginWorklistQuery; | |
812 | |
813 | |
814 | |
815 /** | |
816 * @brief Opaque structure to an object that represents the answers to a C-Find query. | |
817 * @ingroup Worklists | |
818 **/ | |
819 typedef struct _OrthancPluginWorklistAnswers_t OrthancPluginWorklistAnswers; | |
820 | |
821 | |
822 | |
823 /** | |
652 * @brief Signature of a callback function that answers to a REST request. | 824 * @brief Signature of a callback function that answers to a REST request. |
653 * @ingroup Callbacks | 825 * @ingroup Callbacks |
654 **/ | 826 **/ |
655 typedef int32_t (*OrthancPluginRestCallback) ( | 827 typedef OrthancPluginErrorCode (*OrthancPluginRestCallback) ( |
656 OrthancPluginRestOutput* output, | 828 OrthancPluginRestOutput* output, |
657 const char* url, | 829 const char* url, |
658 const OrthancPluginHttpRequest* request); | 830 const OrthancPluginHttpRequest* request); |
659 | 831 |
660 | 832 |
661 | 833 |
662 /** | 834 /** |
663 * @brief Signature of a callback function that is triggered when Orthanc receives a DICOM instance. | 835 * @brief Signature of a callback function that is triggered when Orthanc receives a DICOM instance. |
664 * @ingroup Callbacks | 836 * @ingroup Callbacks |
665 **/ | 837 **/ |
666 typedef int32_t (*OrthancPluginOnStoredInstanceCallback) ( | 838 typedef OrthancPluginErrorCode (*OrthancPluginOnStoredInstanceCallback) ( |
667 OrthancPluginDicomInstance* instance, | 839 OrthancPluginDicomInstance* instance, |
668 const char* instanceId); | 840 const char* instanceId); |
669 | 841 |
670 | 842 |
671 | 843 |
672 /** | 844 /** |
673 * @brief Signature of a callback function that is triggered when a change happens to some DICOM resource. | 845 * @brief Signature of a callback function that is triggered when a change happens to some DICOM resource. |
674 * @ingroup Callbacks | 846 * @ingroup Callbacks |
675 **/ | 847 **/ |
676 typedef int32_t (*OrthancPluginOnChangeCallback) ( | 848 typedef OrthancPluginErrorCode (*OrthancPluginOnChangeCallback) ( |
677 OrthancPluginChangeType changeType, | 849 OrthancPluginChangeType changeType, |
678 OrthancPluginResourceType resourceType, | 850 OrthancPluginResourceType resourceType, |
679 const char* resourceId); | 851 const char* resourceId); |
852 | |
853 | |
854 | |
855 /** | |
856 * @brief Signature of a callback function to decode a DICOM instance as an image. | |
857 * @ingroup Callbacks | |
858 **/ | |
859 typedef OrthancPluginErrorCode (*OrthancPluginDecodeImageCallback) ( | |
860 OrthancPluginImage** target, | |
861 const void* dicom, | |
862 const uint32_t size, | |
863 uint32_t frameIndex); | |
680 | 864 |
681 | 865 |
682 | 866 |
683 /** | 867 /** |
684 * @brief Signature of a function to free dynamic memory. | 868 * @brief Signature of a function to free dynamic memory. |
697 * @param size The size of the file. | 881 * @param size The size of the file. |
698 * @param type The content type corresponding to this file. | 882 * @param type The content type corresponding to this file. |
699 * @return 0 if success, other value if error. | 883 * @return 0 if success, other value if error. |
700 * @ingroup Callbacks | 884 * @ingroup Callbacks |
701 **/ | 885 **/ |
702 typedef int32_t (*OrthancPluginStorageCreate) ( | 886 typedef OrthancPluginErrorCode (*OrthancPluginStorageCreate) ( |
703 const char* uuid, | 887 const char* uuid, |
704 const void* content, | 888 const void* content, |
705 int64_t size, | 889 int64_t size, |
706 OrthancPluginContentType type); | 890 OrthancPluginContentType type); |
707 | 891 |
717 * @param uuid The UUID of the file of interest. | 901 * @param uuid The UUID of the file of interest. |
718 * @param type The content type corresponding to this file. | 902 * @param type The content type corresponding to this file. |
719 * @return 0 if success, other value if error. | 903 * @return 0 if success, other value if error. |
720 * @ingroup Callbacks | 904 * @ingroup Callbacks |
721 **/ | 905 **/ |
722 typedef int32_t (*OrthancPluginStorageRead) ( | 906 typedef OrthancPluginErrorCode (*OrthancPluginStorageRead) ( |
723 void** content, | 907 void** content, |
724 int64_t* size, | 908 int64_t* size, |
725 const char* uuid, | 909 const char* uuid, |
726 OrthancPluginContentType type); | 910 OrthancPluginContentType type); |
727 | 911 |
735 * @param uuid The UUID of the file to be removed. | 919 * @param uuid The UUID of the file to be removed. |
736 * @param type The content type corresponding to this file. | 920 * @param type The content type corresponding to this file. |
737 * @return 0 if success, other value if error. | 921 * @return 0 if success, other value if error. |
738 * @ingroup Callbacks | 922 * @ingroup Callbacks |
739 **/ | 923 **/ |
740 typedef int32_t (*OrthancPluginStorageRemove) ( | 924 typedef OrthancPluginErrorCode (*OrthancPluginStorageRemove) ( |
741 const char* uuid, | 925 const char* uuid, |
742 OrthancPluginContentType type); | 926 OrthancPluginContentType type); |
927 | |
928 | |
929 | |
930 /** | |
931 * @brief Callback to handle the C-Find SCP requests received by Orthanc. | |
932 * | |
933 * Signature of a callback function that is triggered when Orthanc | |
934 * receives a C-Find SCP request against modality worklists. | |
935 * | |
936 * @param answers The target structure where answers must be stored. | |
937 * @param query The worklist query. | |
938 * @param remoteAet The Application Entity Title (AET) of the modality from which the request originates. | |
939 * @param calledAet The Application Entity Title (AET) of the modality that is called by the request. | |
940 * @return 0 if success, other value if error. | |
941 * @ingroup Worklists | |
942 **/ | |
943 typedef OrthancPluginErrorCode (*OrthancPluginWorklistCallback) ( | |
944 OrthancPluginWorklistAnswers* answers, | |
945 const OrthancPluginWorklistQuery* query, | |
946 const char* remoteAet, | |
947 const char* calledAet); | |
743 | 948 |
744 | 949 |
745 | 950 |
746 /** | 951 /** |
747 * @brief Data structure that contains information about the Orthanc core. | 952 * @brief Data structure that contains information about the Orthanc core. |
802 sizeof(int32_t) != sizeof(OrthancPluginPixelFormat) || | 1007 sizeof(int32_t) != sizeof(OrthancPluginPixelFormat) || |
803 sizeof(int32_t) != sizeof(OrthancPluginContentType) || | 1008 sizeof(int32_t) != sizeof(OrthancPluginContentType) || |
804 sizeof(int32_t) != sizeof(OrthancPluginResourceType) || | 1009 sizeof(int32_t) != sizeof(OrthancPluginResourceType) || |
805 sizeof(int32_t) != sizeof(OrthancPluginChangeType) || | 1010 sizeof(int32_t) != sizeof(OrthancPluginChangeType) || |
806 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) || | 1011 sizeof(int32_t) != sizeof(OrthancPluginCompressionType) || |
807 sizeof(int32_t) != sizeof(OrthancPluginImageFormat)) | 1012 sizeof(int32_t) != sizeof(OrthancPluginImageFormat) || |
1013 sizeof(int32_t) != sizeof(OrthancPluginValueRepresentation) || | |
1014 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFormat) || | |
1015 sizeof(int32_t) != sizeof(OrthancPluginDicomToJsonFlags) || | |
1016 sizeof(int32_t) != sizeof(OrthancPluginCreateDicomFlags) || | |
1017 sizeof(int32_t) != sizeof(OrthancPluginIdentifierConstraint) || | |
1018 sizeof(int32_t) != sizeof(OrthancPluginInstanceOrigin)) | |
808 { | 1019 { |
809 /* Mismatch in the size of the enumerations */ | 1020 /* Mismatch in the size of the enumerations */ |
810 return 0; | 1021 return 0; |
811 } | 1022 } |
812 | 1023 |
1137 * | 1348 * |
1138 * Retrieve a DICOM instance using its Orthanc identifier. The DICOM | 1349 * Retrieve a DICOM instance using its Orthanc identifier. The DICOM |
1139 * file is stored into a newly allocated memory buffer. | 1350 * file is stored into a newly allocated memory buffer. |
1140 * | 1351 * |
1141 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 1352 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
1142 * @param target The target memory buffer. | 1353 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
1143 * @param instanceId The Orthanc identifier of the DICOM instance of interest. | 1354 * @param instanceId The Orthanc identifier of the DICOM instance of interest. |
1144 * @return 0 if success, or the error code if failure. | 1355 * @return 0 if success, or the error code if failure. |
1145 * @ingroup Orthanc | 1356 * @ingroup Orthanc |
1146 **/ | 1357 **/ |
1147 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetDicomForInstance( | 1358 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginGetDicomForInstance( |
1168 * | 1379 * |
1169 * Make a GET call to the built-in Orthanc REST API. The result to | 1380 * Make a GET call to the built-in Orthanc REST API. The result to |
1170 * the query is stored into a newly allocated memory buffer. | 1381 * the query is stored into a newly allocated memory buffer. |
1171 * | 1382 * |
1172 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 1383 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
1173 * @param target The target memory buffer. | 1384 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
1174 * @param uri The URI in the built-in Orthanc API. | 1385 * @param uri The URI in the built-in Orthanc API. |
1175 * @return 0 if success, or the error code if failure. | 1386 * @return 0 if success, or the error code if failure. |
1176 * @see OrthancPluginRestApiGetAfterPlugins | 1387 * @see OrthancPluginRestApiGetAfterPlugins |
1177 * @ingroup Orthanc | 1388 * @ingroup Orthanc |
1178 **/ | 1389 **/ |
1197 * called URI to the built-in Orthanc REST API, this call will | 1408 * called URI to the built-in Orthanc REST API, this call will |
1198 * return the result provided by this plugin. The result to the | 1409 * return the result provided by this plugin. The result to the |
1199 * query is stored into a newly allocated memory buffer. | 1410 * query is stored into a newly allocated memory buffer. |
1200 * | 1411 * |
1201 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 1412 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
1202 * @param target The target memory buffer. | 1413 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
1203 * @param uri The URI in the built-in Orthanc API. | 1414 * @param uri The URI in the built-in Orthanc API. |
1204 * @return 0 if success, or the error code if failure. | 1415 * @return 0 if success, or the error code if failure. |
1205 * @see OrthancPluginRestApiGet | 1416 * @see OrthancPluginRestApiGet |
1206 * @ingroup Orthanc | 1417 * @ingroup Orthanc |
1207 **/ | 1418 **/ |
1231 * | 1442 * |
1232 * Make a POST call to the built-in Orthanc REST API. The result to | 1443 * Make a POST call to the built-in Orthanc REST API. The result to |
1233 * the query is stored into a newly allocated memory buffer. | 1444 * the query is stored into a newly allocated memory buffer. |
1234 * | 1445 * |
1235 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 1446 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
1236 * @param target The target memory buffer. | 1447 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
1237 * @param uri The URI in the built-in Orthanc API. | 1448 * @param uri The URI in the built-in Orthanc API. |
1238 * @param body The body of the POST request. | 1449 * @param body The body of the POST request. |
1239 * @param bodySize The size of the body. | 1450 * @param bodySize The size of the body. |
1240 * @return 0 if success, or the error code if failure. | 1451 * @return 0 if success, or the error code if failure. |
1241 * @see OrthancPluginRestApiPostAfterPlugins | 1452 * @see OrthancPluginRestApiPostAfterPlugins |
1265 * called URI to the built-in Orthanc REST API, this call will | 1476 * called URI to the built-in Orthanc REST API, this call will |
1266 * return the result provided by this plugin. The result to the | 1477 * return the result provided by this plugin. The result to the |
1267 * query is stored into a newly allocated memory buffer. | 1478 * query is stored into a newly allocated memory buffer. |
1268 * | 1479 * |
1269 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 1480 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
1270 * @param target The target memory buffer. | 1481 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
1271 * @param uri The URI in the built-in Orthanc API. | 1482 * @param uri The URI in the built-in Orthanc API. |
1272 * @param body The body of the POST request. | 1483 * @param body The body of the POST request. |
1273 * @param bodySize The size of the body. | 1484 * @param bodySize The size of the body. |
1274 * @return 0 if success, or the error code if failure. | 1485 * @return 0 if success, or the error code if failure. |
1275 * @see OrthancPluginRestApiPost | 1486 * @see OrthancPluginRestApiPost |
1339 * | 1550 * |
1340 * Make a PUT call to the built-in Orthanc REST API. The result to | 1551 * Make a PUT call to the built-in Orthanc REST API. The result to |
1341 * the query is stored into a newly allocated memory buffer. | 1552 * the query is stored into a newly allocated memory buffer. |
1342 * | 1553 * |
1343 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 1554 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
1344 * @param target The target memory buffer. | 1555 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
1345 * @param uri The URI in the built-in Orthanc API. | 1556 * @param uri The URI in the built-in Orthanc API. |
1346 * @param body The body of the PUT request. | 1557 * @param body The body of the PUT request. |
1347 * @param bodySize The size of the body. | 1558 * @param bodySize The size of the body. |
1348 * @return 0 if success, or the error code if failure. | 1559 * @return 0 if success, or the error code if failure. |
1349 * @see OrthancPluginRestApiPutAfterPlugins | 1560 * @see OrthancPluginRestApiPutAfterPlugins |
1374 * called URI to the built-in Orthanc REST API, this call will | 1585 * called URI to the built-in Orthanc REST API, this call will |
1375 * return the result provided by this plugin. The result to the | 1586 * return the result provided by this plugin. The result to the |
1376 * query is stored into a newly allocated memory buffer. | 1587 * query is stored into a newly allocated memory buffer. |
1377 * | 1588 * |
1378 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 1589 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
1379 * @param target The target memory buffer. | 1590 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
1380 * @param uri The URI in the built-in Orthanc API. | 1591 * @param uri The URI in the built-in Orthanc API. |
1381 * @param body The body of the PUT request. | 1592 * @param body The body of the PUT request. |
1382 * @param bodySize The size of the body. | 1593 * @param bodySize The size of the body. |
1383 * @return 0 if success, or the error code if failure. | 1594 * @return 0 if success, or the error code if failure. |
1384 * @see OrthancPluginRestApiPut | 1595 * @see OrthancPluginRestApiPut |
1750 } | 1961 } |
1751 | 1962 |
1752 | 1963 |
1753 typedef struct | 1964 typedef struct |
1754 { | 1965 { |
1755 char** resultStringToFree; | 1966 char** resultStringToFree; |
1756 const char** resultString; | 1967 const char** resultString; |
1757 int64_t* resultInt64; | 1968 int64_t* resultInt64; |
1758 const char* key; | 1969 const char* key; |
1759 OrthancPluginDicomInstance* instance; | 1970 OrthancPluginDicomInstance* instance; |
1971 OrthancPluginInstanceOrigin* resultOrigin; /* New in Orthanc 0.9.5 SDK */ | |
1760 } _OrthancPluginAccessDicomInstance; | 1972 } _OrthancPluginAccessDicomInstance; |
1761 | 1973 |
1762 | 1974 |
1763 /** | 1975 /** |
1764 * @brief Get the AET of a DICOM instance. | 1976 * @brief Get the AET of a DICOM instance. |
2162 /** | 2374 /** |
2163 * @brief Register a callback to monitor changes. | 2375 * @brief Register a callback to monitor changes. |
2164 * | 2376 * |
2165 * This function registers a callback function that is called | 2377 * This function registers a callback function that is called |
2166 * whenever a change happens to some DICOM resource. | 2378 * whenever a change happens to some DICOM resource. |
2379 * | |
2380 * @warning If your change callback has to call the REST API of | |
2381 * Orthanc, you should make these calls in a separate thread (with | |
2382 * the events passing through a message queue). Otherwise, this | |
2383 * could result in deadlocks in the presence of other plugins or Lua | |
2384 * script. | |
2167 * | 2385 * |
2168 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 2386 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
2169 * @param callback The callback function. | 2387 * @param callback The callback function. |
2170 * @ingroup Callbacks | 2388 * @ingroup Callbacks |
2171 **/ | 2389 **/ |
2548 * | 2766 * |
2549 * This function compresses or decompresses a buffer, using the | 2767 * This function compresses or decompresses a buffer, using the |
2550 * version of the zlib library that is used by the Orthanc core. | 2768 * version of the zlib library that is used by the Orthanc core. |
2551 * | 2769 * |
2552 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 2770 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
2553 * @param target The target memory buffer. | 2771 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
2554 * @param source The source buffer. | 2772 * @param source The source buffer. |
2555 * @param size The size in bytes of the source buffer. | 2773 * @param size The size in bytes of the source buffer. |
2556 * @param compression The compression algorithm. | 2774 * @param compression The compression algorithm. |
2557 * @param uncompress If set to "0", the buffer must be compressed. | 2775 * @param uncompress If set to "0", the buffer must be compressed. |
2558 * If set to "1", the buffer must be uncompressed. | 2776 * If set to "1", the buffer must be uncompressed. |
2590 * | 2808 * |
2591 * Read the content of a file on the filesystem, and returns it into | 2809 * Read the content of a file on the filesystem, and returns it into |
2592 * a newly allocated memory buffer. | 2810 * a newly allocated memory buffer. |
2593 * | 2811 * |
2594 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 2812 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
2595 * @param target The target memory buffer. | 2813 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
2596 * @param path The path of the file to be read. | 2814 * @param path The path of the file to be read. |
2597 * @return 0 if success, or the error code if failure. | 2815 * @return 0 if success, or the error code if failure. |
2598 **/ | 2816 **/ |
2599 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReadFile( | 2817 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReadFile( |
2600 OrthancPluginContext* context, | 2818 OrthancPluginContext* context, |
2731 typedef struct | 2949 typedef struct |
2732 { | 2950 { |
2733 const OrthancPluginImage* image; | 2951 const OrthancPluginImage* image; |
2734 uint32_t* resultUint32; | 2952 uint32_t* resultUint32; |
2735 OrthancPluginPixelFormat* resultPixelFormat; | 2953 OrthancPluginPixelFormat* resultPixelFormat; |
2736 const void** resultBuffer; | 2954 void** resultBuffer; |
2737 } _OrthancPluginGetImageInfo; | 2955 } _OrthancPluginGetImageInfo; |
2738 | 2956 |
2739 | 2957 |
2740 /** | 2958 /** |
2741 * @brief Return the pixel format of an image. | 2959 * @brief Return the pixel format of an image. |
2880 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 3098 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
2881 * @param image The image of interest. | 3099 * @param image The image of interest. |
2882 * @return The pointer. | 3100 * @return The pointer. |
2883 * @ingroup Images | 3101 * @ingroup Images |
2884 **/ | 3102 **/ |
2885 ORTHANC_PLUGIN_INLINE const void* OrthancPluginGetImageBuffer( | 3103 ORTHANC_PLUGIN_INLINE void* OrthancPluginGetImageBuffer( |
2886 OrthancPluginContext* context, | 3104 OrthancPluginContext* context, |
2887 const OrthancPluginImage* image) | 3105 const OrthancPluginImage* image) |
2888 { | 3106 { |
2889 const void* target = NULL; | 3107 void* target = NULL; |
2890 | 3108 |
2891 _OrthancPluginGetImageInfo params; | 3109 _OrthancPluginGetImageInfo params; |
2892 memset(¶ms, 0, sizeof(params)); | 3110 memset(¶ms, 0, sizeof(params)); |
2893 params.resultBuffer = ⌖ | 3111 params.resultBuffer = ⌖ |
2894 params.image = image; | 3112 params.image = image; |
3148 * stored into a newly allocated memory buffer. Favor | 3366 * stored into a newly allocated memory buffer. Favor |
3149 * OrthancPluginRestApiGet() if calling the built-in REST API of the | 3367 * OrthancPluginRestApiGet() if calling the built-in REST API of the |
3150 * Orthanc instance that hosts this plugin. | 3368 * Orthanc instance that hosts this plugin. |
3151 * | 3369 * |
3152 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 3370 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
3153 * @param target The target memory buffer. | 3371 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
3154 * @param url The URL of interest. | 3372 * @param url The URL of interest. |
3155 * @param username The username (can be <tt>NULL</tt> if no password protection). | 3373 * @param username The username (can be <tt>NULL</tt> if no password protection). |
3156 * @param password The password (can be <tt>NULL</tt> if no password protection). | 3374 * @param password The password (can be <tt>NULL</tt> if no password protection). |
3157 * @return 0 if success, or the error code if failure. | 3375 * @return 0 if success, or the error code if failure. |
3158 **/ | 3376 **/ |
3183 * is stored into a newly allocated memory buffer. Favor | 3401 * is stored into a newly allocated memory buffer. Favor |
3184 * OrthancPluginRestApiPost() if calling the built-in REST API of | 3402 * OrthancPluginRestApiPost() if calling the built-in REST API of |
3185 * the Orthanc instance that hosts this plugin. | 3403 * the Orthanc instance that hosts this plugin. |
3186 * | 3404 * |
3187 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 3405 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
3188 * @param target The target memory buffer. | 3406 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
3189 * @param url The URL of interest. | 3407 * @param url The URL of interest. |
3190 * @param body The content of the body of the request. | 3408 * @param body The content of the body of the request. |
3191 * @param bodySize The size of the body of the request. | 3409 * @param bodySize The size of the body of the request. |
3192 * @param username The username (can be <tt>NULL</tt> if no password protection). | 3410 * @param username The username (can be <tt>NULL</tt> if no password protection). |
3193 * @param password The password (can be <tt>NULL</tt> if no password protection). | 3411 * @param password The password (can be <tt>NULL</tt> if no password protection). |
3224 * stored into a newly allocated memory buffer. Favor | 3442 * stored into a newly allocated memory buffer. Favor |
3225 * OrthancPluginRestApiPut() if calling the built-in REST API of the | 3443 * OrthancPluginRestApiPut() if calling the built-in REST API of the |
3226 * Orthanc instance that hosts this plugin. | 3444 * Orthanc instance that hosts this plugin. |
3227 * | 3445 * |
3228 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | 3446 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). |
3229 * @param target The target memory buffer. | 3447 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). |
3230 * @param url The URL of interest. | 3448 * @param url The URL of interest. |
3231 * @param body The content of the body of the request. | 3449 * @param body The content of the body of the request. |
3232 * @param bodySize The size of the body of the request. | 3450 * @param bodySize The size of the body of the request. |
3233 * @param username The username (can be <tt>NULL</tt> if no password protection). | 3451 * @param username The username (can be <tt>NULL</tt> if no password protection). |
3234 * @param password The password (can be <tt>NULL</tt> if no password protection). | 3452 * @param password The password (can be <tt>NULL</tt> if no password protection). |
3585 OrthancPluginStorageArea* storageArea; | 3803 OrthancPluginStorageArea* storageArea; |
3586 const char* uuid; | 3804 const char* uuid; |
3587 OrthancPluginContentType type; | 3805 OrthancPluginContentType type; |
3588 } _OrthancPluginStorageAreaRemove; | 3806 } _OrthancPluginStorageAreaRemove; |
3589 | 3807 |
3590 | |
3591 /** | 3808 /** |
3592 * @brief Remove a file from the storage area. | 3809 * @brief Remove a file from the storage area. |
3593 * | 3810 * |
3594 * This function removes a given file from the storage area that is | 3811 * This function removes a given file from the storage area that is |
3595 * currently used by Orthanc. | 3812 * currently used by Orthanc. |
3615 return context->InvokeService(context, _OrthancPluginService_StorageAreaRemove, ¶ms); | 3832 return context->InvokeService(context, _OrthancPluginService_StorageAreaRemove, ¶ms); |
3616 } | 3833 } |
3617 | 3834 |
3618 | 3835 |
3619 | 3836 |
3837 typedef struct | |
3838 { | |
3839 OrthancPluginErrorCode* target; | |
3840 int32_t code; | |
3841 uint16_t httpStatus; | |
3842 const char* message; | |
3843 } _OrthancPluginRegisterErrorCode; | |
3844 | |
3845 /** | |
3846 * @brief Declare a custom error code for this plugin. | |
3847 * | |
3848 * This function declares a custom error code that can be generated | |
3849 * by this plugin. This declaration is used to enrich the body of | |
3850 * the HTTP answer in the case of an error, and to set the proper | |
3851 * HTTP status code. | |
3852 * | |
3853 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3854 * @param code The error code that is internal to this plugin. | |
3855 * @param httpStatus The HTTP status corresponding to this error. | |
3856 * @param message The description of the error. | |
3857 * @return The error code that has been assigned inside the Orthanc core. | |
3858 * @ingroup Toolbox | |
3859 **/ | |
3860 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterErrorCode( | |
3861 OrthancPluginContext* context, | |
3862 int32_t code, | |
3863 uint16_t httpStatus, | |
3864 const char* message) | |
3865 { | |
3866 OrthancPluginErrorCode target; | |
3867 | |
3868 _OrthancPluginRegisterErrorCode params; | |
3869 params.target = ⌖ | |
3870 params.code = code; | |
3871 params.httpStatus = httpStatus; | |
3872 params.message = message; | |
3873 | |
3874 if (context->InvokeService(context, _OrthancPluginService_RegisterErrorCode, ¶ms) == OrthancPluginErrorCode_Success) | |
3875 { | |
3876 return target; | |
3877 } | |
3878 else | |
3879 { | |
3880 /* There was an error while assigned the error. Use a generic code. */ | |
3881 return OrthancPluginErrorCode_Plugin; | |
3882 } | |
3883 } | |
3884 | |
3885 | |
3886 | |
3887 typedef struct | |
3888 { | |
3889 uint16_t group; | |
3890 uint16_t element; | |
3891 OrthancPluginValueRepresentation vr; | |
3892 const char* name; | |
3893 uint32_t minMultiplicity; | |
3894 uint32_t maxMultiplicity; | |
3895 } _OrthancPluginRegisterDictionaryTag; | |
3896 | |
3897 /** | |
3898 * @brief Register a new tag into the DICOM dictionary. | |
3899 * | |
3900 * This function declares a new tag in the dictionary of DICOM tags | |
3901 * that are known to Orthanc. This function should be used in the | |
3902 * OrthancPluginInitialize() callback. | |
3903 * | |
3904 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3905 * @param group The group of the tag. | |
3906 * @param element The element of the tag. | |
3907 * @param vr The value representation of the tag. | |
3908 * @param name The nickname of the tag. | |
3909 * @param minMultiplicity The minimum multiplicity of the tag (must be above 0). | |
3910 * @param maxMultiplicity The maximum multiplicity of the tag. A value of 0 means | |
3911 * an arbitrary multiplicity ("<tt>n</tt>"). | |
3912 * @return 0 if success, other value if error. | |
3913 * @ingroup Toolbox | |
3914 **/ | |
3915 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDictionaryTag( | |
3916 OrthancPluginContext* context, | |
3917 uint16_t group, | |
3918 uint16_t element, | |
3919 OrthancPluginValueRepresentation vr, | |
3920 const char* name, | |
3921 uint32_t minMultiplicity, | |
3922 uint32_t maxMultiplicity) | |
3923 { | |
3924 _OrthancPluginRegisterDictionaryTag params; | |
3925 params.group = group; | |
3926 params.element = element; | |
3927 params.vr = vr; | |
3928 params.name = name; | |
3929 params.minMultiplicity = minMultiplicity; | |
3930 params.maxMultiplicity = maxMultiplicity; | |
3931 | |
3932 return context->InvokeService(context, _OrthancPluginService_RegisterDictionaryTag, ¶ms); | |
3933 } | |
3934 | |
3935 | |
3936 | |
3937 | |
3938 typedef struct | |
3939 { | |
3940 OrthancPluginStorageArea* storageArea; | |
3941 OrthancPluginResourceType level; | |
3942 } _OrthancPluginReconstructMainDicomTags; | |
3943 | |
3944 /** | |
3945 * @brief Reconstruct the main DICOM tags. | |
3946 * | |
3947 * This function requests the Orthanc core to reconstruct the main | |
3948 * DICOM tags of all the resources of the given type. This function | |
3949 * can only be used as a part of the upgrade of a custom database | |
3950 * back-end | |
3951 * (cf. OrthancPlugins::IDatabaseBackend::UpgradeDatabase). A | |
3952 * database transaction will be automatically setup. | |
3953 * | |
3954 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3955 * @param storageArea The storage area. | |
3956 * @param level The type of the resources of interest. | |
3957 * @return 0 if success, other value if error. | |
3958 * @ingroup Callbacks | |
3959 **/ | |
3960 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginReconstructMainDicomTags( | |
3961 OrthancPluginContext* context, | |
3962 OrthancPluginStorageArea* storageArea, | |
3963 OrthancPluginResourceType level) | |
3964 { | |
3965 _OrthancPluginReconstructMainDicomTags params; | |
3966 params.level = level; | |
3967 params.storageArea = storageArea; | |
3968 | |
3969 return context->InvokeService(context, _OrthancPluginService_ReconstructMainDicomTags, ¶ms); | |
3970 } | |
3971 | |
3972 | |
3973 typedef struct | |
3974 { | |
3975 char** result; | |
3976 const char* instanceId; | |
3977 const char* buffer; | |
3978 uint32_t size; | |
3979 OrthancPluginDicomToJsonFormat format; | |
3980 OrthancPluginDicomToJsonFlags flags; | |
3981 uint32_t maxStringLength; | |
3982 } _OrthancPluginDicomToJson; | |
3983 | |
3984 | |
3985 /** | |
3986 * @brief Format a DICOM memory buffer as a JSON string. | |
3987 * | |
3988 * This function takes as input a memory buffer containing a DICOM | |
3989 * file, and outputs a JSON string representing the tags of this | |
3990 * DICOM file. | |
3991 * | |
3992 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
3993 * @param buffer The memory buffer containing the DICOM file. | |
3994 * @param size The size of the memory buffer. | |
3995 * @param format The output format. | |
3996 * @param flags Flags governing the output. | |
3997 * @param maxStringLength The maximum length of a field. Too long fields will | |
3998 * be output as "null". The 0 value means no maximum length. | |
3999 * @return The NULL value if the case of an error, or the JSON | |
4000 * string. This string must be freed by OrthancPluginFreeString(). | |
4001 * @ingroup Toolbox | |
4002 * @see OrthancPluginDicomInstanceToJson | |
4003 **/ | |
4004 ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomBufferToJson( | |
4005 OrthancPluginContext* context, | |
4006 const char* buffer, | |
4007 uint32_t size, | |
4008 OrthancPluginDicomToJsonFormat format, | |
4009 OrthancPluginDicomToJsonFlags flags, | |
4010 uint32_t maxStringLength) | |
4011 { | |
4012 char* result; | |
4013 | |
4014 _OrthancPluginDicomToJson params; | |
4015 memset(¶ms, 0, sizeof(params)); | |
4016 params.result = &result; | |
4017 params.buffer = buffer; | |
4018 params.size = size; | |
4019 params.format = format; | |
4020 params.flags = flags; | |
4021 params.maxStringLength = maxStringLength; | |
4022 | |
4023 if (context->InvokeService(context, _OrthancPluginService_DicomBufferToJson, ¶ms) != OrthancPluginErrorCode_Success) | |
4024 { | |
4025 /* Error */ | |
4026 return NULL; | |
4027 } | |
4028 else | |
4029 { | |
4030 return result; | |
4031 } | |
4032 } | |
4033 | |
4034 | |
4035 /** | |
4036 * @brief Format a DICOM instance as a JSON string. | |
4037 * | |
4038 * This function formats a DICOM instance that is stored in Orthanc, | |
4039 * and outputs a JSON string representing the tags of this DICOM | |
4040 * instance. | |
4041 * | |
4042 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4043 * @param instanceId The Orthanc identifier of the instance. | |
4044 * @param format The output format. | |
4045 * @param flags Flags governing the output. | |
4046 * @param maxStringLength The maximum length of a field. Too long fields will | |
4047 * be output as "null". The 0 value means no maximum length. | |
4048 * @return The NULL value if the case of an error, or the JSON | |
4049 * string. This string must be freed by OrthancPluginFreeString(). | |
4050 * @ingroup Toolbox | |
4051 * @see OrthancPluginDicomInstanceToJson | |
4052 **/ | |
4053 ORTHANC_PLUGIN_INLINE char* OrthancPluginDicomInstanceToJson( | |
4054 OrthancPluginContext* context, | |
4055 const char* instanceId, | |
4056 OrthancPluginDicomToJsonFormat format, | |
4057 OrthancPluginDicomToJsonFlags flags, | |
4058 uint32_t maxStringLength) | |
4059 { | |
4060 char* result; | |
4061 | |
4062 _OrthancPluginDicomToJson params; | |
4063 memset(¶ms, 0, sizeof(params)); | |
4064 params.result = &result; | |
4065 params.instanceId = instanceId; | |
4066 params.format = format; | |
4067 params.flags = flags; | |
4068 params.maxStringLength = maxStringLength; | |
4069 | |
4070 if (context->InvokeService(context, _OrthancPluginService_DicomInstanceToJson, ¶ms) != OrthancPluginErrorCode_Success) | |
4071 { | |
4072 /* Error */ | |
4073 return NULL; | |
4074 } | |
4075 else | |
4076 { | |
4077 return result; | |
4078 } | |
4079 } | |
4080 | |
4081 | |
4082 typedef struct | |
4083 { | |
4084 OrthancPluginMemoryBuffer* target; | |
4085 const char* uri; | |
4086 uint32_t headersCount; | |
4087 const char* const* headersKeys; | |
4088 const char* const* headersValues; | |
4089 int32_t afterPlugins; | |
4090 } _OrthancPluginRestApiGet2; | |
4091 | |
4092 /** | |
4093 * @brief Make a GET call to the Orthanc REST API, with custom HTTP headers. | |
4094 * | |
4095 * Make a GET call to the Orthanc REST API with extended | |
4096 * parameters. The result to the query is stored into a newly | |
4097 * allocated memory buffer. | |
4098 * | |
4099 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4100 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
4101 * @param uri The URI in the built-in Orthanc API. | |
4102 * @param headersCount The number of HTTP headers. | |
4103 * @param headersKeys Array containing the keys of the HTTP headers. | |
4104 * @param headersValues Array containing the values of the HTTP headers. | |
4105 * @param afterPlugins If 0, the built-in API of Orthanc is used. | |
4106 * If 1, the API is tainted by the plugins. | |
4107 * @return 0 if success, or the error code if failure. | |
4108 * @see OrthancPluginRestApiGet, OrthancPluginRestApiGetAfterPlugins | |
4109 * @ingroup Orthanc | |
4110 **/ | |
4111 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRestApiGet2( | |
4112 OrthancPluginContext* context, | |
4113 OrthancPluginMemoryBuffer* target, | |
4114 const char* uri, | |
4115 uint32_t headersCount, | |
4116 const char* const* headersKeys, | |
4117 const char* const* headersValues, | |
4118 int32_t afterPlugins) | |
4119 { | |
4120 _OrthancPluginRestApiGet2 params; | |
4121 params.target = target; | |
4122 params.uri = uri; | |
4123 params.headersCount = headersCount; | |
4124 params.headersKeys = headersKeys; | |
4125 params.headersValues = headersValues; | |
4126 params.afterPlugins = afterPlugins; | |
4127 | |
4128 return context->InvokeService(context, _OrthancPluginService_RestApiGet2, ¶ms); | |
4129 } | |
4130 | |
4131 | |
4132 | |
4133 typedef struct | |
4134 { | |
4135 OrthancPluginWorklistCallback callback; | |
4136 } _OrthancPluginWorklistCallback; | |
4137 | |
4138 /** | |
4139 * @brief Register a callback to handle modality worklists requests. | |
4140 * | |
4141 * This function registers a callback to handle C-Find SCP requests | |
4142 * on modality worklists. | |
4143 * | |
4144 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4145 * @param callback The callback. | |
4146 * @return 0 if success, other value if error. | |
4147 * @ingroup Worklists | |
4148 **/ | |
4149 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterWorklistCallback( | |
4150 OrthancPluginContext* context, | |
4151 OrthancPluginWorklistCallback callback) | |
4152 { | |
4153 _OrthancPluginWorklistCallback params; | |
4154 params.callback = callback; | |
4155 | |
4156 return context->InvokeService(context, _OrthancPluginService_RegisterWorklistCallback, ¶ms); | |
4157 } | |
4158 | |
4159 | |
4160 | |
4161 typedef struct | |
4162 { | |
4163 OrthancPluginWorklistAnswers* answers; | |
4164 const OrthancPluginWorklistQuery* query; | |
4165 const void* dicom; | |
4166 uint32_t size; | |
4167 } _OrthancPluginWorklistAnswersOperation; | |
4168 | |
4169 /** | |
4170 * @brief Add one answer to some modality worklist request. | |
4171 * | |
4172 * This function adds one worklist (encoded as a DICOM file) to the | |
4173 * set of answers corresponding to some C-Find SCP request against | |
4174 * modality worklists. | |
4175 * | |
4176 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4177 * @param answers The set of answers. | |
4178 * @param query The worklist query, as received by the callback. | |
4179 * @param dicom The worklist to answer, encoded as a DICOM file. | |
4180 * @param size The size of the DICOM file. | |
4181 * @return 0 if success, other value if error. | |
4182 * @ingroup Worklists | |
4183 **/ | |
4184 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistAddAnswer( | |
4185 OrthancPluginContext* context, | |
4186 OrthancPluginWorklistAnswers* answers, | |
4187 const OrthancPluginWorklistQuery* query, | |
4188 const void* dicom, | |
4189 uint32_t size) | |
4190 { | |
4191 _OrthancPluginWorklistAnswersOperation params; | |
4192 params.answers = answers; | |
4193 params.query = query; | |
4194 params.dicom = dicom; | |
4195 params.size = size; | |
4196 | |
4197 return context->InvokeService(context, _OrthancPluginService_WorklistAddAnswer, ¶ms); | |
4198 } | |
4199 | |
4200 | |
4201 /** | |
4202 * @brief Mark the set of worklist answers as incomplete. | |
4203 * | |
4204 * This function marks as incomplete the set of answers | |
4205 * corresponding to some C-Find SCP request against modality | |
4206 * worklists. This must be used if canceling the handling of a | |
4207 * request when too many answers are to be returned. | |
4208 * | |
4209 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4210 * @param answers The set of answers. | |
4211 * @return 0 if success, other value if error. | |
4212 * @ingroup Worklists | |
4213 **/ | |
4214 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistMarkIncomplete( | |
4215 OrthancPluginContext* context, | |
4216 OrthancPluginWorklistAnswers* answers) | |
4217 { | |
4218 _OrthancPluginWorklistAnswersOperation params; | |
4219 params.answers = answers; | |
4220 params.query = NULL; | |
4221 params.dicom = NULL; | |
4222 params.size = 0; | |
4223 | |
4224 return context->InvokeService(context, _OrthancPluginService_WorklistMarkIncomplete, ¶ms); | |
4225 } | |
4226 | |
4227 | |
4228 typedef struct | |
4229 { | |
4230 const OrthancPluginWorklistQuery* query; | |
4231 const void* dicom; | |
4232 uint32_t size; | |
4233 int32_t* isMatch; | |
4234 OrthancPluginMemoryBuffer* target; | |
4235 } _OrthancPluginWorklistQueryOperation; | |
4236 | |
4237 /** | |
4238 * @brief Test whether a worklist matches the query. | |
4239 * | |
4240 * This function checks whether one worklist (encoded as a DICOM | |
4241 * file) matches the C-Find SCP query against modality | |
4242 * worklists. This function must be called before adding the | |
4243 * worklist as an answer through OrthancPluginWorklistAddAnswer(). | |
4244 * | |
4245 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4246 * @param query The worklist query, as received by the callback. | |
4247 * @param dicom The worklist to answer, encoded as a DICOM file. | |
4248 * @param size The size of the DICOM file. | |
4249 * @return 1 if the worklist matches the query, 0 otherwise. | |
4250 * @ingroup Worklists | |
4251 **/ | |
4252 ORTHANC_PLUGIN_INLINE int32_t OrthancPluginWorklistIsMatch( | |
4253 OrthancPluginContext* context, | |
4254 const OrthancPluginWorklistQuery* query, | |
4255 const void* dicom, | |
4256 uint32_t size) | |
4257 { | |
4258 int32_t isMatch = 0; | |
4259 | |
4260 _OrthancPluginWorklistQueryOperation params; | |
4261 params.query = query; | |
4262 params.dicom = dicom; | |
4263 params.size = size; | |
4264 params.isMatch = &isMatch; | |
4265 params.target = NULL; | |
4266 | |
4267 if (context->InvokeService(context, _OrthancPluginService_WorklistIsMatch, ¶ms) == OrthancPluginErrorCode_Success) | |
4268 { | |
4269 return isMatch; | |
4270 } | |
4271 else | |
4272 { | |
4273 /* Error: Assume non-match */ | |
4274 return 0; | |
4275 } | |
4276 } | |
4277 | |
4278 | |
4279 /** | |
4280 * @brief Retrieve the worklist query as a DICOM file. | |
4281 * | |
4282 * This function retrieves the DICOM file that underlies a C-Find | |
4283 * SCP query against modality worklists. | |
4284 * | |
4285 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4286 * @param target Memory buffer where to store the DICOM file. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
4287 * @param query The worklist query, as received by the callback. | |
4288 * @return 0 if success, other value if error. | |
4289 * @ingroup Worklists | |
4290 **/ | |
4291 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginWorklistGetDicomQuery( | |
4292 OrthancPluginContext* context, | |
4293 OrthancPluginMemoryBuffer* target, | |
4294 const OrthancPluginWorklistQuery* query) | |
4295 { | |
4296 _OrthancPluginWorklistQueryOperation params; | |
4297 params.query = query; | |
4298 params.dicom = NULL; | |
4299 params.size = 0; | |
4300 params.isMatch = NULL; | |
4301 params.target = target; | |
4302 | |
4303 return context->InvokeService(context, _OrthancPluginService_WorklistGetDicomQuery, ¶ms); | |
4304 } | |
4305 | |
4306 | |
4307 /** | |
4308 * @brief Get the origin of a DICOM file. | |
4309 * | |
4310 * This function returns the origin of a DICOM instance that has been received by Orthanc. | |
4311 * | |
4312 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4313 * @param instance The instance of interest. | |
4314 * @return The origin of the instance. | |
4315 * @ingroup Callbacks | |
4316 **/ | |
4317 ORTHANC_PLUGIN_INLINE OrthancPluginInstanceOrigin OrthancPluginGetInstanceOrigin( | |
4318 OrthancPluginContext* context, | |
4319 OrthancPluginDicomInstance* instance) | |
4320 { | |
4321 OrthancPluginInstanceOrigin origin; | |
4322 | |
4323 _OrthancPluginAccessDicomInstance params; | |
4324 memset(¶ms, 0, sizeof(params)); | |
4325 params.resultOrigin = &origin; | |
4326 params.instance = instance; | |
4327 | |
4328 if (context->InvokeService(context, _OrthancPluginService_GetInstanceOrigin, ¶ms) != OrthancPluginErrorCode_Success) | |
4329 { | |
4330 /* Error */ | |
4331 return OrthancPluginInstanceOrigin_Unknown; | |
4332 } | |
4333 else | |
4334 { | |
4335 return origin; | |
4336 } | |
4337 } | |
4338 | |
4339 | |
4340 typedef struct | |
4341 { | |
4342 OrthancPluginMemoryBuffer* target; | |
4343 const char* json; | |
4344 const OrthancPluginImage* pixelData; | |
4345 OrthancPluginCreateDicomFlags flags; | |
4346 } _OrthancPluginCreateDicom; | |
4347 | |
4348 /** | |
4349 * @brief Create a DICOM instance from a JSON string and an image. | |
4350 * | |
4351 * This function takes as input a string containing a JSON file | |
4352 * describing the content of a DICOM instance. As an output, it | |
4353 * writes the corresponding DICOM instance to a newly allocated | |
4354 * memory buffer. Additionally, an image to be encoded within the | |
4355 * DICOM instance can also be provided. | |
4356 * | |
4357 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4358 * @param target The target memory buffer. It must be freed with OrthancPluginFreeMemoryBuffer(). | |
4359 * @param json The input JSON file. | |
4360 * @param pixelData The image. Can be NULL, if the pixel data is encoded inside the JSON with the data URI scheme. | |
4361 * @param flags Flags governing the output. | |
4362 * @return 0 if success, other value if error. | |
4363 * @ingroup Toolbox | |
4364 * @see OrthancPluginDicomBufferToJson | |
4365 **/ | |
4366 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginCreateDicom( | |
4367 OrthancPluginContext* context, | |
4368 OrthancPluginMemoryBuffer* target, | |
4369 const char* json, | |
4370 const OrthancPluginImage* pixelData, | |
4371 OrthancPluginCreateDicomFlags flags) | |
4372 { | |
4373 _OrthancPluginCreateDicom params; | |
4374 params.target = target; | |
4375 params.json = json; | |
4376 params.pixelData = pixelData; | |
4377 params.flags = flags; | |
4378 | |
4379 return context->InvokeService(context, _OrthancPluginService_CreateDicom, ¶ms); | |
4380 } | |
4381 | |
4382 | |
4383 typedef struct | |
4384 { | |
4385 OrthancPluginDecodeImageCallback callback; | |
4386 } _OrthancPluginDecodeImageCallback; | |
4387 | |
4388 /** | |
4389 * @brief Register a callback to handle the decoding of DICOM images. | |
4390 * | |
4391 * This function registers a custom callback to the decoding of | |
4392 * DICOM images, replacing the built-in decoder of Orthanc. | |
4393 * | |
4394 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4395 * @param callback The callback. | |
4396 * @return 0 if success, other value if error. | |
4397 * @ingroup Callbacks | |
4398 **/ | |
4399 ORTHANC_PLUGIN_INLINE OrthancPluginErrorCode OrthancPluginRegisterDecodeImageCallback( | |
4400 OrthancPluginContext* context, | |
4401 OrthancPluginDecodeImageCallback callback) | |
4402 { | |
4403 _OrthancPluginDecodeImageCallback params; | |
4404 params.callback = callback; | |
4405 | |
4406 return context->InvokeService(context, _OrthancPluginService_RegisterDecodeImageCallback, ¶ms); | |
4407 } | |
4408 | |
4409 | |
4410 | |
4411 typedef struct | |
4412 { | |
4413 OrthancPluginImage** target; | |
4414 OrthancPluginPixelFormat format; | |
4415 uint32_t width; | |
4416 uint32_t height; | |
4417 uint32_t pitch; | |
4418 void* buffer; | |
4419 const void* constBuffer; | |
4420 uint32_t bufferSize; | |
4421 uint32_t frameIndex; | |
4422 } _OrthancPluginCreateImage; | |
4423 | |
4424 | |
4425 /** | |
4426 * @brief Create an image. | |
4427 * | |
4428 * This function creates an image of given size and format. | |
4429 * | |
4430 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4431 * @param format The format of the pixels. | |
4432 * @param width The width of the image. | |
4433 * @param height The height of the image. | |
4434 * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). | |
4435 * @ingroup Images | |
4436 **/ | |
4437 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImage( | |
4438 OrthancPluginContext* context, | |
4439 OrthancPluginPixelFormat format, | |
4440 uint32_t width, | |
4441 uint32_t height) | |
4442 { | |
4443 OrthancPluginImage* target = NULL; | |
4444 | |
4445 _OrthancPluginCreateImage params; | |
4446 memset(¶ms, 0, sizeof(params)); | |
4447 params.target = ⌖ | |
4448 params.format = format; | |
4449 params.width = width; | |
4450 params.height = height; | |
4451 | |
4452 if (context->InvokeService(context, _OrthancPluginService_CreateImage, ¶ms) != OrthancPluginErrorCode_Success) | |
4453 { | |
4454 return NULL; | |
4455 } | |
4456 else | |
4457 { | |
4458 return target; | |
4459 } | |
4460 } | |
4461 | |
4462 | |
4463 /** | |
4464 * @brief Create an image pointing to a memory buffer. | |
4465 * | |
4466 * This function creates an image whose content points to a memory | |
4467 * buffer managed by the plugin. Note that the buffer is directly | |
4468 * accessed, no memory is allocated and no data is copied. | |
4469 * | |
4470 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4471 * @param format The format of the pixels. | |
4472 * @param width The width of the image. | |
4473 * @param height The height of the image. | |
4474 * @param pitch The pitch of the image (i.e. the number of bytes | |
4475 * between 2 successive lines of the image in the memory buffer). | |
4476 * @param buffer The memory buffer. | |
4477 * @return The newly allocated image. It must be freed with OrthancPluginFreeImage(). | |
4478 * @ingroup Images | |
4479 **/ | |
4480 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginCreateImageAccessor( | |
4481 OrthancPluginContext* context, | |
4482 OrthancPluginPixelFormat format, | |
4483 uint32_t width, | |
4484 uint32_t height, | |
4485 uint32_t pitch, | |
4486 void* buffer) | |
4487 { | |
4488 OrthancPluginImage* target = NULL; | |
4489 | |
4490 _OrthancPluginCreateImage params; | |
4491 memset(¶ms, 0, sizeof(params)); | |
4492 params.target = ⌖ | |
4493 params.format = format; | |
4494 params.width = width; | |
4495 params.height = height; | |
4496 params.pitch = pitch; | |
4497 params.buffer = buffer; | |
4498 | |
4499 if (context->InvokeService(context, _OrthancPluginService_CreateImageAccessor, ¶ms) != OrthancPluginErrorCode_Success) | |
4500 { | |
4501 return NULL; | |
4502 } | |
4503 else | |
4504 { | |
4505 return target; | |
4506 } | |
4507 } | |
4508 | |
4509 | |
4510 | |
4511 /** | |
4512 * @brief Decode one frame from a DICOM instance. | |
4513 * | |
4514 * This function decodes one frame of a DICOM image that is stored | |
4515 * in a memory buffer. This function will give the same result as | |
4516 * OrthancPluginUncompressImage() for single-frame DICOM images. | |
4517 * | |
4518 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4519 * @param buffer Pointer to a memory buffer containing the DICOM image. | |
4520 * @param bufferSize Size of the memory buffer containing the DICOM image. | |
4521 * @param frameIndex The index of the frame of interest in a multi-frame image. | |
4522 * @return The uncompressed image. It must be freed with OrthancPluginFreeImage(). | |
4523 * @ingroup Images | |
4524 **/ | |
4525 ORTHANC_PLUGIN_INLINE OrthancPluginImage* OrthancPluginDecodeDicomImage( | |
4526 OrthancPluginContext* context, | |
4527 const void* buffer, | |
4528 uint32_t bufferSize, | |
4529 uint32_t frameIndex) | |
4530 { | |
4531 OrthancPluginImage* target = NULL; | |
4532 | |
4533 _OrthancPluginCreateImage params; | |
4534 memset(¶ms, 0, sizeof(params)); | |
4535 params.target = ⌖ | |
4536 params.constBuffer = buffer; | |
4537 params.bufferSize = bufferSize; | |
4538 params.frameIndex = frameIndex; | |
4539 | |
4540 if (context->InvokeService(context, _OrthancPluginService_DecodeDicomImage, ¶ms) != OrthancPluginErrorCode_Success) | |
4541 { | |
4542 return NULL; | |
4543 } | |
4544 else | |
4545 { | |
4546 return target; | |
4547 } | |
4548 } | |
4549 | |
4550 | |
4551 | |
4552 typedef struct | |
4553 { | |
4554 char** result; | |
4555 const void* buffer; | |
4556 uint32_t size; | |
4557 } _OrthancPluginComputeHash; | |
4558 | |
4559 /** | |
4560 * @brief Compute an MD5 hash. | |
4561 * | |
4562 * This functions computes the MD5 cryptographic hash of the given memory buffer. | |
4563 * | |
4564 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4565 * @param buffer The source memory buffer. | |
4566 * @param size The size in bytes of the source buffer. | |
4567 * @return The NULL value in case of error, or a string containing the cryptographic hash. | |
4568 * This string must be freed by OrthancPluginFreeString(). | |
4569 * @ingroup Toolbox | |
4570 **/ | |
4571 ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeMd5( | |
4572 OrthancPluginContext* context, | |
4573 const void* buffer, | |
4574 uint32_t size) | |
4575 { | |
4576 char* result; | |
4577 | |
4578 _OrthancPluginComputeHash params; | |
4579 params.result = &result; | |
4580 params.buffer = buffer; | |
4581 params.size = size; | |
4582 | |
4583 if (context->InvokeService(context, _OrthancPluginService_ComputeMd5, ¶ms) != OrthancPluginErrorCode_Success) | |
4584 { | |
4585 /* Error */ | |
4586 return NULL; | |
4587 } | |
4588 else | |
4589 { | |
4590 return result; | |
4591 } | |
4592 } | |
4593 | |
4594 | |
4595 /** | |
4596 * @brief Compute a SHA-1 hash. | |
4597 * | |
4598 * This functions computes the SHA-1 cryptographic hash of the given memory buffer. | |
4599 * | |
4600 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
4601 * @param buffer The source memory buffer. | |
4602 * @param size The size in bytes of the source buffer. | |
4603 * @return The NULL value in case of error, or a string containing the cryptographic hash. | |
4604 * This string must be freed by OrthancPluginFreeString(). | |
4605 * @ingroup Toolbox | |
4606 **/ | |
4607 ORTHANC_PLUGIN_INLINE char* OrthancPluginComputeSha1( | |
4608 OrthancPluginContext* context, | |
4609 const void* buffer, | |
4610 uint32_t size) | |
4611 { | |
4612 char* result; | |
4613 | |
4614 _OrthancPluginComputeHash params; | |
4615 params.result = &result; | |
4616 params.buffer = buffer; | |
4617 params.size = size; | |
4618 | |
4619 if (context->InvokeService(context, _OrthancPluginService_ComputeSha1, ¶ms) != OrthancPluginErrorCode_Success) | |
4620 { | |
4621 /* Error */ | |
4622 return NULL; | |
4623 } | |
4624 else | |
4625 { | |
4626 return result; | |
4627 } | |
4628 } | |
4629 | |
3620 #ifdef __cplusplus | 4630 #ifdef __cplusplus |
3621 } | 4631 } |
3622 #endif | 4632 #endif |
3623 | 4633 |
3624 | 4634 |