Skip to content

fix: use dictionary keywords for anonymizer tags - #510

Merged
wayfarer3130 merged 3 commits into
dcmjs-org:masterfrom
cpruijsen:fix/issue-345
Nov 24, 2026
Merged

wayfarer3130 merged 3 commits into
dcmjs-org:masterfrom
cpruijsen:fix/issue-345

Conversation

@cpruijsen

@cpruijsen cpruijsen commented Sep 11, 2026 •

Copy link
Copy Markdown

Summary

Every tagNamesToEmpty name now resolves in DicomMetaDictionary.nameMap, so cleanTags actually empties those PHI tags. cleanTags looks up each name and silently skips any it cannot find. 104 of the 222 live names never resolved, so those tags were left in place.

The first commit fixes the seven names from #345:

  • ReferringPhysicianTelephoneNumbers (was ReferringPhysicianPhoneNumbers)
  • PhysiciansOfRecord (was PhysicianOfRecord)
  • NameOfPhysiciansReadingStudy (was NameOfPhysicianReadingStudy)
  • OperatorsName (was OperatorName)
  • AdmittingDiagnosesDescription (was AdmittingDiagnosisDescription)
  • Allergies (was ContrastAllergies; ContrastAllergies is a Siemens RIS private tag)
  • ResponsiblePersonRole (added)

The second commit renames the remaining 97 to their dictionary keywords: CTP-style Seq abbreviations (for example ReferencedImageSequence, OtherPatientIDsSequence), case variants such as AcquisitionDateTime, PatientTelephoneNumbers, and retired elements under their RETIRED_ names. Each one was checked against nameMap, and none were dropped.

Heads up: this changes output for files that carry those tags, since they are now emptied as the list intended. That includes sequences such as ContentSequence and ReferencedImageSequence, which PS3.15 Table E.1-1 also lists for removal. Callers that copy getTagsNameToEmpty() and splice the old strings will no longer find them, but those strings never matched nameMap anyway.

Closes #345

Test plan

  • test/anonymizer.test.js: builds a dict from every list entry, runs cleanTags, and expects empty values
  • the test fails if src/anonymizer.js is reverted to the old names
  • same file: existing tests other than test_anonymization_no_change_ref (that one already fails on Node 26 because sample-sr.dcm is read via .buffer; not part of this change)

cleanTags looks up tagNamesToEmpty in DicomMetaDictionary.nameMap, so
incorrect or missing keywords were skipped and those PHI tags were left intact.
@netlify

netlify Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for dcmjs2 ready!

Name Link
🔨 Latest commit f5fddac
🔍 Latest deploy log https://app.netlify.com/projects/dcmjs2/deploys/6aa3b053bfa51d0008bb42df
😎 Deploy Preview https://deploy-preview-510--dcmjs2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

97 more tagNamesToEmpty entries used CTP abbreviations or pre-retirement
names that never resolve in DicomMetaDictionary.nameMap, so cleanTags
silently skipped them and left those PHI tags intact. Retired elements
resolve under their RETIRED_ dictionary names. The regression test now
asserts every getTagsNameToEmpty() name resolves and is emptied.
@netlify

netlify Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for dcmjs2 ready!

Name Link
🔨 Latest commit 27b7992
🔍 Latest deploy log https://app.netlify.com/projects/dcmjs2/deploys/6b05f61f90a7c46f11e6e433
😎 Deploy Preview https://deploy-preview-510--dcmjs2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@wayfarer3130
wayfarer3130 merged commit 9fec4f2 into dcmjs-org:master Nov 24, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in dcmjs roadmap Nov 24, 2026
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.53.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

wayfarer3130 added a commit that referenced this pull request Nov 25, 2026
Record master (d236313) as a parent with -s ours; the tree stays the 1.0-beta tree. Master fixes #657, #622, #510, #625 and #632 are not in 1.x and need ports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
wayfarer3130 added a commit that referenced this pull request Nov 27, 2026
) (#674)

* fix: registerTag and anonymizer fixes from 0.53.3 (port of #510 and #625)

- registerTag() stores the tag in upper case and finds both cases, so a
  tag registered in lower case keeps its keyword when a file is read.
- The first registration of a name keeps the name; a warning names both
  tags.
- DicomMetaDictionary.entryForName() is the one lookup by name
  (standard keyword first, then a registerTag() name). It is used by
  denaturalizeDataset(), tagAsIntegerFromName(), entryFor() and
  cleanTags(), so cleanTags() empties a registered name in a custom list.
- dcmjs.data exports registerTag and dictionary again, as in 0.53.3.
- The anonymizer list has ResponsiblePersonRole, as in 0.53.3.
- MIGRATION.md states the nameMap difference from 0.53.3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix: registerTag name rules and tag registry requirements (review of #674)

- The tag of the first argument wins over entry.tag.
- A name that is the keyword of a different tag throws. The keyword of
  the same tag is accepted with no warning.
- When two tags use one name, the second tag gets its hex tag as its
  name and keeps its VR and VM, so a read and a write keep both values.
- A new name for a registered tag removes the old name.
- entryForName() reads only own entries of nameMap.
- docs/specs/registries.md: REG-U-18 to REG-U-21 for the tag registry;
  registries-implementation.md: REG-I-23 to REG-I-26.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

anonymizer uses incorrect tag names

2 participants