Mercurial > hg > orthanc-book
annotate Sphinx/source/users/anonymization_bypass.py @ 1006:fd3ad1ac1482
docker image was upgraded
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 22 Dec 2023 15:21:38 +0100 |
parents | bc531449c024 |
children |
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()) |