# HG changeset patch # User Alain Mazy # Date 1755107161 -7200 # Node ID 801707730af71509b160b6999e33e66f92b271f9 # Parent 0f65d14e02ddcdd02992f8b1ed561403493e0f04 python: SetStableStatus diff -r 0f65d14e02dd -r 801707730af7 Sphinx/source/plugins/python.rst --- 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: diff -r 0f65d14e02dd -r 801707730af7 Sphinx/source/plugins/python/set-stable-status.py --- /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