# HG changeset patch # User Sebastien Jodogne # Date 1645638375 -3600 # Node ID a67ceccebf021bae3cbc25c465bb49936b7c4687 # Parent 48676fb3ac0f0b144abacd26e99be9644eecab3a releasing Python plugin 4.0 diff -r 48676fb3ac0f -r a67ceccebf02 Sphinx/source/plugins/python.rst --- a/Sphinx/source/plugins/python.rst Wed Feb 23 15:03:47 2022 +0100 +++ b/Sphinx/source/plugins/python.rst Wed Feb 23 18:46:15 2022 +0100 @@ -771,10 +771,10 @@ .. _python_received_instance: -Modifying received instances (new in 3.5 - not released yet) -............................................................ +Modifying received instances (new in 4.0) +......................................... -Starting with release 3.5 of the Python plugin, it is possible to +Starting with release 4.0 of the Python plugin, it is possible to modify instances received by Orthanc before they are stored in the storage. This is usually easier to perform modification at this stage compared to using the ``/modify`` route once the instances diff -r 48676fb3ac0f -r a67ceccebf02 Sphinx/source/plugins/python/received-instance-callback.py --- a/Sphinx/source/plugins/python/received-instance-callback.py Wed Feb 23 15:03:47 2022 +0100 +++ b/Sphinx/source/plugins/python/received-instance-callback.py Wed Feb 23 18:46:15 2022 +0100 @@ -23,17 +23,17 @@ if dataset.PatientID.startswith('001-'): orthanc.LogWarning('Discard instance') - return orthanc.ReceivedInstanceCallbackResult.DISCARD, None + return orthanc.ReceivedInstanceAction.DISCARD, None elif dataset.PatientID.startswith('002-'): orthanc.LogWarning('Store source instance as it is') - return orthanc.ReceivedInstanceCallbackResult.KEEP_AS_IS, None + return orthanc.ReceivedInstanceAction.KEEP_AS_IS, None else: orthanc.LogWarning('Modify the source instance') dataset.PatientName = str(dataset.PatientName).upper() dataset.PatientID = '002-' + dataset.PatientID dataset.InstitutionName = "MY INSTITUTION" - return orthanc.ReceivedInstanceCallbackResult.MODIFIED, write_dataset_to_bytes(dataset) + return orthanc.ReceivedInstanceAction.MODIFY, write_dataset_to_bytes(dataset) orthanc.RegisterReceivedInstanceCallback(ReceivedInstanceCallback)