annotate Sphinx/source/users/anonymization_bypass.py @ 970:bc531449c024

altering the content of a single instance
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 24 Aug 2023 09:56:03 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
970
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 import json
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 import pprint
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 import requests
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 INSTANCE = '19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5'
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 OVERWRITE_INSTANCES = True # Whether the "OverwriteInstance" is set to "true" in the Orthanc config
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 r = requests.post('http://localhost:8042/instances/%s/modify' % INSTANCE, json.dumps({
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 'Replace' : {
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 'PatientName' : 'Hello'
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 },
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 'Keep' : [ 'SOPInstanceUID' ], # Don't generate a new SOPInstanceUID
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 'Force' : True # Mandatory if SOPInstanceUID must be kept constant
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 }))
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 r.raise_for_status()
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 dicom = r.content
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 if not OVERWRITE_INSTANCES:
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 r = requests.delete('http://localhost:8042/instances/%s' % INSTANCE)
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 r.raise_for_status()
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 r = requests.post('http://localhost:8042/instances', dicom)
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 r.raise_for_status()
bc531449c024 altering the content of a single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 pprint.pprint(r.json())