Mercurial > hg > orthanc-book
annotate Sphinx/source/plugins/python/dicom-find-move-scp.py @ 1113:a588960a72e5 default tip
spelling
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 28 Oct 2024 09:23:08 +0100 |
parents | daf07750e901 |
children |
rev | line source |
---|---|
704
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 import json |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 import orthanc |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 import pprint |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 def OnFind(answers, query, issuerAet, calledAet): |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 print('Received incoming C-FIND request from %s:' % issuerAet) |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 answer = {} |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 for i in range(query.GetFindQuerySize()): |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 print(' %s (%04x,%04x) = [%s]' % (query.GetFindQueryTagName(i), |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 query.GetFindQueryTagGroup(i), |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 query.GetFindQueryTagElement(i), |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 query.GetFindQueryValue(i))) |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 answer[query.GetFindQueryTagName(i)] = ('HELLO%d-%s' % (i, query.GetFindQueryValue(i))) |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 answers.FindAddAnswer(orthanc.CreateDicom( |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 json.dumps(answer), None, orthanc.CreateDicomFlags.NONE)) |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 def OnMove(**request): |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 orthanc.LogWarning('C-MOVE request to be handled in Python: %s' % |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 json.dumps(request, indent = 4, sort_keys = True)) |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
707 | 23 # To indicate a failure in the processing, one can raise an exception: |
705 | 24 # raise Exception('Cannot handle C-MOVE') |
25 | |
704
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 orthanc.RegisterFindCallback(OnFind) |
ba2403ebd4b7
moving python samples in separate files (3)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 orthanc.RegisterMoveCallback(OnMove) |