comparison Sphinx/source/plugins/python.rst @ 727:698eb280060a

pynetdicom sample
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 Jun 2021 07:48:48 +0200
parents 8a247c645ac6
children e6386c012438
comparison
equal deleted inserted replaced
726:26940c3246c3 727:698eb280060a
660 I: (0008,0060) CS [MR] # 2, 1 Modality 660 I: (0008,0060) CS [MR] # 2, 1 Modality
661 I: (fffe,e00d) na (ItemDelimitationItem for re-encoding) # 0, 0 ItemDelimitationItem 661 I: (fffe,e00d) na (ItemDelimitationItem for re-encoding) # 0, 0 ItemDelimitationItem
662 I: (fffe,e0dd) na (SequenceDelimitationItem for re-encod.) # 0, 0 SequenceDelimitationItem 662 I: (fffe,e0dd) na (SequenceDelimitationItem for re-encod.) # 0, 0 SequenceDelimitationItem
663 I: 663 I:
664 664
665 665
666 .. _pynetdicom:
667
668 Replacing DICOM SCP of Orthanc by pynetdicom
669 ............................................
670
671 .. highlight:: json
672
673 Thanks to Python plugins, it is also possible to replace the built-in
674 DICOM SCP of Orthanc by `pynetdicom
675 <https://pydicom.github.io/pynetdicom/stable/examples/storage.html>`__
676 so as to customize how the DICOM protocol is handled. Firstly, in the
677 configuration file, make sure to disable the Orthanc SCP by setting
678 ``DicomServerEnabled`` to ``false``::
679
680 {
681 "Plugins" : [ "." ],
682 "PythonScript" : "pynetdicom.py",
683 "DicomServerEnabled" : false
684 }
685
686 Secondly, here a basic plugin illustrating how to start and stop the
687 pynetdicom server, and handle incoming C-STORE requests:
688
689 .. literalinclude:: python/pynetdicom.py
690 :language: python
691
692 As can be seen in this listing, whenever the pynetdicom receives an
693 incoming C-STORE request, it makes a POST call to the URI
694 ``/instances`` in the REST API of Orthanc in order to store the
695 embedded DICOM dataset into Orthanc. Obviously, one can build more
696 complex DICOM servers by handling more messages than C-STORE alone.
697
698
666 699
667 Performance and concurrency 700 Performance and concurrency
668 --------------------------- 701 ---------------------------
669 702
670 **Important:** This section only applies to UNIX-like systems. The 703 **Important:** This section only applies to UNIX-like systems. The