Mercurial > hg > orthanc-book
changeset 1189:801707730af7
python: SetStableStatus
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Wed, 13 Aug 2025 19:46:01 +0200 |
parents | 0f65d14e02dd |
children | 7492a3915bf2 |
files | Sphinx/source/plugins/python.rst Sphinx/source/plugins/python/set-stable-status.py |
diffstat | 2 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/Sphinx/source/plugins/python.rst Wed Aug 13 17:05:51 2025 +0200 +++ b/Sphinx/source/plugins/python.rst Wed Aug 13 19:46:01 2025 +0200 @@ -993,6 +993,18 @@ .. literalinclude:: python/extend-api-with-streaming.py :language: python +.. _python_set_stable_status: + +Changing the Stable status of a resource (new in 6.0) +................................... + +Starting from v 6.0, it is possible to change the ``Stable`` status of a +resource without waiting for the stabilization time defined by the ``StableAge`` +configuration. Changing the ``Stable`` status will also trigger the lua callbacks +and python plugins that are listening on the ``STABLE_STUDY/STABLE_SERIES/..`` events. + +.. literalinclude:: python/set-stable-status.py + :language: python .. _python_couchdb:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Sphinx/source/plugins/python/set-stable-status.py Wed Aug 13 19:46:01 2025 +0200 @@ -0,0 +1,12 @@ +import orthanc +import json + +def OnChange(changeType, level, resource): + if changeType == orthanc.ChangeType.NEW_INSTANCE: + parentSeries = json.loads(orthanc.RestApiGet('/instances/%s/series' % resource)) + + if parentSeries["MainDicomTags"]["Modality"] == "CR": + orthanc.LogInfo('Stabilizing CR series directly: %s' % resource) + ret, hasStableStatusChanged = orthanc.SetStableStatus(parentSeries["ID"], orthanc.StableStatus.STABLE) + +orthanc.RegisterOnChangeCallback(OnChange) \ No newline at end of file