DICOM Solutions
DICOM is the registered trademark of the National Electrical Manufacturers Association for its standards publications relating to digital communications of medical information.

http://www.dicom-solutions.com

Features Webcasts and Screenshots Free Trial Order Information User Zone Portable USB Version
MHGS logo

PowerDicom

A Sample Script

The following sample script demonstrates how easy it is to anonymize all DICOM files in a whole folder using PowerDicom™. This script uses VBScript (Windows Script Host). Many other programming, scripting or macro languages can be used similar.

rem              Sample Script anonymize.vbs
rem
rem  This script changes the patient's name in each file of a given
rem  folder and saves all files to a different directory
rem==========================================================================
rem  Source and Destination Directories
 SourceDir="files\"
 DestDir=WScript.CreateObject("WScript.Shell").SpecialFolders("Desktop")+"\test\"

rem creating  a filesystem object and the PowerDicom.Automation object
set fs=WScript.CreateObject("Scripting.FileSystemObject")
set PowerDicomAuto = WScript.CreateObject("PowerDicom.Automation")

if fs.FolderExists(SourceDir) then
  set Files=fs.GetFolder(SourceDir).Files
else
  WScript.Echo(SourceDir+" doesn't exist.")
  WScript.Quit
end if

if Not fs.FolderExists(DestDir) then
  fs.CreateFolder(DestDir)
end if

for each Item in Files
  rem opening a DICOM-file
   v= PowerDicomAuto.OpenFile(Item.Path)
if v>0 then
    rem  modify the Patient's name
      PowerDicomAuto.SetItemValue &H10,&H10,"anonymous"

    rem save the modified file
    if PowerDicomAuto.SaveFile(DestDir+Item.Name)<1 then
      WScript.Echo("Error Writing File "+ Item.Name + " to " + DestDir)
      end if
    rem close the file
    PowerDicomAuto.CloseFile()
  end if
next

WScript.Echo("Finished Anonymizing")

DICOM Solutions is an MHGS Enterprise.

© MHGS: http://www.MHGSoft.de