comparison Sources/Autogenerated/orthanc.pyi @ 203:28531e615104

documented orthanc.RegisterIncomingHttpRequestFilter() and orthanc.RegisterOnStoredInstanceCallback()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jul 2024 12:03:09 +0200
parents d7a6e75558ee
children 234681297600
comparison
equal deleted inserted replaced
202:ba4dd45ab937 203:28531e615104
1311 Unlimited Text 1311 Unlimited Text
1312 """ 1312 """
1313 UT: int = 27, 1313 UT: int = 27,
1314 1314
1315 1315
1316
1316 # This function returns the MIME type of a file by inspecting its extension 1317 # This function returns the MIME type of a file by inspecting its extension
1317 def AutodetectMimeType(path: str) -> str: 1318 def AutodetectMimeType(path: str) -> str:
1318 """ 1319 """
1319 This function returns the MIME type of a file by inspecting its extension. 1320 This function returns the MIME type of a file by inspecting its extension.
1320 1321
1323 1324
1324 Returns: 1325 Returns:
1325 str: The MIME type. This is a statically-allocated string, do not free it. 1326 str: The MIME type. This is a statically-allocated string, do not free it.
1326 """ 1327 """
1327 ... 1328 ...
1329
1328 # This function compresses or decompresses a buffer, using the version of the zlib library that is used by the Orthanc core 1330 # This function compresses or decompresses a buffer, using the version of the zlib library that is used by the Orthanc core
1329 def BufferCompression(source: bytes, compression: CompressionType, uncompress: int) -> bytes: 1331 def BufferCompression(source: bytes, compression: CompressionType, uncompress: int) -> bytes:
1330 """ 1332 """
1331 This function compresses or decompresses a buffer, using the version of the zlib library that is used by the Orthanc core. 1333 This function compresses or decompresses a buffer, using the version of the zlib library that is used by the Orthanc core.
1332 1334
1337 1339
1338 Returns: 1340 Returns:
1339 bytes: 0 if success, or the error code if failure. 1341 bytes: 0 if success, or the error code if failure.
1340 """ 1342 """
1341 ... 1343 ...
1344
1342 # This function checks whether the version of the Orthanc server running this plugin, is above the version of the current Orthanc SDK header 1345 # This function checks whether the version of the Orthanc server running this plugin, is above the version of the current Orthanc SDK header
1343 def CheckVersion() -> int: 1346 def CheckVersion() -> int:
1344 """ 1347 """
1345 This function checks whether the version of the Orthanc server running this plugin, is above the version of the current Orthanc SDK header. This guarantees that the plugin is compatible with the hosting Orthanc (i.e. it will not call unavailable services). The result of this function should always be checked in the OrthancPluginInitialize() entry point of the plugin. 1348 This function checks whether the version of the Orthanc server running this plugin, is above the version of the current Orthanc SDK header. This guarantees that the plugin is compatible with the hosting Orthanc (i.e. it will not call unavailable services). The result of this function should always be checked in the OrthancPluginInitialize() entry point of the plugin.
1346 1349
1347 Returns: 1350 Returns:
1348 int: 1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail. 1351 int: 1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail.
1349 """ 1352 """
1350 ... 1353 ...
1354
1351 # This function checks whether the version of the Orthanc server running this plugin, is above the given version 1355 # This function checks whether the version of the Orthanc server running this plugin, is above the given version
1352 def CheckVersionAdvanced(expected_major: int, expected_minor: int, expected_revision: int) -> int: 1356 def CheckVersionAdvanced(expected_major: int, expected_minor: int, expected_revision: int) -> int:
1353 """ 1357 """
1354 This function checks whether the version of the Orthanc server running this plugin, is above the given version. Contrarily to OrthancPluginCheckVersion(), it is up to the developer of the plugin to make sure that all the Orthanc SDK services called by the plugin are actually implemented in the given version of Orthanc. 1358 This function checks whether the version of the Orthanc server running this plugin, is above the given version. Contrarily to OrthancPluginCheckVersion(), it is up to the developer of the plugin to make sure that all the Orthanc SDK services called by the plugin are actually implemented in the given version of Orthanc.
1355 1359
1360 1364
1361 Returns: 1365 Returns:
1362 int: 1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail. 1366 int: 1 if and only if the versions are compatible. If the result is 0, the initialization of the plugin should fail.
1363 """ 1367 """
1364 ... 1368 ...
1369
1365 # This function compresses the given memory buffer containing an image using the JPEG specification, and stores the result of the compression into a newly allocated memory buffer 1370 # This function compresses the given memory buffer containing an image using the JPEG specification, and stores the result of the compression into a newly allocated memory buffer
1366 def CompressJpegImage(format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes, quality: int) -> bytes: 1371 def CompressJpegImage(format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes, quality: int) -> bytes:
1367 """ 1372 """
1368 This function compresses the given memory buffer containing an image using the JPEG specification, and stores the result of the compression into a newly allocated memory buffer. 1373 This function compresses the given memory buffer containing an image using the JPEG specification, and stores the result of the compression into a newly allocated memory buffer.
1369 1374
1377 1382
1378 Returns: 1383 Returns:
1379 bytes: 0 if success, or the error code if failure. 1384 bytes: 0 if success, or the error code if failure.
1380 """ 1385 """
1381 ... 1386 ...
1387
1382 # This function compresses the given memory buffer containing an image using the PNG specification, and stores the result of the compression into a newly allocated memory buffer 1388 # This function compresses the given memory buffer containing an image using the PNG specification, and stores the result of the compression into a newly allocated memory buffer
1383 def CompressPngImage(format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes) -> bytes: 1389 def CompressPngImage(format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes) -> bytes:
1384 """ 1390 """
1385 This function compresses the given memory buffer containing an image using the PNG specification, and stores the result of the compression into a newly allocated memory buffer. 1391 This function compresses the given memory buffer containing an image using the PNG specification, and stores the result of the compression into a newly allocated memory buffer.
1386 1392
1393 1399
1394 Returns: 1400 Returns:
1395 bytes: 0 if success, or the error code if failure. 1401 bytes: 0 if success, or the error code if failure.
1396 """ 1402 """
1397 ... 1403 ...
1404
1398 # This functions computes the MD5 cryptographic hash of the given memory buffer 1405 # This functions computes the MD5 cryptographic hash of the given memory buffer
1399 def ComputeMd5(buffer: bytes) -> str: 1406 def ComputeMd5(buffer: bytes) -> str:
1400 """ 1407 """
1401 This functions computes the MD5 cryptographic hash of the given memory buffer. 1408 This functions computes the MD5 cryptographic hash of the given memory buffer.
1402 1409
1405 1412
1406 Returns: 1413 Returns:
1407 str: The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString(). 1414 str: The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString().
1408 """ 1415 """
1409 ... 1416 ...
1417
1410 # This functions computes the SHA-1 cryptographic hash of the given memory buffer 1418 # This functions computes the SHA-1 cryptographic hash of the given memory buffer
1411 def ComputeSha1(buffer: bytes) -> str: 1419 def ComputeSha1(buffer: bytes) -> str:
1412 """ 1420 """
1413 This functions computes the SHA-1 cryptographic hash of the given memory buffer. 1421 This functions computes the SHA-1 cryptographic hash of the given memory buffer.
1414 1422
1417 1425
1418 Returns: 1426 Returns:
1419 str: The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString(). 1427 str: The NULL value in case of error, or a string containing the cryptographic hash. This string must be freed by OrthancPluginFreeString().
1420 """ 1428 """
1421 ... 1429 ...
1430
1422 # This function takes as input a string containing a JSON file describing the content of a DICOM instance 1431 # This function takes as input a string containing a JSON file describing the content of a DICOM instance
1423 def CreateDicom(json: str, pixel_data: Image, flags: CreateDicomFlags) -> bytes: 1432 def CreateDicom(json: str, pixel_data: Image, flags: CreateDicomFlags) -> bytes:
1424 """ 1433 """
1425 This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided. 1434 This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided.
1426 Private tags will be associated with the private creator whose value is specified in the "DefaultPrivateCreator" configuration option of Orthanc. The function OrthancPluginCreateDicom2() can be used if another private creator must be used to create this instance. 1435 Private tags will be associated with the private creator whose value is specified in the "DefaultPrivateCreator" configuration option of Orthanc. The function OrthancPluginCreateDicom2() can be used if another private creator must be used to create this instance.
1432 1441
1433 Returns: 1442 Returns:
1434 bytes: 0 if success, other value if error. 1443 bytes: 0 if success, other value if error.
1435 """ 1444 """
1436 ... 1445 ...
1446
1437 # This function takes as input a string containing a JSON file describing the content of a DICOM instance 1447 # This function takes as input a string containing a JSON file describing the content of a DICOM instance
1438 def CreateDicom2(json: str, pixel_data: Image, flags: CreateDicomFlags, private_creator: str) -> bytes: 1448 def CreateDicom2(json: str, pixel_data: Image, flags: CreateDicomFlags, private_creator: str) -> bytes:
1439 """ 1449 """
1440 This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided. 1450 This function takes as input a string containing a JSON file describing the content of a DICOM instance. As an output, it writes the corresponding DICOM instance to a newly allocated memory buffer. Additionally, an image to be encoded within the DICOM instance can also be provided.
1441 Contrarily to the function OrthancPluginCreateDicom(), this function can be explicitly provided with a private creator. 1451 Contrarily to the function OrthancPluginCreateDicom(), this function can be explicitly provided with a private creator.
1448 1458
1449 Returns: 1459 Returns:
1450 bytes: 0 if success, other value if error. 1460 bytes: 0 if success, other value if error.
1451 """ 1461 """
1452 ... 1462 ...
1463
1453 # This function parses a memory buffer that contains a DICOM file 1464 # This function parses a memory buffer that contains a DICOM file
1454 def CreateDicomInstance(buffer: bytes) -> DicomInstance: 1465 def CreateDicomInstance(buffer: bytes) -> DicomInstance:
1455 """ 1466 """
1456 This function parses a memory buffer that contains a DICOM file. The function returns a new pointer to a data structure that is managed by the Orthanc core. 1467 This function parses a memory buffer that contains a DICOM file. The function returns a new pointer to a data structure that is managed by the Orthanc core.
1457 1468
1460 1471
1461 Returns: 1472 Returns:
1462 DicomInstance: The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). 1473 DicomInstance: The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance().
1463 """ 1474 """
1464 ... 1475 ...
1476
1465 # This function creates a "matcher" object that can be used to check whether a DICOM instance matches a C-Find query 1477 # This function creates a "matcher" object that can be used to check whether a DICOM instance matches a C-Find query
1466 def CreateFindMatcher(query: bytes) -> FindMatcher: 1478 def CreateFindMatcher(query: bytes) -> FindMatcher:
1467 """ 1479 """
1468 This function creates a "matcher" object that can be used to check whether a DICOM instance matches a C-Find query. The C-Find query must be expressed as a DICOM buffer. 1480 This function creates a "matcher" object that can be used to check whether a DICOM instance matches a C-Find query. The C-Find query must be expressed as a DICOM buffer.
1469 1481
1472 1484
1473 Returns: 1485 Returns:
1474 FindMatcher: The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher(). 1486 FindMatcher: The newly allocated matcher. It must be freed with OrthancPluginFreeFindMatcher().
1475 """ 1487 """
1476 ... 1488 ...
1489
1477 # This function creates an image of given size and format 1490 # This function creates an image of given size and format
1478 def CreateImage(format: PixelFormat, width: int, height: int) -> Image: 1491 def CreateImage(format: PixelFormat, width: int, height: int) -> Image:
1479 """ 1492 """
1480 This function creates an image of given size and format. 1493 This function creates an image of given size and format.
1481 1494
1486 1499
1487 Returns: 1500 Returns:
1488 Image: The newly allocated image. It must be freed with OrthancPluginFreeImage(). 1501 Image: The newly allocated image. It must be freed with OrthancPluginFreeImage().
1489 """ 1502 """
1490 ... 1503 ...
1504
1491 # This function decodes one frame of a DICOM image that is stored in a memory buffer 1505 # This function decodes one frame of a DICOM image that is stored in a memory buffer
1492 def DecodeDicomImage(buffer: bytes, frame_index: int) -> Image: 1506 def DecodeDicomImage(buffer: bytes, frame_index: int) -> Image:
1493 """ 1507 """
1494 This function decodes one frame of a DICOM image that is stored in a memory buffer. This function will give the same result as OrthancPluginUncompressImage() for single-frame DICOM images. 1508 This function decodes one frame of a DICOM image that is stored in a memory buffer. This function will give the same result as OrthancPluginUncompressImage() for single-frame DICOM images.
1495 1509
1499 1513
1500 Returns: 1514 Returns:
1501 Image: The uncompressed image. It must be freed with OrthancPluginFreeImage(). 1515 Image: The uncompressed image. It must be freed with OrthancPluginFreeImage().
1502 """ 1516 """
1503 ... 1517 ...
1518
1504 # This function takes as input a memory buffer containing a DICOM file, and outputs a JSON string representing the tags of this DICOM file 1519 # This function takes as input a memory buffer containing a DICOM file, and outputs a JSON string representing the tags of this DICOM file
1505 def DicomBufferToJson(buffer: bytes, format: DicomToJsonFormat, flags: DicomToJsonFlags, max_string_length: int) -> str: 1520 def DicomBufferToJson(buffer: bytes, format: DicomToJsonFormat, flags: DicomToJsonFlags, max_string_length: int) -> str:
1506 """ 1521 """
1507 This function takes as input a memory buffer containing a DICOM file, and outputs a JSON string representing the tags of this DICOM file. 1522 This function takes as input a memory buffer containing a DICOM file, and outputs a JSON string representing the tags of this DICOM file.
1508 1523
1514 1529
1515 Returns: 1530 Returns:
1516 str: The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString(). 1531 str: The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString().
1517 """ 1532 """
1518 ... 1533 ...
1534
1519 # This function formats a DICOM instance that is stored in Orthanc, and outputs a JSON string representing the tags of this DICOM instance 1535 # This function formats a DICOM instance that is stored in Orthanc, and outputs a JSON string representing the tags of this DICOM instance
1520 def DicomInstanceToJson(instance_id: str, format: DicomToJsonFormat, flags: DicomToJsonFlags, max_string_length: int) -> str: 1536 def DicomInstanceToJson(instance_id: str, format: DicomToJsonFormat, flags: DicomToJsonFlags, max_string_length: int) -> str:
1521 """ 1537 """
1522 This function formats a DICOM instance that is stored in Orthanc, and outputs a JSON string representing the tags of this DICOM instance. 1538 This function formats a DICOM instance that is stored in Orthanc, and outputs a JSON string representing the tags of this DICOM instance.
1523 1539
1529 1545
1530 Returns: 1546 Returns:
1531 str: The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString(). 1547 str: The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString().
1532 """ 1548 """
1533 ... 1549 ...
1550
1534 # Add JavaScript code to customize the default behavior of Orthanc Explorer 1551 # Add JavaScript code to customize the default behavior of Orthanc Explorer
1535 def ExtendOrthancExplorer(javascript: str) -> None: 1552 def ExtendOrthancExplorer(javascript: str) -> None:
1536 """ 1553 """
1537 Add JavaScript code to customize the default behavior of Orthanc Explorer. This can for instance be used to add new buttons. 1554 Add JavaScript code to customize the default behavior of Orthanc Explorer. This can for instance be used to add new buttons.
1538 1555
1539 Args: 1556 Args:
1540 javascript (str): The custom JavaScript code. 1557 javascript (str): The custom JavaScript code.
1541 """ 1558 """
1542 ... 1559 ...
1560
1543 # This function generates a token that can be set in the HTTP header "Authorization" so as to grant full access to the REST API of Orthanc using an external HTTP client 1561 # This function generates a token that can be set in the HTTP header "Authorization" so as to grant full access to the REST API of Orthanc using an external HTTP client
1544 def GenerateRestApiAuthorizationToken() -> str: 1562 def GenerateRestApiAuthorizationToken() -> str:
1545 """ 1563 """
1546 This function generates a token that can be set in the HTTP header "Authorization" so as to grant full access to the REST API of Orthanc using an external HTTP client. Using this function avoids the need of adding a separate user in the "RegisteredUsers" configuration of Orthanc, which eases deployments. 1564 This function generates a token that can be set in the HTTP header "Authorization" so as to grant full access to the REST API of Orthanc using an external HTTP client. Using this function avoids the need of adding a separate user in the "RegisteredUsers" configuration of Orthanc, which eases deployments.
1547 This feature is notably useful in multiprocess scenarios, where a subprocess created by a plugin has no access to the "OrthancPluginContext", and thus cannot call "OrthancPluginRestApi[Get|Post|Put|Delete]()". 1565 This feature is notably useful in multiprocess scenarios, where a subprocess created by a plugin has no access to the "OrthancPluginContext", and thus cannot call "OrthancPluginRestApi[Get|Post|Put|Delete]()".
1549 1567
1550 Returns: 1568 Returns:
1551 str: The authorization token, or NULL value in the case of an error. This string must be freed by OrthancPluginFreeString(). 1569 str: The authorization token, or NULL value in the case of an error. This string must be freed by OrthancPluginFreeString().
1552 """ 1570 """
1553 ... 1571 ...
1572
1554 # Generate a random GUID/UUID (globally unique identifier) 1573 # Generate a random GUID/UUID (globally unique identifier)
1555 def GenerateUuid() -> str: 1574 def GenerateUuid() -> str:
1556 """ 1575 """
1557 Generate a random GUID/UUID (globally unique identifier). 1576 Generate a random GUID/UUID (globally unique identifier).
1558 1577
1559 Returns: 1578 Returns:
1560 str: NULL in the case of an error, or a newly allocated string containing the UUID. This string must be freed by OrthancPluginFreeString(). 1579 str: NULL in the case of an error, or a newly allocated string containing the UUID. This string must be freed by OrthancPluginFreeString().
1561 """ 1580 """
1562 ... 1581 ...
1582
1563 # Get the value of one of the command-line arguments that were used to launch Orthanc 1583 # Get the value of one of the command-line arguments that were used to launch Orthanc
1564 def GetCommandLineArgument(argument: int) -> str: 1584 def GetCommandLineArgument(argument: int) -> str:
1565 """ 1585 """
1566 Get the value of one of the command-line arguments that were used to launch Orthanc. The number of available arguments can be retrieved by OrthancPluginGetCommandLineArgumentsCount(). 1586 Get the value of one of the command-line arguments that were used to launch Orthanc. The number of available arguments can be retrieved by OrthancPluginGetCommandLineArgumentsCount().
1567 1587
1570 1590
1571 Returns: 1591 Returns:
1572 str: The value of the argument, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString(). 1592 str: The value of the argument, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString().
1573 """ 1593 """
1574 ... 1594 ...
1595
1575 # Retrieve the number of command-line arguments that were used to launch Orthanc 1596 # Retrieve the number of command-line arguments that were used to launch Orthanc
1576 def GetCommandLineArgumentsCount() -> int: 1597 def GetCommandLineArgumentsCount() -> int:
1577 """ 1598 """
1578 Retrieve the number of command-line arguments that were used to launch Orthanc. 1599 Retrieve the number of command-line arguments that were used to launch Orthanc.
1579 1600
1580 Returns: 1601 Returns:
1581 int: The number of arguments. 1602 int: The number of arguments.
1582 """ 1603 """
1583 ... 1604 ...
1605
1584 # This function returns the content of the configuration that is used by Orthanc, formatted as a JSON string 1606 # This function returns the content of the configuration that is used by Orthanc, formatted as a JSON string
1585 def GetConfiguration() -> str: 1607 def GetConfiguration() -> str:
1586 """ 1608 """
1587 This function returns the content of the configuration that is used by Orthanc, formatted as a JSON string. 1609 This function returns the content of the configuration that is used by Orthanc, formatted as a JSON string.
1588 1610
1589 Returns: 1611 Returns:
1590 str: NULL in the case of an error, or a newly allocated string containing the configuration. This string must be freed by OrthancPluginFreeString(). 1612 str: NULL in the case of an error, or a newly allocated string containing the configuration. This string must be freed by OrthancPluginFreeString().
1591 """ 1613 """
1592 ... 1614 ...
1615
1593 # This function returns the path to the configuration file(s) that was specified when starting Orthanc 1616 # This function returns the path to the configuration file(s) that was specified when starting Orthanc
1594 def GetConfigurationPath() -> str: 1617 def GetConfigurationPath() -> str:
1595 """ 1618 """
1596 This function returns the path to the configuration file(s) that was specified when starting Orthanc. Since version 0.9.1, this path can refer to a folder that stores a set of configuration files. This function is deprecated in favor of OrthancPluginGetConfiguration(). 1619 This function returns the path to the configuration file(s) that was specified when starting Orthanc. Since version 0.9.1, this path can refer to a folder that stores a set of configuration files. This function is deprecated in favor of OrthancPluginGetConfiguration().
1597 1620
1598 Returns: 1621 Returns:
1599 str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString(). 1622 str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().
1600 """ 1623 """
1601 ... 1624 ...
1625
1602 # Retrieve a DICOM instance using its Orthanc identifier 1626 # Retrieve a DICOM instance using its Orthanc identifier
1603 def GetDicomForInstance(instance_id: str) -> bytes: 1627 def GetDicomForInstance(instance_id: str) -> bytes:
1604 """ 1628 """
1605 Retrieve a DICOM instance using its Orthanc identifier. The DICOM file is stored into a newly allocated memory buffer. 1629 Retrieve a DICOM instance using its Orthanc identifier. The DICOM file is stored into a newly allocated memory buffer.
1606 1630
1609 1633
1610 Returns: 1634 Returns:
1611 bytes: 0 if success, or the error code if failure. 1635 bytes: 0 if success, or the error code if failure.
1612 """ 1636 """
1613 ... 1637 ...
1638
1614 # This function returns the description of a given error code 1639 # This function returns the description of a given error code
1615 def GetErrorDescription(error: ErrorCode) -> str: 1640 def GetErrorDescription(error: ErrorCode) -> str:
1616 """ 1641 """
1617 This function returns the description of a given error code. 1642 This function returns the description of a given error code.
1618 1643
1621 1646
1622 Returns: 1647 Returns:
1623 str: The error description. This is a statically-allocated string, do not free it. 1648 str: The error description. This is a statically-allocated string, do not free it.
1624 """ 1649 """
1625 ... 1650 ...
1651
1626 # Retrieve the expected version of the database schema 1652 # Retrieve the expected version of the database schema
1627 def GetExpectedDatabaseVersion() -> int: 1653 def GetExpectedDatabaseVersion() -> int:
1628 """ 1654 """
1629 Retrieve the expected version of the database schema. 1655 Retrieve the expected version of the database schema.
1630 1656
1631 Returns: 1657 Returns:
1632 int: The version. 1658 int: The version.
1633 """ 1659 """
1634 ... 1660 ...
1661
1635 # This function returns the name of a font that is built in the Orthanc core 1662 # This function returns the name of a font that is built in the Orthanc core
1636 def GetFontName(font_index: int) -> str: 1663 def GetFontName(font_index: int) -> str:
1637 """ 1664 """
1638 This function returns the name of a font that is built in the Orthanc core. 1665 This function returns the name of a font that is built in the Orthanc core.
1639 1666
1642 1669
1643 Returns: 1670 Returns:
1644 str: The font name. This is a statically-allocated string, do not free it. 1671 str: The font name. This is a statically-allocated string, do not free it.
1645 """ 1672 """
1646 ... 1673 ...
1674
1647 # This function returns the size of a font that is built in the Orthanc core 1675 # This function returns the size of a font that is built in the Orthanc core
1648 def GetFontSize(font_index: int) -> int: 1676 def GetFontSize(font_index: int) -> int:
1649 """ 1677 """
1650 This function returns the size of a font that is built in the Orthanc core. 1678 This function returns the size of a font that is built in the Orthanc core.
1651 1679
1654 1682
1655 Returns: 1683 Returns:
1656 int: The font size. 1684 int: The font size.
1657 """ 1685 """
1658 ... 1686 ...
1687
1659 # This function returns the number of fonts that are built in the Orthanc core 1688 # This function returns the number of fonts that are built in the Orthanc core
1660 def GetFontsCount() -> int: 1689 def GetFontsCount() -> int:
1661 """ 1690 """
1662 This function returns the number of fonts that are built in the Orthanc core. These fonts can be used to draw texts on images through OrthancPluginDrawText(). 1691 This function returns the number of fonts that are built in the Orthanc core. These fonts can be used to draw texts on images through OrthancPluginDrawText().
1663 1692
1664 Returns: 1693 Returns:
1665 int: The number of fonts. 1694 int: The number of fonts.
1666 """ 1695 """
1667 ... 1696 ...
1697
1668 # Get the value of a global property that is stored in the Orthanc database 1698 # Get the value of a global property that is stored in the Orthanc database
1669 def GetGlobalProperty(property: int, default_value: str) -> str: 1699 def GetGlobalProperty(property: int, default_value: str) -> str:
1670 """ 1700 """
1671 Get the value of a global property that is stored in the Orthanc database. Global properties whose index is below 1024 are reserved by Orthanc. 1701 Get the value of a global property that is stored in the Orthanc database. Global properties whose index is below 1024 are reserved by Orthanc.
1672 1702
1676 1706
1677 Returns: 1707 Returns:
1678 str: The value of the global property, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString(). 1708 str: The value of the global property, or NULL in the case of an error. This string must be freed by OrthancPluginFreeString().
1679 """ 1709 """
1680 ... 1710 ...
1711
1681 # This function returns the path to the directory containing the Orthanc executable 1712 # This function returns the path to the directory containing the Orthanc executable
1682 def GetOrthancDirectory() -> str: 1713 def GetOrthancDirectory() -> str:
1683 """ 1714 """
1684 This function returns the path to the directory containing the Orthanc executable. 1715 This function returns the path to the directory containing the Orthanc executable.
1685 1716
1686 Returns: 1717 Returns:
1687 str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString(). 1718 str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().
1688 """ 1719 """
1689 ... 1720 ...
1721
1690 # This function returns the path to the Orthanc executable 1722 # This function returns the path to the Orthanc executable
1691 def GetOrthancPath() -> str: 1723 def GetOrthancPath() -> str:
1692 """ 1724 """
1693 This function returns the path to the Orthanc executable. 1725 This function returns the path to the Orthanc executable.
1694 1726
1695 Returns: 1727 Returns:
1696 str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString(). 1728 str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().
1697 """ 1729 """
1698 ... 1730 ...
1731
1699 # This function returns the parameters of the Orthanc peers that are known to the Orthanc server hosting the plugin 1732 # This function returns the parameters of the Orthanc peers that are known to the Orthanc server hosting the plugin
1700 def GetPeers() -> Peers: 1733 def GetPeers() -> Peers:
1701 """ 1734 """
1702 This function returns the parameters of the Orthanc peers that are known to the Orthanc server hosting the plugin. 1735 This function returns the parameters of the Orthanc peers that are known to the Orthanc server hosting the plugin.
1703 1736
1704 Returns: 1737 Returns:
1705 Peers: NULL if error, or a newly allocated opaque data structure containing the peers. This structure must be freed with OrthancPluginFreePeers(). 1738 Peers: NULL if error, or a newly allocated opaque data structure containing the peers. This structure must be freed with OrthancPluginFreePeers().
1706 """ 1739 """
1707 ... 1740 ...
1741
1708 # This function makes a lookup to the dictionary of DICOM tags that are known to Orthanc, and returns the symbolic name of a DICOM tag 1742 # This function makes a lookup to the dictionary of DICOM tags that are known to Orthanc, and returns the symbolic name of a DICOM tag
1709 def GetTagName(group: int, element: int, private_creator: str) -> str: 1743 def GetTagName(group: int, element: int, private_creator: str) -> str:
1710 """ 1744 """
1711 This function makes a lookup to the dictionary of DICOM tags that are known to Orthanc, and returns the symbolic name of a DICOM tag. 1745 This function makes a lookup to the dictionary of DICOM tags that are known to Orthanc, and returns the symbolic name of a DICOM tag.
1712 1746
1717 1751
1718 Returns: 1752 Returns:
1719 str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString(). 1753 str: NULL in the case of an error, or a newly allocated string containing the path. This string must be freed by OrthancPluginFreeString().
1720 """ 1754 """
1721 ... 1755 ...
1756
1722 # Make a HTTP DELETE call to the given URL 1757 # Make a HTTP DELETE call to the given URL
1723 def HttpDelete(url: str, username: str, password: str) -> None: 1758 def HttpDelete(url: str, username: str, password: str) -> None:
1724 """ 1759 """
1725 Make a HTTP DELETE call to the given URL. Favor OrthancPluginRestApiDelete() if calling the built-in REST API of the Orthanc instance that hosts this plugin. 1760 Make a HTTP DELETE call to the given URL. Favor OrthancPluginRestApiDelete() if calling the built-in REST API of the Orthanc instance that hosts this plugin.
1726 1761
1728 url (str): The URL of interest. 1763 url (str): The URL of interest.
1729 username (str): The username (can be "NULL" if no password protection). 1764 username (str): The username (can be "NULL" if no password protection).
1730 password (str): The password (can be "NULL" if no password protection). 1765 password (str): The password (can be "NULL" if no password protection).
1731 """ 1766 """
1732 ... 1767 ...
1768
1733 # Make a HTTP GET call to the given URL 1769 # Make a HTTP GET call to the given URL
1734 def HttpGet(url: str, username: str, password: str) -> bytes: 1770 def HttpGet(url: str, username: str, password: str) -> bytes:
1735 """ 1771 """
1736 Make a HTTP GET call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiGet() if calling the built-in REST API of the Orthanc instance that hosts this plugin. 1772 Make a HTTP GET call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiGet() if calling the built-in REST API of the Orthanc instance that hosts this plugin.
1737 1773
1742 1778
1743 Returns: 1779 Returns:
1744 bytes: 0 if success, or the error code if failure. 1780 bytes: 0 if success, or the error code if failure.
1745 """ 1781 """
1746 ... 1782 ...
1783
1747 # Make a HTTP POST call to the given URL 1784 # Make a HTTP POST call to the given URL
1748 def HttpPost(url: str, body: bytes, username: str, password: str) -> bytes: 1785 def HttpPost(url: str, body: bytes, username: str, password: str) -> bytes:
1749 """ 1786 """
1750 Make a HTTP POST call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPost() if calling the built-in REST API of the Orthanc instance that hosts this plugin. 1787 Make a HTTP POST call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPost() if calling the built-in REST API of the Orthanc instance that hosts this plugin.
1751 1788
1757 1794
1758 Returns: 1795 Returns:
1759 bytes: 0 if success, or the error code if failure. 1796 bytes: 0 if success, or the error code if failure.
1760 """ 1797 """
1761 ... 1798 ...
1799
1762 # Make a HTTP PUT call to the given URL 1800 # Make a HTTP PUT call to the given URL
1763 def HttpPut(url: str, body: bytes, username: str, password: str) -> bytes: 1801 def HttpPut(url: str, body: bytes, username: str, password: str) -> bytes:
1764 """ 1802 """
1765 Make a HTTP PUT call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPut() if calling the built-in REST API of the Orthanc instance that hosts this plugin. 1803 Make a HTTP PUT call to the given URL. The result to the query is stored into a newly allocated memory buffer. Favor OrthancPluginRestApiPut() if calling the built-in REST API of the Orthanc instance that hosts this plugin.
1766 1804
1772 1810
1773 Returns: 1811 Returns:
1774 bytes: 0 if success, or the error code if failure. 1812 bytes: 0 if success, or the error code if failure.
1775 """ 1813 """
1776 ... 1814 ...
1815
1777 # Log an error message using the Orthanc logging system 1816 # Log an error message using the Orthanc logging system
1778 def LogError(message: str) -> None: 1817 def LogError(message: str) -> None:
1779 """ 1818 """
1780 Log an error message using the Orthanc logging system. 1819 Log an error message using the Orthanc logging system.
1781 1820
1782 Args: 1821 Args:
1783 message (str): The message to be logged. 1822 message (str): The message to be logged.
1784 """ 1823 """
1785 ... 1824 ...
1825
1786 # Log an information message using the Orthanc logging system 1826 # Log an information message using the Orthanc logging system
1787 def LogInfo(message: str) -> None: 1827 def LogInfo(message: str) -> None:
1788 """ 1828 """
1789 Log an information message using the Orthanc logging system. 1829 Log an information message using the Orthanc logging system.
1790 1830
1791 Args: 1831 Args:
1792 message (str): The message to be logged. 1832 message (str): The message to be logged.
1793 """ 1833 """
1794 ... 1834 ...
1835
1795 # Log a warning message using the Orthanc logging system 1836 # Log a warning message using the Orthanc logging system
1796 def LogWarning(message: str) -> None: 1837 def LogWarning(message: str) -> None:
1797 """ 1838 """
1798 Log a warning message using the Orthanc logging system. 1839 Log a warning message using the Orthanc logging system.
1799 1840
1800 Args: 1841 Args:
1801 message (str): The message to be logged. 1842 message (str): The message to be logged.
1802 """ 1843 """
1803 ... 1844 ...
1845
1804 # Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018) 1846 # Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018)
1805 def LookupInstance(sop_instance_u_i_d: str) -> str: 1847 def LookupInstance(sop_instance_u_i_d: str) -> str:
1806 """ 1848 """
1807 Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). This function uses the database index to run as fast as possible (it does not loop over all the stored instances). 1849 Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018). This function uses the database index to run as fast as possible (it does not loop over all the stored instances).
1808 1850
1811 1853
1812 Returns: 1854 Returns:
1813 str: The NULL value if the instance is non-existent, or a string containing the Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString(). 1855 str: The NULL value if the instance is non-existent, or a string containing the Orthanc ID of the instance. This string must be freed by OrthancPluginFreeString().
1814 """ 1856 """
1815 ... 1857 ...
1858
1816 # Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020) 1859 # Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020)
1817 def LookupPatient(patient_i_d: str) -> str: 1860 def LookupPatient(patient_i_d: str) -> str:
1818 """ 1861 """
1819 Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). This function uses the database index to run as fast as possible (it does not loop over all the stored patients). 1862 Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020). This function uses the database index to run as fast as possible (it does not loop over all the stored patients).
1820 1863
1823 1866
1824 Returns: 1867 Returns:
1825 str: The NULL value if the patient is non-existent, or a string containing the Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString(). 1868 str: The NULL value if the patient is non-existent, or a string containing the Orthanc ID of the patient. This string must be freed by OrthancPluginFreeString().
1826 """ 1869 """
1827 ... 1870 ...
1871
1828 # Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e) 1872 # Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e)
1829 def LookupSeries(series_u_i_d: str) -> str: 1873 def LookupSeries(series_u_i_d: str) -> str:
1830 """ 1874 """
1831 Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). This function uses the database index to run as fast as possible (it does not loop over all the stored series). 1875 Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e). This function uses the database index to run as fast as possible (it does not loop over all the stored series).
1832 1876
1835 1879
1836 Returns: 1880 Returns:
1837 str: The NULL value if the series is non-existent, or a string containing the Orthanc ID of the series. This string must be freed by OrthancPluginFreeString(). 1881 str: The NULL value if the series is non-existent, or a string containing the Orthanc ID of the series. This string must be freed by OrthancPluginFreeString().
1838 """ 1882 """
1839 ... 1883 ...
1884
1840 # Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d) 1885 # Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d)
1841 def LookupStudy(study_u_i_d: str) -> str: 1886 def LookupStudy(study_u_i_d: str) -> str:
1842 """ 1887 """
1843 Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). This function uses the database index to run as fast as possible (it does not loop over all the stored studies). 1888 Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d). This function uses the database index to run as fast as possible (it does not loop over all the stored studies).
1844 1889
1847 1892
1848 Returns: 1893 Returns:
1849 str: The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). 1894 str: The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().
1850 """ 1895 """
1851 ... 1896 ...
1897
1852 # Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050) 1898 # Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050)
1853 def LookupStudyWithAccessionNumber(accession_number: str) -> str: 1899 def LookupStudyWithAccessionNumber(accession_number: str) -> str:
1854 """ 1900 """
1855 Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050). This function uses the database index to run as fast as possible (it does not loop over all the stored studies). 1901 Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050). This function uses the database index to run as fast as possible (it does not loop over all the stored studies).
1856 1902
1859 1905
1860 Returns: 1906 Returns:
1861 str: The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString(). 1907 str: The NULL value if the study is non-existent, or a string containing the Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().
1862 """ 1908 """
1863 ... 1909 ...
1910
1864 # Read the content of a file on the filesystem, and returns it into a newly allocated memory buffer 1911 # Read the content of a file on the filesystem, and returns it into a newly allocated memory buffer
1865 def ReadFile(path: str) -> bytes: 1912 def ReadFile(path: str) -> bytes:
1866 """ 1913 """
1867 Read the content of a file on the filesystem, and returns it into a newly allocated memory buffer. 1914 Read the content of a file on the filesystem, and returns it into a newly allocated memory buffer.
1868 1915
1871 1918
1872 Returns: 1919 Returns:
1873 bytes: 0 if success, or the error code if failure. 1920 bytes: 0 if success, or the error code if failure.
1874 """ 1921 """
1875 ... 1922 ...
1923
1876 # This function declares a new public tag in the dictionary of DICOM tags that are known to Orthanc 1924 # This function declares a new public tag in the dictionary of DICOM tags that are known to Orthanc
1877 def RegisterDictionaryTag(group: int, element: int, vr: ValueRepresentation, name: str, min_multiplicity: int, max_multiplicity: int) -> None: 1925 def RegisterDictionaryTag(group: int, element: int, vr: ValueRepresentation, name: str, min_multiplicity: int, max_multiplicity: int) -> None:
1878 """ 1926 """
1879 This function declares a new public tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback. 1927 This function declares a new public tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback.
1880 1928
1885 name (str): The nickname of the tag. 1933 name (str): The nickname of the tag.
1886 min_multiplicity (int): The minimum multiplicity of the tag (must be above 0). 1934 min_multiplicity (int): The minimum multiplicity of the tag (must be above 0).
1887 max_multiplicity (int): The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (""n""). 1935 max_multiplicity (int): The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (""n"").
1888 """ 1936 """
1889 ... 1937 ...
1938
1890 # This function declares a custom error code that can be generated by this plugin 1939 # This function declares a custom error code that can be generated by this plugin
1891 def RegisterErrorCode(code: int, http_status: int, message: str) -> None: 1940 def RegisterErrorCode(code: int, http_status: int, message: str) -> None:
1892 """ 1941 """
1893 This function declares a custom error code that can be generated by this plugin. This declaration is used to enrich the body of the HTTP answer in the case of an error, and to set the proper HTTP status code. 1942 This function declares a custom error code that can be generated by this plugin. This declaration is used to enrich the body of the HTTP answer in the case of an error, and to set the proper HTTP status code.
1894 1943
1896 code (int): The error code that is internal to this plugin. 1945 code (int): The error code that is internal to this plugin.
1897 http_status (int): The HTTP status corresponding to this error. 1946 http_status (int): The HTTP status corresponding to this error.
1898 message (str): The description of the error. 1947 message (str): The description of the error.
1899 """ 1948 """
1900 ... 1949 ...
1950
1901 # This function declares a new private tag in the dictionary of DICOM tags that are known to Orthanc 1951 # This function declares a new private tag in the dictionary of DICOM tags that are known to Orthanc
1902 def RegisterPrivateDictionaryTag(group: int, element: int, vr: ValueRepresentation, name: str, min_multiplicity: int, max_multiplicity: int, private_creator: str) -> None: 1952 def RegisterPrivateDictionaryTag(group: int, element: int, vr: ValueRepresentation, name: str, min_multiplicity: int, max_multiplicity: int, private_creator: str) -> None:
1903 """ 1953 """
1904 This function declares a new private tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback. 1954 This function declares a new private tag in the dictionary of DICOM tags that are known to Orthanc. This function should be used in the OrthancPluginInitialize() callback.
1905 1955
1911 min_multiplicity (int): The minimum multiplicity of the tag (must be above 0). 1961 min_multiplicity (int): The minimum multiplicity of the tag (must be above 0).
1912 max_multiplicity (int): The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (""n""). 1962 max_multiplicity (int): The maximum multiplicity of the tag. A value of 0 means an arbitrary multiplicity (""n"").
1913 private_creator (str): The private creator of this private tag. 1963 private_creator (str): The private creator of this private tag.
1914 """ 1964 """
1915 ... 1965 ...
1966
1916 # Make a DELETE call to the built-in Orthanc REST API 1967 # Make a DELETE call to the built-in Orthanc REST API
1917 def RestApiDelete(uri: str) -> None: 1968 def RestApiDelete(uri: str) -> None:
1918 """ 1969 """
1919 Make a DELETE call to the built-in Orthanc REST API. 1970 Make a DELETE call to the built-in Orthanc REST API.
1920 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. 1971 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
1921 1972
1922 Args: 1973 Args:
1923 uri (str): The URI to delete in the built-in Orthanc API. 1974 uri (str): The URI to delete in the built-in Orthanc API.
1924 """ 1975 """
1925 ... 1976 ...
1977
1926 # Make a DELETE call to the Orthanc REST API, after all the plugins are applied 1978 # Make a DELETE call to the Orthanc REST API, after all the plugins are applied
1927 def RestApiDeleteAfterPlugins(uri: str) -> None: 1979 def RestApiDeleteAfterPlugins(uri: str) -> None:
1928 """ 1980 """
1929 Make a DELETE call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. 1981 Make a DELETE call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin.
1930 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. 1982 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
1931 1983
1932 Args: 1984 Args:
1933 uri (str): The URI to delete in the built-in Orthanc API. 1985 uri (str): The URI to delete in the built-in Orthanc API.
1934 """ 1986 """
1935 ... 1987 ...
1988
1936 # Make a GET call to the built-in Orthanc REST API 1989 # Make a GET call to the built-in Orthanc REST API
1937 def RestApiGet(uri: str) -> bytes: 1990 def RestApiGet(uri: str) -> bytes:
1938 """ 1991 """
1939 Make a GET call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer. 1992 Make a GET call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer.
1940 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. 1993 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
1944 1997
1945 Returns: 1998 Returns:
1946 bytes: 0 if success, or the error code if failure. 1999 bytes: 0 if success, or the error code if failure.
1947 """ 2000 """
1948 ... 2001 ...
2002
1949 # Make a GET call to the Orthanc REST API, after all the plugins are applied 2003 # Make a GET call to the Orthanc REST API, after all the plugins are applied
1950 def RestApiGetAfterPlugins(uri: str) -> bytes: 2004 def RestApiGetAfterPlugins(uri: str) -> bytes:
1951 """ 2005 """
1952 Make a GET call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer. 2006 Make a GET call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer.
1953 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. 2007 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
1957 2011
1958 Returns: 2012 Returns:
1959 bytes: 0 if success, or the error code if failure. 2013 bytes: 0 if success, or the error code if failure.
1960 """ 2014 """
1961 ... 2015 ...
2016
1962 # Make a POST call to the built-in Orthanc REST API 2017 # Make a POST call to the built-in Orthanc REST API
1963 def RestApiPost(uri: str, body: bytes) -> bytes: 2018 def RestApiPost(uri: str, body: bytes) -> bytes:
1964 """ 2019 """
1965 Make a POST call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer. 2020 Make a POST call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer.
1966 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. 2021 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
1971 2026
1972 Returns: 2027 Returns:
1973 bytes: 0 if success, or the error code if failure. 2028 bytes: 0 if success, or the error code if failure.
1974 """ 2029 """
1975 ... 2030 ...
2031
1976 # Make a POST call to the Orthanc REST API, after all the plugins are applied 2032 # Make a POST call to the Orthanc REST API, after all the plugins are applied
1977 def RestApiPostAfterPlugins(uri: str, body: bytes) -> bytes: 2033 def RestApiPostAfterPlugins(uri: str, body: bytes) -> bytes:
1978 """ 2034 """
1979 Make a POST call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer. 2035 Make a POST call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer.
1980 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. 2036 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
1985 2041
1986 Returns: 2042 Returns:
1987 bytes: 0 if success, or the error code if failure. 2043 bytes: 0 if success, or the error code if failure.
1988 """ 2044 """
1989 ... 2045 ...
2046
1990 # Make a PUT call to the built-in Orthanc REST API 2047 # Make a PUT call to the built-in Orthanc REST API
1991 def RestApiPut(uri: str, body: bytes) -> bytes: 2048 def RestApiPut(uri: str, body: bytes) -> bytes:
1992 """ 2049 """
1993 Make a PUT call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer. 2050 Make a PUT call to the built-in Orthanc REST API. The result to the query is stored into a newly allocated memory buffer.
1994 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. 2051 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
1999 2056
2000 Returns: 2057 Returns:
2001 bytes: 0 if success, or the error code if failure. 2058 bytes: 0 if success, or the error code if failure.
2002 """ 2059 """
2003 ... 2060 ...
2061
2004 # Make a PUT call to the Orthanc REST API, after all the plugins are applied 2062 # Make a PUT call to the Orthanc REST API, after all the plugins are applied
2005 def RestApiPutAfterPlugins(uri: str, body: bytes) -> bytes: 2063 def RestApiPutAfterPlugins(uri: str, body: bytes) -> bytes:
2006 """ 2064 """
2007 Make a PUT call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer. 2065 Make a PUT call to the Orthanc REST API, after all the plugins are applied. In other words, if some plugin overrides or adds the called URI to the built-in Orthanc REST API, this call will return the result provided by this plugin. The result to the query is stored into a newly allocated memory buffer.
2008 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource. 2066 Remark: If the resource is not existing (error 404), the error code will be OrthancPluginErrorCode_UnknownResource.
2013 2071
2014 Returns: 2072 Returns:
2015 bytes: 0 if success, or the error code if failure. 2073 bytes: 0 if success, or the error code if failure.
2016 """ 2074 """
2017 ... 2075 ...
2076
2018 # Set a description for this plugin 2077 # Set a description for this plugin
2019 def SetDescription(description: str) -> None: 2078 def SetDescription(description: str) -> None:
2020 """ 2079 """
2021 Set a description for this plugin. It is displayed in the "Plugins" page of Orthanc Explorer. 2080 Set a description for this plugin. It is displayed in the "Plugins" page of Orthanc Explorer.
2022 2081
2023 Args: 2082 Args:
2024 description (str): The description. 2083 description (str): The description.
2025 """ 2084 """
2026 ... 2085 ...
2086
2027 # Set the value of a global property into the Orthanc database 2087 # Set the value of a global property into the Orthanc database
2028 def SetGlobalProperty(property: int, value: str) -> None: 2088 def SetGlobalProperty(property: int, value: str) -> None:
2029 """ 2089 """
2030 Set the value of a global property into the Orthanc database. Setting a global property can be used by plugins to save their internal parameters. Plugins are only allowed to set properties whose index are above or equal to 1024 (properties below 1024 are read-only and reserved by Orthanc). 2090 Set the value of a global property into the Orthanc database. Setting a global property can be used by plugins to save their internal parameters. Plugins are only allowed to set properties whose index are above or equal to 1024 (properties below 1024 are read-only and reserved by Orthanc).
2031 2091
2032 Args: 2092 Args:
2033 property (int): The global property of interest. 2093 property (int): The global property of interest.
2034 value (str): The value to be set in the global property. 2094 value (str): The value to be set in the global property.
2035 """ 2095 """
2036 ... 2096 ...
2097
2037 # This function sets the value of a metrics to monitor the behavior of the plugin through tools such as Prometheus 2098 # This function sets the value of a metrics to monitor the behavior of the plugin through tools such as Prometheus
2038 def SetMetricsValue(name: str, value: float, type: MetricsType) -> None: 2099 def SetMetricsValue(name: str, value: float, type: MetricsType) -> None:
2039 """ 2100 """
2040 This function sets the value of a metrics to monitor the behavior of the plugin through tools such as Prometheus. The values of all the metrics are stored within the Orthanc context. 2101 This function sets the value of a metrics to monitor the behavior of the plugin through tools such as Prometheus. The values of all the metrics are stored within the Orthanc context.
2041 2102
2043 name (str): The name of the metrics to be set. 2104 name (str): The name of the metrics to be set.
2044 value (float): The value of the metrics. 2105 value (float): The value of the metrics.
2045 type (MetricsType): The type of the metrics. This parameter is only taken into consideration the first time this metrics is set. 2106 type (MetricsType): The type of the metrics. This parameter is only taken into consideration the first time this metrics is set.
2046 """ 2107 """
2047 ... 2108 ...
2109
2048 # For plugins that come with a Web interface, this function declares the entry path where to find this interface 2110 # For plugins that come with a Web interface, this function declares the entry path where to find this interface
2049 def SetRootUri(uri: str) -> None: 2111 def SetRootUri(uri: str) -> None:
2050 """ 2112 """
2051 For plugins that come with a Web interface, this function declares the entry path where to find this interface. This information is notably used in the "Plugins" page of Orthanc Explorer. 2113 For plugins that come with a Web interface, this function declares the entry path where to find this interface. This information is notably used in the "Plugins" page of Orthanc Explorer.
2052 2114
2053 Args: 2115 Args:
2054 uri (str): The root URI for this plugin. 2116 uri (str): The root URI for this plugin.
2055 """ 2117 """
2056 ... 2118 ...
2119
2057 # This function parses a memory buffer that contains a DICOM file, then transcodes it to the given transfer syntax 2120 # This function parses a memory buffer that contains a DICOM file, then transcodes it to the given transfer syntax
2058 def TranscodeDicomInstance(buffer: bytes, transfer_syntax: str) -> DicomInstance: 2121 def TranscodeDicomInstance(buffer: bytes, transfer_syntax: str) -> DicomInstance:
2059 """ 2122 """
2060 This function parses a memory buffer that contains a DICOM file, then transcodes it to the given transfer syntax. The function returns a new pointer to a data structure that is managed by the Orthanc core. 2123 This function parses a memory buffer that contains a DICOM file, then transcodes it to the given transfer syntax. The function returns a new pointer to a data structure that is managed by the Orthanc core.
2061 2124
2065 2128
2066 Returns: 2129 Returns:
2067 DicomInstance: The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance(). 2130 DicomInstance: The newly allocated DICOM instance. It must be freed with OrthancPluginFreeDicomInstance().
2068 """ 2131 """
2069 ... 2132 ...
2133
2070 # This function decodes a compressed image from a memory buffer 2134 # This function decodes a compressed image from a memory buffer
2071 def UncompressImage(data: bytes, format: ImageFormat) -> Image: 2135 def UncompressImage(data: bytes, format: ImageFormat) -> Image:
2072 """ 2136 """
2073 This function decodes a compressed image from a memory buffer. 2137 This function decodes a compressed image from a memory buffer.
2074 2138
2078 2142
2079 Returns: 2143 Returns:
2080 Image: The uncompressed image. It must be freed with OrthancPluginFreeImage(). 2144 Image: The uncompressed image. It must be freed with OrthancPluginFreeImage().
2081 """ 2145 """
2082 ... 2146 ...
2147
2083 # Write the content of a memory buffer to the filesystem 2148 # Write the content of a memory buffer to the filesystem
2084 def WriteFile(path: str, data: bytes) -> None: 2149 def WriteFile(path: str, data: bytes) -> None:
2085 """ 2150 """
2086 Write the content of a memory buffer to the filesystem. 2151 Write the content of a memory buffer to the filesystem.
2087 2152
2088 Args: 2153 Args:
2089 path (str): The path of the file to be written. 2154 path (str): The path of the file to be written.
2090 data (bytes): The content of the memory buffer. 2155 data (bytes): The content of the memory buffer.
2091 """ 2156 """
2092 ... 2157 ...
2158
2159 class IncomingHttpRequestFilter(typing.Protocol):
2160 def __call__(self, uri: str, method: HttpMethod, ip: str, headers: dict, get: dict) -> bool:
2161 ...
2162
2163 # Callback to filter incoming HTTP requests received by Orthanc
2164 def RegisterIncomingHttpRequestFilter(callback: IncomingHttpRequestFilter) -> None:
2165 """
2166 Callback to filter incoming HTTP requests received by Orthanc.
2167
2168 Args:
2169 callback (IncomingHttpRequestFilter): The callback function.
2170 """
2171 ...
2172
2173 class OnChangeCallback(typing.Protocol):
2174 def __call__(self, change_type: ChangeType, resource_type: ResourceType, resource_id: str) -> None:
2175 ...
2176
2093 # Register a callback to monitor changes 2177 # Register a callback to monitor changes
2094 def RegisterOnChangeCallback(callback: typing.Callable[[ChangeType, ResourceType, str], None]) -> None: 2178 def RegisterOnChangeCallback(callback: OnChangeCallback) -> None:
2095 """ 2179 """
2096 Register a callback to monitor changes. 2180 Register a callback to monitor changes.
2097 2181
2098 Args: 2182 Args:
2099 callback (typing.Callable[[ChangeType, ResourceType, str], None]): The callback function. 2183 callback (OnChangeCallback): The callback function.
2100 """ 2184 """
2101 ... 2185 ...
2186
2187 class OnStoredInstanceCallback(typing.Protocol):
2188 def __call__(self, instance: DicomInstance, instance_id: str) -> None:
2189 ...
2190
2191 # Register a callback for received DICOM instances
2192 def RegisterOnStoredInstanceCallback(callback: OnStoredInstanceCallback) -> None:
2193 """
2194 Register a callback for received DICOM instances.
2195
2196 Args:
2197 callback (OnStoredInstanceCallback): The callback function.
2198 """
2199 ...
2200
2201 class RestCallback(typing.Protocol):
2202 def __call__(self, output: RestOutput, url: str, method: HttpMethod, groups: dict, get: dict, headers: dict, body: bytes=None) -> None:
2203 ...
2204
2102 # Register a REST callback 2205 # Register a REST callback
2103 def RegisterRestCallback(path_regular_expression: str, callback: typing.Callable[[RestOutput, str], None]) -> None: 2206 def RegisterRestCallback(path_regular_expression: str, callback: RestCallback) -> None:
2104 """ 2207 """
2105 Register a REST callback. 2208 Register a REST callback.
2106 2209
2107 Args: 2210 Args:
2108 path_regular_expression (str): Regular expression for the URI. May contain groups. 2211 path_regular_expression (str): Regular expression for the URI. May contain groups.
2109 callback (typing.Callable[[RestOutput, str], None]): The callback function to handle the REST call. 2212 callback (RestCallback): The callback function to handle the REST call.
2110 """ 2213 """
2111 ... 2214 ...
2112 2215
2113 2216
2114 class DicomInstance: 2217 class DicomInstance:
2115 """ 2218 """
2116 DICOM instance managed by the Orthanc core 2219 DICOM instance managed by the Orthanc core
2117 """ 2220 """
2118 ... 2221 ...
2119 2222
2223
2120 # This function returns the Application Entity Title (AET) of the DICOM modality from which a DICOM instance originates 2224 # This function returns the Application Entity Title (AET) of the DICOM modality from which a DICOM instance originates
2121 def GetInstanceRemoteAet(self) -> str: 2225 def GetInstanceRemoteAet(self) -> str:
2122 """ 2226 """
2123 This function returns the Application Entity Title (AET) of the DICOM modality from which a DICOM instance originates. 2227 This function returns the Application Entity Title (AET) of the DICOM modality from which a DICOM instance originates.
2124 2228
2125 Returns: 2229 Returns:
2126 str: The AET if success, NULL if error. 2230 str: The AET if success, NULL if error.
2127 """ 2231 """
2128 ... 2232 ...
2233
2129 # This function returns the number of bytes of the given DICOM instance 2234 # This function returns the number of bytes of the given DICOM instance
2130 def GetInstanceSize(self) -> int: 2235 def GetInstanceSize(self) -> int:
2131 """ 2236 """
2132 This function returns the number of bytes of the given DICOM instance. 2237 This function returns the number of bytes of the given DICOM instance.
2133 2238
2134 Returns: 2239 Returns:
2135 int: The size of the file, -1 in case of error. 2240 int: The size of the file, -1 in case of error.
2136 """ 2241 """
2137 ... 2242 ...
2243
2138 # This function returns a pointer to a newly created string containing a JSON file 2244 # This function returns a pointer to a newly created string containing a JSON file
2139 def GetInstanceJson(self) -> str: 2245 def GetInstanceJson(self) -> str:
2140 """ 2246 """
2141 This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance. 2247 This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance.
2142 2248
2143 Returns: 2249 Returns:
2144 str: The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString(). 2250 str: The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString().
2145 """ 2251 """
2146 ... 2252 ...
2253
2147 # This function returns a pointer to a newly created string containing a JSON file 2254 # This function returns a pointer to a newly created string containing a JSON file
2148 def GetInstanceSimplifiedJson(self) -> str: 2255 def GetInstanceSimplifiedJson(self) -> str:
2149 """ 2256 """
2150 This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance. In contrast with ::OrthancPluginGetInstanceJson(), the returned JSON file is in its simplified version. 2257 This function returns a pointer to a newly created string containing a JSON file. This JSON file encodes the tag hierarchy of the given DICOM instance. In contrast with ::OrthancPluginGetInstanceJson(), the returned JSON file is in its simplified version.
2151 2258
2152 Returns: 2259 Returns:
2153 str: The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString(). 2260 str: The NULL value in case of error, or a string containing the JSON file. This string must be freed by OrthancPluginFreeString().
2154 """ 2261 """
2155 ... 2262 ...
2263
2156 # This function checks whether the DICOM instance of interest is associated with some metadata 2264 # This function checks whether the DICOM instance of interest is associated with some metadata
2157 def HasInstanceMetadata(self, metadata: str) -> int: 2265 def HasInstanceMetadata(self, metadata: str) -> int:
2158 """ 2266 """
2159 This function checks whether the DICOM instance of interest is associated with some metadata. As of Orthanc 0.8.1, in the callbacks registered by ::OrthancPluginRegisterOnStoredInstanceCallback(), the only possibly available metadata are "ReceptionDate", "RemoteAET" and "IndexInSeries". 2267 This function checks whether the DICOM instance of interest is associated with some metadata. As of Orthanc 0.8.1, in the callbacks registered by ::OrthancPluginRegisterOnStoredInstanceCallback(), the only possibly available metadata are "ReceptionDate", "RemoteAET" and "IndexInSeries".
2160 2268
2163 2271
2164 Returns: 2272 Returns:
2165 int: 1 if the metadata is present, 0 if it is absent, -1 in case of error. 2273 int: 1 if the metadata is present, 0 if it is absent, -1 in case of error.
2166 """ 2274 """
2167 ... 2275 ...
2276
2168 # This functions returns the value of some metadata that is associated with the DICOM instance of interest 2277 # This functions returns the value of some metadata that is associated with the DICOM instance of interest
2169 def GetInstanceMetadata(self, metadata: str) -> str: 2278 def GetInstanceMetadata(self, metadata: str) -> str:
2170 """ 2279 """
2171 This functions returns the value of some metadata that is associated with the DICOM instance of interest. Before calling this function, the existence of the metadata must have been checked with ::OrthancPluginHasInstanceMetadata(). 2280 This functions returns the value of some metadata that is associated with the DICOM instance of interest. Before calling this function, the existence of the metadata must have been checked with ::OrthancPluginHasInstanceMetadata().
2172 2281
2175 2284
2176 Returns: 2285 Returns:
2177 str: The metadata value if success, NULL if error. Please note that the returned string belongs to the instance object and must NOT be deallocated. Please make a copy of the string if you wish to access it later. 2286 str: The metadata value if success, NULL if error. Please note that the returned string belongs to the instance object and must NOT be deallocated. Please make a copy of the string if you wish to access it later.
2178 """ 2287 """
2179 ... 2288 ...
2289
2180 # This function returns the origin of a DICOM instance that has been received by Orthanc 2290 # This function returns the origin of a DICOM instance that has been received by Orthanc
2181 def GetInstanceOrigin(self) -> InstanceOrigin: 2291 def GetInstanceOrigin(self) -> InstanceOrigin:
2182 """ 2292 """
2183 This function returns the origin of a DICOM instance that has been received by Orthanc. 2293 This function returns the origin of a DICOM instance that has been received by Orthanc.
2184 2294
2185 Returns: 2295 Returns:
2186 InstanceOrigin: The origin of the instance. 2296 InstanceOrigin: The origin of the instance.
2187 """ 2297 """
2188 ... 2298 ...
2299
2189 # This function returns a pointer to a newly created string that contains the transfer syntax UID of the DICOM instance 2300 # This function returns a pointer to a newly created string that contains the transfer syntax UID of the DICOM instance
2190 def GetInstanceTransferSyntaxUid(self) -> str: 2301 def GetInstanceTransferSyntaxUid(self) -> str:
2191 """ 2302 """
2192 This function returns a pointer to a newly created string that contains the transfer syntax UID of the DICOM instance. The empty string might be returned if this information is unknown. 2303 This function returns a pointer to a newly created string that contains the transfer syntax UID of the DICOM instance. The empty string might be returned if this information is unknown.
2193 2304
2194 Returns: 2305 Returns:
2195 str: The NULL value in case of error, or a string containing the transfer syntax UID. This string must be freed by OrthancPluginFreeString(). 2306 str: The NULL value in case of error, or a string containing the transfer syntax UID. This string must be freed by OrthancPluginFreeString().
2196 """ 2307 """
2197 ... 2308 ...
2309
2198 # This function returns a Boolean value indicating whether the DICOM instance contains the pixel data (7FE0,0010) tag 2310 # This function returns a Boolean value indicating whether the DICOM instance contains the pixel data (7FE0,0010) tag
2199 def HasInstancePixelData(self) -> int: 2311 def HasInstancePixelData(self) -> int:
2200 """ 2312 """
2201 This function returns a Boolean value indicating whether the DICOM instance contains the pixel data (7FE0,0010) tag. 2313 This function returns a Boolean value indicating whether the DICOM instance contains the pixel data (7FE0,0010) tag.
2202 2314
2203 Returns: 2315 Returns:
2204 int: "1" if the DICOM instance contains pixel data, or "0" if the tag is missing, or "-1" in the case of an error. 2316 int: "1" if the DICOM instance contains pixel data, or "0" if the tag is missing, or "-1" in the case of an error.
2205 """ 2317 """
2206 ... 2318 ...
2319
2207 # This function returns the number of frames that are part of a DICOM image managed by the Orthanc core 2320 # This function returns the number of frames that are part of a DICOM image managed by the Orthanc core
2208 def GetInstanceFramesCount(self) -> int: 2321 def GetInstanceFramesCount(self) -> int:
2209 """ 2322 """
2210 This function returns the number of frames that are part of a DICOM image managed by the Orthanc core. 2323 This function returns the number of frames that are part of a DICOM image managed by the Orthanc core.
2211 2324
2212 Returns: 2325 Returns:
2213 int: The number of frames (will be zero in the case of an error). 2326 int: The number of frames (will be zero in the case of an error).
2214 """ 2327 """
2215 ... 2328 ...
2329
2216 # This function returns a memory buffer containing the raw content of a frame in a DICOM instance that is managed by the Orthanc core 2330 # This function returns a memory buffer containing the raw content of a frame in a DICOM instance that is managed by the Orthanc core
2217 def GetInstanceRawFrame(self, frame_index: int) -> bytes: 2331 def GetInstanceRawFrame(self, frame_index: int) -> bytes:
2218 """ 2332 """
2219 This function returns a memory buffer containing the raw content of a frame in a DICOM instance that is managed by the Orthanc core. This is notably useful for compressed transfer syntaxes, as it gives access to the embedded files (such as JPEG, JPEG-LS or JPEG2k). The Orthanc core transparently reassembles the fragments to extract the raw frame. 2333 This function returns a memory buffer containing the raw content of a frame in a DICOM instance that is managed by the Orthanc core. This is notably useful for compressed transfer syntaxes, as it gives access to the embedded files (such as JPEG, JPEG-LS or JPEG2k). The Orthanc core transparently reassembles the fragments to extract the raw frame.
2220 2334
2223 2337
2224 Returns: 2338 Returns:
2225 bytes: 0 if success, or the error code if failure. 2339 bytes: 0 if success, or the error code if failure.
2226 """ 2340 """
2227 ... 2341 ...
2342
2228 # This function decodes one frame of a DICOM image that is managed by the Orthanc core 2343 # This function decodes one frame of a DICOM image that is managed by the Orthanc core
2229 def GetInstanceDecodedFrame(self, frame_index: int) -> Image: 2344 def GetInstanceDecodedFrame(self, frame_index: int) -> Image:
2230 """ 2345 """
2231 This function decodes one frame of a DICOM image that is managed by the Orthanc core. 2346 This function decodes one frame of a DICOM image that is managed by the Orthanc core.
2232 2347
2235 2350
2236 Returns: 2351 Returns:
2237 Image: The uncompressed image. It must be freed with OrthancPluginFreeImage(). 2352 Image: The uncompressed image. It must be freed with OrthancPluginFreeImage().
2238 """ 2353 """
2239 ... 2354 ...
2355
2240 # This function returns a memory buffer containing the serialization of a DICOM instance that is managed by the Orthanc core 2356 # This function returns a memory buffer containing the serialization of a DICOM instance that is managed by the Orthanc core
2241 def SerializeDicomInstance(self) -> bytes: 2357 def SerializeDicomInstance(self) -> bytes:
2242 """ 2358 """
2243 This function returns a memory buffer containing the serialization of a DICOM instance that is managed by the Orthanc core. 2359 This function returns a memory buffer containing the serialization of a DICOM instance that is managed by the Orthanc core.
2244 2360
2245 Returns: 2361 Returns:
2246 bytes: 0 if success, or the error code if failure. 2362 bytes: 0 if success, or the error code if failure.
2247 """ 2363 """
2248 ... 2364 ...
2365
2249 # This function takes as DICOM instance managed by the Orthanc core, and outputs a JSON string representing the tags of this DICOM file 2366 # This function takes as DICOM instance managed by the Orthanc core, and outputs a JSON string representing the tags of this DICOM file
2250 def GetInstanceAdvancedJson(self, format: DicomToJsonFormat, flags: DicomToJsonFlags, max_string_length: int) -> str: 2367 def GetInstanceAdvancedJson(self, format: DicomToJsonFormat, flags: DicomToJsonFlags, max_string_length: int) -> str:
2251 """ 2368 """
2252 This function takes as DICOM instance managed by the Orthanc core, and outputs a JSON string representing the tags of this DICOM file. 2369 This function takes as DICOM instance managed by the Orthanc core, and outputs a JSON string representing the tags of this DICOM file.
2253 2370
2259 Returns: 2376 Returns:
2260 str: The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString(). 2377 str: The NULL value if the case of an error, or the JSON string. This string must be freed by OrthancPluginFreeString().
2261 """ 2378 """
2262 ... 2379 ...
2263 2380
2381
2264 # Get the content of the DICOM instance 2382 # Get the content of the DICOM instance
2265 def GetInstanceData(self) -> bytes: 2383 def GetInstanceData(self) -> bytes:
2266 """ 2384 """
2267 Get the content of the DICOM instance. 2385 Get the content of the DICOM instance.
2268 2386
2281 """ 2399 """
2282 Answers to a DICOM C-FIND query 2400 Answers to a DICOM C-FIND query
2283 """ 2401 """
2284 ... 2402 ...
2285 2403
2404
2286 # This function adds one answer (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request that is not related to modality worklists 2405 # This function adds one answer (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request that is not related to modality worklists
2287 def FindAddAnswer(self, dicom: bytes) -> None: 2406 def FindAddAnswer(self, dicom: bytes) -> None:
2288 """ 2407 """
2289 This function adds one answer (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request that is not related to modality worklists. 2408 This function adds one answer (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request that is not related to modality worklists.
2290 2409
2291 Args: 2410 Args:
2292 dicom (bytes): The answer to be added, encoded as a DICOM file. 2411 dicom (bytes): The answer to be added, encoded as a DICOM file.
2293 """ 2412 """
2294 ... 2413 ...
2414
2295 # This function marks as incomplete the set of answers corresponding to some C-Find SCP request that is not related to modality worklists 2415 # This function marks as incomplete the set of answers corresponding to some C-Find SCP request that is not related to modality worklists
2296 def FindMarkIncomplete(self) -> None: 2416 def FindMarkIncomplete(self) -> None:
2297 """ 2417 """
2298 This function marks as incomplete the set of answers corresponding to some C-Find SCP request that is not related to modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned. 2418 This function marks as incomplete the set of answers corresponding to some C-Find SCP request that is not related to modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned.
2299 """ 2419 """
2303 """ 2423 """
2304 Matcher for DICOM C-FIND query 2424 Matcher for DICOM C-FIND query
2305 """ 2425 """
2306 ... 2426 ...
2307 2427
2428
2308 # This function checks whether one DICOM instance matches C-Find matcher that was previously allocated using OrthancPluginCreateFindMatcher() 2429 # This function checks whether one DICOM instance matches C-Find matcher that was previously allocated using OrthancPluginCreateFindMatcher()
2309 def FindMatcherIsMatch(self, dicom: bytes) -> int: 2430 def FindMatcherIsMatch(self, dicom: bytes) -> int:
2310 """ 2431 """
2311 This function checks whether one DICOM instance matches C-Find matcher that was previously allocated using OrthancPluginCreateFindMatcher(). 2432 This function checks whether one DICOM instance matches C-Find matcher that was previously allocated using OrthancPluginCreateFindMatcher().
2312 2433
2322 """ 2443 """
2323 DICOM C-FIND query 2444 DICOM C-FIND query
2324 """ 2445 """
2325 ... 2446 ...
2326 2447
2448
2327 # This function returns the number of tags that are contained in the given C-Find query 2449 # This function returns the number of tags that are contained in the given C-Find query
2328 def GetFindQuerySize(self) -> int: 2450 def GetFindQuerySize(self) -> int:
2329 """ 2451 """
2330 This function returns the number of tags that are contained in the given C-Find query. 2452 This function returns the number of tags that are contained in the given C-Find query.
2331 2453
2332 Returns: 2454 Returns:
2333 int: The number of tags. 2455 int: The number of tags.
2334 """ 2456 """
2335 ... 2457 ...
2458
2336 # This function returns the symbolic name of one DICOM tag in the given C-Find query 2459 # This function returns the symbolic name of one DICOM tag in the given C-Find query
2337 def GetFindQueryTagName(self, index: int) -> str: 2460 def GetFindQueryTagName(self, index: int) -> str:
2338 """ 2461 """
2339 This function returns the symbolic name of one DICOM tag in the given C-Find query. 2462 This function returns the symbolic name of one DICOM tag in the given C-Find query.
2340 2463
2343 2466
2344 Returns: 2467 Returns:
2345 str: 0 if success, other value if error. 2468 str: 0 if success, other value if error.
2346 """ 2469 """
2347 ... 2470 ...
2471
2348 # This function returns the value associated with one tag in the given C-Find query 2472 # This function returns the value associated with one tag in the given C-Find query
2349 def GetFindQueryValue(self, index: int) -> str: 2473 def GetFindQueryValue(self, index: int) -> str:
2350 """ 2474 """
2351 This function returns the value associated with one tag in the given C-Find query. 2475 This function returns the value associated with one tag in the given C-Find query.
2352 2476
2356 Returns: 2480 Returns:
2357 str: 0 if success, other value if error. 2481 str: 0 if success, other value if error.
2358 """ 2482 """
2359 ... 2483 ...
2360 2484
2485
2361 # This function returns the element of one DICOM tag in the given C-Find query 2486 # This function returns the element of one DICOM tag in the given C-Find query
2362 def GetFindQueryTagElement(self, index: int) -> int: 2487 def GetFindQueryTagElement(self, index: int) -> int:
2363 """ 2488 """
2364 This function returns the element of one DICOM tag in the given C-Find query. 2489 This function returns the element of one DICOM tag in the given C-Find query.
2365 2490
2368 2493
2369 Returns: 2494 Returns:
2370 int: The value of the element. 2495 int: The value of the element.
2371 """ 2496 """
2372 ... 2497 ...
2498
2373 # This function returns the group of one DICOM tag in the given C-Find query 2499 # This function returns the group of one DICOM tag in the given C-Find query
2374 def GetFindQueryTagGroup(self, index: int) -> int: 2500 def GetFindQueryTagGroup(self, index: int) -> int:
2375 """ 2501 """
2376 This function returns the group of one DICOM tag in the given C-Find query. 2502 This function returns the group of one DICOM tag in the given C-Find query.
2377 2503
2386 """ 2512 """
2387 2D image managed by the Orthanc core 2513 2D image managed by the Orthanc core
2388 """ 2514 """
2389 ... 2515 ...
2390 2516
2517
2391 # This function returns the type of memory layout for the pixels of the given image 2518 # This function returns the type of memory layout for the pixels of the given image
2392 def GetImagePixelFormat(self) -> PixelFormat: 2519 def GetImagePixelFormat(self) -> PixelFormat:
2393 """ 2520 """
2394 This function returns the type of memory layout for the pixels of the given image. 2521 This function returns the type of memory layout for the pixels of the given image.
2395 2522
2396 Returns: 2523 Returns:
2397 PixelFormat: The pixel format. 2524 PixelFormat: The pixel format.
2398 """ 2525 """
2399 ... 2526 ...
2527
2400 # This function returns the width of the given image 2528 # This function returns the width of the given image
2401 def GetImageWidth(self) -> int: 2529 def GetImageWidth(self) -> int:
2402 """ 2530 """
2403 This function returns the width of the given image. 2531 This function returns the width of the given image.
2404 2532
2405 Returns: 2533 Returns:
2406 int: The width. 2534 int: The width.
2407 """ 2535 """
2408 ... 2536 ...
2537
2409 # This function returns the height of the given image 2538 # This function returns the height of the given image
2410 def GetImageHeight(self) -> int: 2539 def GetImageHeight(self) -> int:
2411 """ 2540 """
2412 This function returns the height of the given image. 2541 This function returns the height of the given image.
2413 2542
2414 Returns: 2543 Returns:
2415 int: The height. 2544 int: The height.
2416 """ 2545 """
2417 ... 2546 ...
2547
2418 # This function returns the pitch of the given image 2548 # This function returns the pitch of the given image
2419 def GetImagePitch(self) -> int: 2549 def GetImagePitch(self) -> int:
2420 """ 2550 """
2421 This function returns the pitch of the given image. The pitch is defined as the number of bytes between 2 successive lines of the image in the memory buffer. 2551 This function returns the pitch of the given image. The pitch is defined as the number of bytes between 2 successive lines of the image in the memory buffer.
2422 2552
2423 Returns: 2553 Returns:
2424 int: The pitch. 2554 int: The pitch.
2425 """ 2555 """
2426 ... 2556 ...
2557
2427 # This function creates a new image, changing the memory layout of the pixels 2558 # This function creates a new image, changing the memory layout of the pixels
2428 def ConvertPixelFormat(self, target_format: PixelFormat) -> Image: 2559 def ConvertPixelFormat(self, target_format: PixelFormat) -> Image:
2429 """ 2560 """
2430 This function creates a new image, changing the memory layout of the pixels. 2561 This function creates a new image, changing the memory layout of the pixels.
2431 2562
2434 2565
2435 Returns: 2566 Returns:
2436 Image: The resulting image. It must be freed with OrthancPluginFreeImage(). 2567 Image: The resulting image. It must be freed with OrthancPluginFreeImage().
2437 """ 2568 """
2438 ... 2569 ...
2570
2439 # This function draws some text on some image 2571 # This function draws some text on some image
2440 def DrawText(self, font_index: int, utf8_text: str, x: int, y: int, r: int, g: int, b: int) -> None: 2572 def DrawText(self, font_index: int, utf8_text: str, x: int, y: int, r: int, g: int, b: int) -> None:
2441 """ 2573 """
2442 This function draws some text on some image. 2574 This function draws some text on some image.
2443 2575
2450 g (int): The value of the green color channel of the text. 2582 g (int): The value of the green color channel of the text.
2451 b (int): The value of the blue color channel of the text. 2583 b (int): The value of the blue color channel of the text.
2452 """ 2584 """
2453 ... 2585 ...
2454 2586
2587
2455 # This function returns a pointer to the memory buffer that contains the pixels of the image 2588 # This function returns a pointer to the memory buffer that contains the pixels of the image
2456 def GetImageBuffer(self) -> bytes: 2589 def GetImageBuffer(self) -> bytes:
2457 """ 2590 """
2458 This function returns a pointer to the memory buffer that contains the pixels of the image. 2591 This function returns a pointer to the memory buffer that contains the pixels of the image.
2459 2592
2465 """ 2598 """
2466 Orthanc job 2599 Orthanc job
2467 """ 2600 """
2468 ... 2601 ...
2469 2602
2603
2470 # This function adds the given job to the pending jobs of Orthanc 2604 # This function adds the given job to the pending jobs of Orthanc
2471 def SubmitJob(self, priority: int) -> str: 2605 def SubmitJob(self, priority: int) -> str:
2472 """ 2606 """
2473 This function adds the given job to the pending jobs of Orthanc. Orthanc will take take of freeing it by invoking the finalization callback provided to OrthancPluginCreateJob(). 2607 This function adds the given job to the pending jobs of Orthanc. Orthanc will take take of freeing it by invoking the finalization callback provided to OrthancPluginCreateJob().
2474 2608
2484 """ 2618 """
2485 Orthanc peer 2619 Orthanc peer
2486 """ 2620 """
2487 ... 2621 ...
2488 2622
2623
2489 # This function returns the number of Orthanc peers 2624 # This function returns the number of Orthanc peers
2490 def GetPeersCount(self) -> int: 2625 def GetPeersCount(self) -> int:
2491 """ 2626 """
2492 This function returns the number of Orthanc peers. 2627 This function returns the number of Orthanc peers.
2493 This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function. 2628 This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function.
2494 2629
2495 Returns: 2630 Returns:
2496 int: The number of peers. 2631 int: The number of peers.
2497 """ 2632 """
2498 ... 2633 ...
2634
2499 # This function returns the symbolic name of the Orthanc peer, which corresponds to the key of the "OrthancPeers" configuration option of Orthanc 2635 # This function returns the symbolic name of the Orthanc peer, which corresponds to the key of the "OrthancPeers" configuration option of Orthanc
2500 def GetPeerName(self, peer_index: int) -> str: 2636 def GetPeerName(self, peer_index: int) -> str:
2501 """ 2637 """
2502 This function returns the symbolic name of the Orthanc peer, which corresponds to the key of the "OrthancPeers" configuration option of Orthanc. 2638 This function returns the symbolic name of the Orthanc peer, which corresponds to the key of the "OrthancPeers" configuration option of Orthanc.
2503 This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function. 2639 This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function.
2507 2643
2508 Returns: 2644 Returns:
2509 str: The symbolic name, or NULL in the case of an error. 2645 str: The symbolic name, or NULL in the case of an error.
2510 """ 2646 """
2511 ... 2647 ...
2648
2512 # This function returns the base URL to the REST API of some Orthanc peer 2649 # This function returns the base URL to the REST API of some Orthanc peer
2513 def GetPeerUrl(self, peer_index: int) -> str: 2650 def GetPeerUrl(self, peer_index: int) -> str:
2514 """ 2651 """
2515 This function returns the base URL to the REST API of some Orthanc peer. 2652 This function returns the base URL to the REST API of some Orthanc peer.
2516 This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function. 2653 This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function.
2520 2657
2521 Returns: 2658 Returns:
2522 str: The URL, or NULL in the case of an error. 2659 str: The URL, or NULL in the case of an error.
2523 """ 2660 """
2524 ... 2661 ...
2662
2525 # This function returns some user-defined property of some Orthanc peer 2663 # This function returns some user-defined property of some Orthanc peer
2526 def GetPeerUserProperty(self, peer_index: int, user_property: str) -> str: 2664 def GetPeerUserProperty(self, peer_index: int, user_property: str) -> str:
2527 """ 2665 """
2528 This function returns some user-defined property of some Orthanc peer. An user-defined property is a property that is associated with the peer in the Orthanc configuration file, but that is not recognized by the Orthanc core. 2666 This function returns some user-defined property of some Orthanc peer. An user-defined property is a property that is associated with the peer in the Orthanc configuration file, but that is not recognized by the Orthanc core.
2529 This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function. 2667 This function is thread-safe: Several threads sharing the same OrthancPluginPeers object can simultaneously call this function.
2541 """ 2679 """
2542 Output for a call to the REST API of Orthanc 2680 Output for a call to the REST API of Orthanc
2543 """ 2681 """
2544 ... 2682 ...
2545 2683
2684
2546 # This function answers to a REST request with the content of a memory buffer 2685 # This function answers to a REST request with the content of a memory buffer
2547 def AnswerBuffer(self, answer: bytes, mime_type: str) -> None: 2686 def AnswerBuffer(self, answer: bytes, mime_type: str) -> None:
2548 """ 2687 """
2549 This function answers to a REST request with the content of a memory buffer. 2688 This function answers to a REST request with the content of a memory buffer.
2550 2689
2551 Args: 2690 Args:
2552 answer (bytes): Pointer to the memory buffer containing the answer. 2691 answer (bytes): Pointer to the memory buffer containing the answer.
2553 mime_type (str): The MIME type of the answer. 2692 mime_type (str): The MIME type of the answer.
2554 """ 2693 """
2555 ... 2694 ...
2695
2556 # This function answers to a REST request with a PNG image 2696 # This function answers to a REST request with a PNG image
2557 def CompressAndAnswerPngImage(self, format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes) -> None: 2697 def CompressAndAnswerPngImage(self, format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes) -> None:
2558 """ 2698 """
2559 This function answers to a REST request with a PNG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a PNG image by the core system of Orthanc. 2699 This function answers to a REST request with a PNG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a PNG image by the core system of Orthanc.
2560 2700
2564 height (int): The height of the image. 2704 height (int): The height of the image.
2565 pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer). 2705 pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).
2566 buffer (bytes): The memory buffer containing the uncompressed image. 2706 buffer (bytes): The memory buffer containing the uncompressed image.
2567 """ 2707 """
2568 ... 2708 ...
2709
2569 # This function answers to a REST request by redirecting the user to another URI using HTTP status 301 2710 # This function answers to a REST request by redirecting the user to another URI using HTTP status 301
2570 def Redirect(self, redirection: str) -> None: 2711 def Redirect(self, redirection: str) -> None:
2571 """ 2712 """
2572 This function answers to a REST request by redirecting the user to another URI using HTTP status 301. 2713 This function answers to a REST request by redirecting the user to another URI using HTTP status 301.
2573 2714
2574 Args: 2715 Args:
2575 redirection (str): Where to redirect. 2716 redirection (str): Where to redirect.
2576 """ 2717 """
2577 ... 2718 ...
2719
2578 # This function answers to a REST request by sending a HTTP status code (such as "400 - Bad Request") 2720 # This function answers to a REST request by sending a HTTP status code (such as "400 - Bad Request")
2579 def SendHttpStatusCode(self, status: int) -> None: 2721 def SendHttpStatusCode(self, status: int) -> None:
2580 """ 2722 """
2581 This function answers to a REST request by sending a HTTP status code (such as "400 - Bad Request"). Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). 2723 This function answers to a REST request by sending a HTTP status code (such as "400 - Bad Request"). Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed().
2582 2724
2583 Args: 2725 Args:
2584 status (int): The HTTP status code to be sent. 2726 status (int): The HTTP status code to be sent.
2585 """ 2727 """
2586 ... 2728 ...
2729
2587 # This function answers to a REST request by signaling that it is not authorized 2730 # This function answers to a REST request by signaling that it is not authorized
2588 def SendUnauthorized(self, realm: str) -> None: 2731 def SendUnauthorized(self, realm: str) -> None:
2589 """ 2732 """
2590 This function answers to a REST request by signaling that it is not authorized. 2733 This function answers to a REST request by signaling that it is not authorized.
2591 2734
2592 Args: 2735 Args:
2593 realm (str): The realm for the authorization process. 2736 realm (str): The realm for the authorization process.
2594 """ 2737 """
2595 ... 2738 ...
2739
2596 # This function answers to a REST request by signaling that the queried URI does not support this method 2740 # This function answers to a REST request by signaling that the queried URI does not support this method
2597 def SendMethodNotAllowed(self, allowed_methods: str) -> None: 2741 def SendMethodNotAllowed(self, allowed_methods: str) -> None:
2598 """ 2742 """
2599 This function answers to a REST request by signaling that the queried URI does not support this method. 2743 This function answers to a REST request by signaling that the queried URI does not support this method.
2600 2744
2601 Args: 2745 Args:
2602 allowed_methods (str): The allowed methods for this URI (e.g. "GET,POST" after a PUT or a POST request). 2746 allowed_methods (str): The allowed methods for this URI (e.g. "GET,POST" after a PUT or a POST request).
2603 """ 2747 """
2604 ... 2748 ...
2749
2605 # This function sets a cookie in the HTTP client 2750 # This function sets a cookie in the HTTP client
2606 def SetCookie(self, cookie: str, value: str) -> None: 2751 def SetCookie(self, cookie: str, value: str) -> None:
2607 """ 2752 """
2608 This function sets a cookie in the HTTP client. 2753 This function sets a cookie in the HTTP client.
2609 2754
2610 Args: 2755 Args:
2611 cookie (str): The cookie to be set. 2756 cookie (str): The cookie to be set.
2612 value (str): The value of the cookie. 2757 value (str): The value of the cookie.
2613 """ 2758 """
2614 ... 2759 ...
2760
2615 # This function sets a HTTP header in the HTTP answer 2761 # This function sets a HTTP header in the HTTP answer
2616 def SetHttpHeader(self, key: str, value: str) -> None: 2762 def SetHttpHeader(self, key: str, value: str) -> None:
2617 """ 2763 """
2618 This function sets a HTTP header in the HTTP answer. 2764 This function sets a HTTP header in the HTTP answer.
2619 2765
2620 Args: 2766 Args:
2621 key (str): The HTTP header to be set. 2767 key (str): The HTTP header to be set.
2622 value (str): The value of the HTTP header. 2768 value (str): The value of the HTTP header.
2623 """ 2769 """
2624 ... 2770 ...
2771
2625 # Initiates a HTTP multipart answer, as the result of a REST request 2772 # Initiates a HTTP multipart answer, as the result of a REST request
2626 def StartMultipartAnswer(self, sub_type: str, content_type: str) -> None: 2773 def StartMultipartAnswer(self, sub_type: str, content_type: str) -> None:
2627 """ 2774 """
2628 Initiates a HTTP multipart answer, as the result of a REST request. 2775 Initiates a HTTP multipart answer, as the result of a REST request.
2629 2776
2630 Args: 2777 Args:
2631 sub_type (str): The sub-type of the multipart answer ("mixed" or "related"). 2778 sub_type (str): The sub-type of the multipart answer ("mixed" or "related").
2632 content_type (str): The MIME type of the items in the multipart answer. 2779 content_type (str): The MIME type of the items in the multipart answer.
2633 """ 2780 """
2634 ... 2781 ...
2782
2635 # This function sends an item as a part of some HTTP multipart answer that was initiated by OrthancPluginStartMultipartAnswer() 2783 # This function sends an item as a part of some HTTP multipart answer that was initiated by OrthancPluginStartMultipartAnswer()
2636 def SendMultipartItem(self, answer: bytes) -> None: 2784 def SendMultipartItem(self, answer: bytes) -> None:
2637 """ 2785 """
2638 This function sends an item as a part of some HTTP multipart answer that was initiated by OrthancPluginStartMultipartAnswer(). 2786 This function sends an item as a part of some HTTP multipart answer that was initiated by OrthancPluginStartMultipartAnswer().
2639 2787
2640 Args: 2788 Args:
2641 answer (bytes): Pointer to the memory buffer containing the item. 2789 answer (bytes): Pointer to the memory buffer containing the item.
2642 """ 2790 """
2643 ... 2791 ...
2792
2644 # This function answers to a HTTP request by sending a HTTP status code (such as "400 - Bad Request"), together with a body describing the error 2793 # This function answers to a HTTP request by sending a HTTP status code (such as "400 - Bad Request"), together with a body describing the error
2645 def SendHttpStatus(self, status: int, body: bytes) -> None: 2794 def SendHttpStatus(self, status: int, body: bytes) -> None:
2646 """ 2795 """
2647 This function answers to a HTTP request by sending a HTTP status code (such as "400 - Bad Request"), together with a body describing the error. The body will only be returned if the configuration option "HttpDescribeErrors" of Orthanc is set to "true". 2796 This function answers to a HTTP request by sending a HTTP status code (such as "400 - Bad Request"), together with a body describing the error. The body will only be returned if the configuration option "HttpDescribeErrors" of Orthanc is set to "true".
2648 Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed(). 2797 Note that: - Successful requests (status 200) must use ::OrthancPluginAnswerBuffer(). - Redirections (status 301) must use ::OrthancPluginRedirect(). - Unauthorized access (status 401) must use ::OrthancPluginSendUnauthorized(). - Methods not allowed (status 405) must use ::OrthancPluginSendMethodNotAllowed().
2650 Args: 2799 Args:
2651 status (int): The HTTP status code to be sent. 2800 status (int): The HTTP status code to be sent.
2652 body (bytes): The body of the answer. 2801 body (bytes): The body of the answer.
2653 """ 2802 """
2654 ... 2803 ...
2804
2655 # This function answers to a REST request with a JPEG image 2805 # This function answers to a REST request with a JPEG image
2656 def CompressAndAnswerJpegImage(self, format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes, quality: int) -> None: 2806 def CompressAndAnswerJpegImage(self, format: PixelFormat, width: int, height: int, pitch: int, buffer: bytes, quality: int) -> None:
2657 """ 2807 """
2658 This function answers to a REST request with a JPEG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a JPEG image by the core system of Orthanc. 2808 This function answers to a REST request with a JPEG image. The parameters of this function describe a memory buffer that contains an uncompressed image. The image will be automatically compressed as a JPEG image by the core system of Orthanc.
2659 2809
2664 pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer). 2814 pitch (int): The pitch of the image (i.e. the number of bytes between 2 successive lines of the image in the memory buffer).
2665 buffer (bytes): The memory buffer containing the uncompressed image. 2815 buffer (bytes): The memory buffer containing the uncompressed image.
2666 quality (int): The quality of the JPEG encoding, between 1 (worst quality, best compression) and 100 (best quality, worst compression). 2816 quality (int): The quality of the JPEG encoding, between 1 (worst quality, best compression) and 100 (best quality, worst compression).
2667 """ 2817 """
2668 ... 2818 ...
2819
2669 # This function sets the detailed description associated with an HTTP error 2820 # This function sets the detailed description associated with an HTTP error
2670 def SetHttpErrorDetails(self, details: str, log: int) -> None: 2821 def SetHttpErrorDetails(self, details: str, log: int) -> None:
2671 """ 2822 """
2672 This function sets the detailed description associated with an HTTP error. This description will be displayed in the "Details" field of the JSON body of the HTTP answer. It is only taken into consideration if the REST callback returns an error code that is different from "OrthancPluginErrorCode_Success", and if the "HttpDescribeErrors" configuration option of Orthanc is set to "true". 2823 This function sets the detailed description associated with an HTTP error. This description will be displayed in the "Details" field of the JSON body of the HTTP answer. It is only taken into consideration if the REST callback returns an error code that is different from "OrthancPluginErrorCode_Success", and if the "HttpDescribeErrors" configuration option of Orthanc is set to "true".
2673 2824
2688 """ 2839 """
2689 Storage area plugin 2840 Storage area plugin
2690 """ 2841 """
2691 ... 2842 ...
2692 2843
2844
2693 # This function creates a new file inside the storage area that is currently used by Orthanc 2845 # This function creates a new file inside the storage area that is currently used by Orthanc
2694 def StorageAreaCreate(self, uuid: str, content: bytes, size: int, type: ContentType) -> None: 2846 def StorageAreaCreate(self, uuid: str, content: bytes, size: int, type: ContentType) -> None:
2695 """ 2847 """
2696 This function creates a new file inside the storage area that is currently used by Orthanc. 2848 This function creates a new file inside the storage area that is currently used by Orthanc.
2697 2849
2700 content (bytes): The content to store in the newly created file. 2852 content (bytes): The content to store in the newly created file.
2701 size (int): The size of the content. 2853 size (int): The size of the content.
2702 type (ContentType): The type of the file content. 2854 type (ContentType): The type of the file content.
2703 """ 2855 """
2704 ... 2856 ...
2857
2705 # This function reads the content of a given file from the storage area that is currently used by Orthanc 2858 # This function reads the content of a given file from the storage area that is currently used by Orthanc
2706 def StorageAreaRead(self, uuid: str, type: ContentType) -> bytes: 2859 def StorageAreaRead(self, uuid: str, type: ContentType) -> bytes:
2707 """ 2860 """
2708 This function reads the content of a given file from the storage area that is currently used by Orthanc. 2861 This function reads the content of a given file from the storage area that is currently used by Orthanc.
2709 2862
2713 2866
2714 Returns: 2867 Returns:
2715 bytes: 0 if success, other value if error. 2868 bytes: 0 if success, other value if error.
2716 """ 2869 """
2717 ... 2870 ...
2871
2718 # This function removes a given file from the storage area that is currently used by Orthanc 2872 # This function removes a given file from the storage area that is currently used by Orthanc
2719 def StorageAreaRemove(self, uuid: str, type: ContentType) -> None: 2873 def StorageAreaRemove(self, uuid: str, type: ContentType) -> None:
2720 """ 2874 """
2721 This function removes a given file from the storage area that is currently used by Orthanc. 2875 This function removes a given file from the storage area that is currently used by Orthanc.
2722 2876
2723 Args: 2877 Args:
2724 uuid (str): The identifier of the file to be removed. 2878 uuid (str): The identifier of the file to be removed.
2725 type (ContentType): The type of the file content. 2879 type (ContentType): The type of the file content.
2726 """ 2880 """
2727 ... 2881 ...
2882
2728 # This function requests the Orthanc core to reconstruct the main DICOM tags of all the resources of the given type 2883 # This function requests the Orthanc core to reconstruct the main DICOM tags of all the resources of the given type
2729 def ReconstructMainDicomTags(self, level: ResourceType) -> None: 2884 def ReconstructMainDicomTags(self, level: ResourceType) -> None:
2730 """ 2885 """
2731 This function requests the Orthanc core to reconstruct the main DICOM tags of all the resources of the given type. This function can only be used as a part of the upgrade of a custom database back-end. A database transaction will be automatically setup. 2886 This function requests the Orthanc core to reconstruct the main DICOM tags of all the resources of the given type. This function can only be used as a part of the upgrade of a custom database back-end. A database transaction will be automatically setup.
2732 2887
2739 """ 2894 """
2740 Answers to a DICOM C-FIND worklist query 2895 Answers to a DICOM C-FIND worklist query
2741 """ 2896 """
2742 ... 2897 ...
2743 2898
2899
2744 # This function adds one worklist (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request against modality worklists 2900 # This function adds one worklist (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request against modality worklists
2745 def WorklistAddAnswer(self, query: WorklistQuery, dicom: bytes) -> None: 2901 def WorklistAddAnswer(self, query: WorklistQuery, dicom: bytes) -> None:
2746 """ 2902 """
2747 This function adds one worklist (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request against modality worklists. 2903 This function adds one worklist (encoded as a DICOM file) to the set of answers corresponding to some C-Find SCP request against modality worklists.
2748 2904
2749 Args: 2905 Args:
2750 query (WorklistQuery): The worklist query, as received by the callback. 2906 query (WorklistQuery): The worklist query, as received by the callback.
2751 dicom (bytes): The worklist to answer, encoded as a DICOM file. 2907 dicom (bytes): The worklist to answer, encoded as a DICOM file.
2752 """ 2908 """
2753 ... 2909 ...
2910
2754 # This function marks as incomplete the set of answers corresponding to some C-Find SCP request against modality worklists 2911 # This function marks as incomplete the set of answers corresponding to some C-Find SCP request against modality worklists
2755 def WorklistMarkIncomplete(self) -> None: 2912 def WorklistMarkIncomplete(self) -> None:
2756 """ 2913 """
2757 This function marks as incomplete the set of answers corresponding to some C-Find SCP request against modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned. 2914 This function marks as incomplete the set of answers corresponding to some C-Find SCP request against modality worklists. This must be used if canceling the handling of a request when too many answers are to be returned.
2758 """ 2915 """
2762 """ 2919 """
2763 DICOM C-FIND worklist query 2920 DICOM C-FIND worklist query
2764 """ 2921 """
2765 ... 2922 ...
2766 2923
2924
2767 # This function checks whether one worklist (encoded as a DICOM file) matches the C-Find SCP query against modality worklists 2925 # This function checks whether one worklist (encoded as a DICOM file) matches the C-Find SCP query against modality worklists
2768 def WorklistIsMatch(self, dicom: bytes) -> int: 2926 def WorklistIsMatch(self, dicom: bytes) -> int:
2769 """ 2927 """
2770 This function checks whether one worklist (encoded as a DICOM file) matches the C-Find SCP query against modality worklists. This function must be called before adding the worklist as an answer through OrthancPluginWorklistAddAnswer(). 2928 This function checks whether one worklist (encoded as a DICOM file) matches the C-Find SCP query against modality worklists. This function must be called before adding the worklist as an answer through OrthancPluginWorklistAddAnswer().
2771 2929
2774 2932
2775 Returns: 2933 Returns:
2776 int: 1 if the worklist matches the query, 0 otherwise. 2934 int: 1 if the worklist matches the query, 0 otherwise.
2777 """ 2935 """
2778 ... 2936 ...
2937
2779 # This function retrieves the DICOM file that underlies a C-Find SCP query against modality worklists 2938 # This function retrieves the DICOM file that underlies a C-Find SCP query against modality worklists
2780 def WorklistGetDicomQuery(self) -> bytes: 2939 def WorklistGetDicomQuery(self) -> bytes:
2781 """ 2940 """
2782 This function retrieves the DICOM file that underlies a C-Find SCP query against modality worklists. 2941 This function retrieves the DICOM file that underlies a C-Find SCP query against modality worklists.
2783 2942