comparison Sphinx/source/plugins/python/accessing-new-instance.py @ 703:a589668768d7

moving python samples in separate files (2)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 Jun 2021 10:07:12 +0200
parents
children
comparison
equal deleted inserted replaced
702:6e02cd89eb6a 703:a589668768d7
1 import orthanc
2 import json
3 import pprint
4
5 def OnStoredInstance(dicom, instanceId):
6 print('Received instance %s of size %d (transfer syntax %s, SOP class UID %s)' % (
7 instanceId, dicom.GetInstanceSize(),
8 dicom.GetInstanceMetadata('TransferSyntax'),
9 dicom.GetInstanceMetadata('SopClassUid')))
10
11 # Print the origin information
12 if dicom.GetInstanceOrigin() == orthanc.InstanceOrigin.DICOM_PROTOCOL:
13 print('This instance was received through the DICOM protocol')
14 elif dicom.GetInstanceOrigin() == orthanc.InstanceOrigin.REST_API:
15 print('This instance was received through the REST API')
16
17 # Print the DICOM tags
18 pprint.pprint(json.loads(dicom.GetInstanceSimplifiedJson()))
19
20 orthanc.RegisterOnStoredInstanceCallback(OnStoredInstance)