# HG changeset patch # User Sebastien Jodogne # Date 1359387829 -3600 # Node ID cc9eddbf07d37c635c4bc7db0a52ddba4e9c302e # Parent 64625960af22c6d5f0b164e96cf0bdef5e6bc054 sample to anonymize patients diff -r 64625960af22 -r cc9eddbf07d3 Resources/Samples/Python/AnonymizeAllPatients.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Samples/Python/AnonymizeAllPatients.py Mon Jan 28 16:43:49 2013 +0100 @@ -0,0 +1,25 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + + +URL = 'http://localhost:8042' + +# +# This sample code will anonymize all the patients that are stored in +# Orthanc. +# + +import sys +import RestToolbox + +# Loop over the patients +for patient in RestToolbox.DoGet('%s/patients' % URL): + + # Ignore patients whose name starts with "Anonymized", as it is + # the result of a previous anonymization + infos = RestToolbox.DoGet('%s/patients/%s' % (URL, patient)) + name = infos['MainDicomTags']['PatientName'].lower() + if not name.startswith('anonymized'): + + # Trigger the anonymization + RestToolbox.DoPost('%s/patients/%s/anonymize' % (URL, patient))