Here you go (changes in black):
import json
import orthanc
import pprint
def OnChange(changeType, level, resource):
if changeType == orthanc.ChangeType.NEW_INSTANCE:
metadata = json.loads(orthanc.RestApiGet(‘/instances/%s/metadata?expand’ % resource))
pprint.pprint(metadata)
tags = json.loads(orthanc.RestApiGet(‘/instances/%s/tags?simplify’ % resource))
pprint.pprint(tags)
orthanc.RegisterOnChangeCallback(OnChange)
Sébastien-