Mercurial > hg > orthanc-book
changeset 472:03dfb896ca4b
merge
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Aug 2020 20:53:35 +0200 |
parents | a735476a0e6e (current diff) 90e6c20cef1e (diff) |
children | c7b2424e4b52 |
files | Sphinx/source/plugins/python.rst |
diffstat | 3 files changed, 107 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Sphinx/source/faq/transcoding.rst Tue Aug 04 20:53:18 2020 +0200 +++ b/Sphinx/source/faq/transcoding.rst Tue Aug 04 20:53:35 2020 +0200 @@ -88,7 +88,7 @@ UID of interest. For instance, setting ``IngestTranscoding`` to ``1.2.840.10008.1.2.1`` will decompress all the received DICOM instances. Conversely, setting it to ``1.2.840.10008.1.2.4.70`` will - compress and store images using JPEG-LS (lossless). + compress and store images using JPEG Lossless. * **Decompression while sending instances using the DICOM protocol**. Orthanc can be configured to automatically decompress DICOM images
--- a/Sphinx/source/plugins.rst Tue Aug 04 20:53:18 2020 +0200 +++ b/Sphinx/source/plugins.rst Tue Aug 04 20:53:35 2020 +0200 @@ -70,34 +70,58 @@ Index of the contributed plugins -------------------------------- +C/C++ plugins +^^^^^^^^^^^^^ + * `AWS S3 storage plugin <https://github.com/radpointhq/orthanc-s3-storage>`__: This plugin by `Radpoint <https://radpoint.pl/>`__ makes Orthanc store its DICOM files into an `Amazon S3 bucket <https://en.wikipedia.org/wiki/Amazon_S3>`__. + * `DWV Orthanc Plugin <https://github.com/ivmartel/dwv-orthanc-plugin>`__: This plugin by Yves Martelli is based on `dwv <https://github.com/ivmartel/dwv/wiki>`__ and extends Orthanc with a Web viewer of DICOM images. + * Another Web viewer is provided courtesy of `Emsy Chan <https://groups.google.com/d/msg/orthanc-users/EC5Z2KaM4Hs/MG3KkzhCDAAJ>`__. + * `VPI Reveal <https://www.vpireveal.com/>`__ provides a plugin to "write the DICOM records in a normal Windows-readable file hierarchy (patient-study-series-DICOM file) at a location called ``VPIStorage`` that can then be imported into VPI Reveal." `Check out their source code <https://github.com/jodogne/OrthancContributed/tree/master/Plugins/orthancVPIRevealPlugin>`__. + * `Doc Cirrus <https://www.doc-cirrus.com/>`__ is working on `MongoDB <https://en.wikipedia.org/wiki/MongoDB>`__ database plugins. Check out their `source code <https://github.com/Doc-Cirrus/orthanc-mongodb>`__ and the `associated description <https://github.com/jodogne/OrthancContributed/tree/master/Plugins/orthanc-mongodb>`__. + +Python plugins +^^^^^^^^^^^^^^ + +* Julian Hartig maintains a `Python plugin + <https://github.com/crispinus2/orthanc-gdt>`__ called + ``orthanc-gdt``, in order to glue Orthanc to the `GDT interface most + German AIS <https://en.wikipedia.org/wiki/XDT>`__ + (Arztinformationssysteme - as opposed to e.g. the RIS used by + radiologists) use for communicating with external applications and + devices. This topic is further discussed on the `Orthanc Users forum + <https://groups.google.com/d/msg/orthanc-users/NO7MnWzKsAc/5hEVxymWBQAJ>`__. + + +Other +^^^^^ + * Check out the `OrthancContributed repository on GitHub <https://github.com/jodogne/OrthancContributed/tree/master/Plugins>`__, that might contain plugins that are not tracked in this list. -*Remark:* Do not hesitate to `contact us -<https://www.orthanc-server.com/static.php?page=contact>`__ if you have -developed a plugin so that we can promote it in the list above! +* **Important:** Do not hesitate to `contact us + <https://www.orthanc-server.com/static.php?page=contact>`__ if you + have developed a plugin so that we can promote it in the list above!
--- a/Sphinx/source/plugins/python.rst Tue Aug 04 20:53:18 2020 +0200 +++ b/Sphinx/source/plugins/python.rst Tue Aug 04 20:53:35 2020 +0200 @@ -240,6 +240,8 @@ $ curl http://localhost:8042/toto ok + +.. _python-changes: Listening to changes .................... @@ -556,7 +558,7 @@ about `attribute matching <http://dicom.nema.org/medical/dicom/2019e/output/chtml/part04/sect_C.2.2.2.html>`__. -.. highlight:: python +.. highlight:: bash Here is a sample call to retrieve all the studies that were last updated in 2019 thanks to this Python script:: @@ -564,6 +566,82 @@ $ curl http://localhost:8042/tools/find -d '{"Level":"Study","Query":{},"Expand":true,"Metadata":{"LastUpdate":"^2019.*$"}}' +.. _python-paging: + +Implementing basic paging +......................... + +.. highlight:: python + +As explained in the FAQ, the :ref:`Orthanc Explorer interface is +low-level <improving-interface>`, and is not adapted for +end-users. One common need is to implement paging of studies, which +calls for server-side sorting of studies. This can be done using the +following sample Python plugin that registers a new route +``/sort-studies`` in the REST API of Orthanc:: + + import json + import orthanc + + def GetStudyDate(study): + if 'StudyDate' in study['MainDicomTags']: + return study['MainDicomTags']['StudyDate'] + else: + return '' + + def SortStudiesByDate(output, uri, **request): + if request['method'] == 'GET': + # Retrieve all the studies + studies = json.loads(orthanc.RestApiGet('/studies?expand')) + + # Sort the studies according to the "StudyDate" DICOM tag + studies = sorted(studies, key = GetStudyDate) + + # Read the limit/offset arguments provided by the user + offset = 0 + if 'offset' in request['get']: + offset = int(request['get']['offset']) + + limit = 0 + if 'limit' in request['get']: + limit = int(request['get']['limit']) + + # Truncate the list of studies + if limit == 0: + studies = studies[offset : ] + else: + studies = studies[offset : offset + limit] + + # Return the truncated list of studies + output.AnswerBuffer(json.dumps(studies), 'application/json') + else: + output.SendMethodNotAllowed('GET') + + orthanc.RegisterRestCallback('/sort-studies', SortStudiesByDate) + + +.. highlight:: bash + +Here is a sample call to this new REST route, that could be issued by +any JavaScript framework (the ``json_pp`` command-line pretty-prints a +JSON file):: + + $ curl http://localhost:8042/sort-studies | json_pp + +This route also implement paging (i.e. it can limit and offset the +returned studies):: + + $ curl 'http://localhost:8042/sort-studies?offset=2&limit=2' | json_pp + +Obviously, this basic sample can be improved in many ways. To improve +performance, one could for instance cache the result of +``/studies?expand`` in memory by :ref:`listening to changes +<python-changes>` in the list of studies +(cf. ``orthanc.ChangeType.NEW_STUDY`` and +``orthanc.ChangeType.DELETED``). + + + Performance and concurrency ---------------------------