diff --git a/src/anonymizer.js b/src/anonymizer.js index 50f0ea50..d901dfae 100644 --- a/src/anonymizer.js +++ b/src/anonymizer.js @@ -235,19 +235,28 @@ var tagNamesToEmpty = [ "DataSetTrailingPadding" ]; -export function cleanTags(dict) { - tagNamesToEmpty.forEach(function (tag) { +export function getTagsNameToEmpty() { + return [...tagNamesToEmpty]; +} + +export function cleanTags( + dict, + tagNamesToReplace, + customTagNamesToEmpty = undefined +) { + var tags = + customTagNamesToEmpty != undefined + ? customTagNamesToEmpty + : tagNamesToEmpty; + tags.forEach(function (tag) { var tagInfo = DicomMetaDictionary.nameMap[tag]; if (tagInfo && tagInfo.version != "PrivateTag") { var tagNumber = tagInfo.tag, tagString = Tag.fromPString(tagNumber).toCleanString(); if (dict[tagString]) { - log.log("empty tag " + tag); var newValue; - if (tagString == "00100010") { - newValue = ["ANON^PATIENT"]; - } else if (tagString == "00100020") { - newValue = ["ANONID"]; + if (tagString in tagNamesToReplace) { + newValue = [tagNamesToReplace[tagString]]; } else { newValue = []; } diff --git a/src/index.js b/src/index.js index 9d189cbc..fe8145e3 100644 --- a/src/index.js +++ b/src/index.js @@ -41,7 +41,7 @@ import adapters from "./adapters/index.js"; import utilities from "./utilities/index.js"; import sr from "./sr/index.js"; -import { cleanTags } from "./anonymizer.js"; +import { cleanTags, getTagsNameToEmpty } from "./anonymizer.js"; let data = { BitArray, @@ -80,7 +80,8 @@ let normalizers = { }; let anonymizer = { - cleanTags + cleanTags, + getTagsNameToEmpty }; const dcmjs = {