// 19) Pass your own list of mappings to anonymizer. Patient Name should be replace to
// 'Mapped' if 'Anonymized' is found. Case sensitive
try
{
echo "19) Pass your own list of mappings to anonymizer\n";
// Own tag elements for anonymizing
$tags = array(
array(0x0008, 0x0020, '{date|Ymd}'), // Study Date
array(0x0008, 0x0021, '{date|Ymd}'), // Series Date
array(0x0008, 0x0090, 'physician{random}'), // Referring Physician
array(0x0010, 0x0010, 'patient{consecutive}'), // Patient Name
array(0x0010, 0x0020, 'id{consecutive}'), // Patient ID
array(0x0010, 0x0030, '{date|Ymd}'), // Patient Date of Birth
);
$replacements = array(
array(0x0010, 0x0010, 'anonymized', 'Mapped'),
);
$dicom = Nanodicom::factory($filename, 'anonymizer');
$dicom1 = Nanodicom::factory($dicom->anonymize($tags, $replacements), 'dumper', 'blob');
echo $dicom1->dump();
file_put_contents($filename.'.ex19', $dicom1->write());
unset($dicom);
unset($dicom1);
}
catch (Nanodicom_Exception $e)
{
echo 'File failed. '.$e->getMessage()."\n";
}