Mercurial > hg > orthanc
diff OrthancServer/Resources/Samples/Python/ContinuousPatientAnonymization.py @ 4855:ffc03a1d60c3
fix sample scripts for Python3
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 17 Dec 2021 13:36:27 +0100 |
parents | 7053502fbf97 |
children | 43e613a7756b |
line wrap: on
line diff
--- a/OrthancServer/Resources/Samples/Python/ContinuousPatientAnonymization.py Thu Dec 16 16:13:03 2021 +0100 +++ b/OrthancServer/Resources/Samples/Python/ContinuousPatientAnonymization.py Fri Dec 17 13:36:27 2021 +0100 @@ -24,7 +24,7 @@ import time import sys import RestToolbox -import md5 +import hashlib ## @@ -66,13 +66,15 @@ # The PatientID after anonymization is taken as the 8 first # characters from the MD5 hash of the original PatientID - anonymizedID = md5.new(patientID).hexdigest()[:8] + h = hashlib.md5(patientID.encode('ascii')) + anonymizedID = h.hexdigest()[:8] anonymizedName = 'Anonymized patient %d' % COUNT COUNT += 1 RestToolbox.DoPost(URL + path + '/anonymize', { 'Replace' : { 'PatientID' : anonymizedID, - 'PatientName' : anonymizedName } }) + 'PatientName' : anonymizedName }, + 'Force' : True }) # Delete the source patient after the anonymization RestToolbox.DoDelete(URL + change['Path'])