Skip to content

feat(anonymizer) - export Array tagNamesToEmpty and modify cleanTags - #303

Merged
pieper merged 3 commits into
dcmjs-org:masterfrom
juliencastelneau:anonymizer_enhancement
Sep 13, 2022
Merged

pieper merged 3 commits into
dcmjs-org:masterfrom
juliencastelneau:anonymizer_enhancement

Conversation

@juliencastelneau

Copy link
Copy Markdown
Contributor
  • export Array tagNamesToEmpty => Modify (add or remove) values before calling cleanTags
  • add dict as parameter to function cleanTags => Choose which tags you want to modify for de-identification
    For instance, a call to anonymizer should be:
               const { cleanTags, tagNamesToEmpty } = dcmjs.anonymizer;

                var tagsToReplace = {
                    "00100010":   "ANON^PATIENT",
                    "00100020":   "ANON^ID"
                }
                var seriesDescription = "SeriesDescription";
                if (tagNamesToEmpty.indexOf(seriesDescription) != -1) {
                    tagNamesToEmpty.splice(tagNamesToEmpty.indexOf(seriesDescription), 1);
                } 
                var studyDescription = "StudyDescription";
                if (tagNamesToEmpty.indexOf(studyDescription) == -1) {
                    tagNamesToEmpty.push(studyDescription);
                } 

                cleanTags(dicomDict.dict, tagsToReplace);

…function cleanTags -> manage the tags to anonymize/modify in dicom

@pieper pieper left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this 👍

Comment thread src/anonymizer.js Resolved
@juliencastelneau

Copy link
Copy Markdown
Contributor Author

Hello,
Is there an issue with the PR ?
@pieper I made the changes you requested.
Maybe I do not understand something. Do you want another modification ?
thx

@pieper
pieper merged commit 42a7ca7 into dcmjs-org:master Sep 13, 2022
@pieper

pieper commented Sep 13, 2022

Copy link
Copy Markdown
Collaborator

Thanks for the contribution and the reminder 👍

@pieper

pieper commented Sep 13, 2022

Copy link
Copy Markdown
Collaborator

@juliencastelneau

Copy link
Copy Markdown
Contributor Author

The test fails because I added an argument to the method cleanTags
I think there are 2 ways to solve.

  1. Modify the test:

Add the lines below in anonymizer.test.js (line 26)

    var tagsToReplace = {
        "00100010":   "ANON^PATIENT",
    }
    
    // when
    cleanTags(dicomDict.dict, tagsToReplace);

instead of

    cleanTags(dicomDict.dict);
  1. Modify the method cleanTags to ensure the behaviour is unchanged:
export function cleanTags(
    dict,
    tagNamesToReplace = undefined,
    customTagNamesToEmpty = undefined
) {
    
    if (tagNamesToReplace==undefined) {
         tagNamesToReplace = {
            "00100010":   "ANON^PATIENT",
            "00100020":   "ANON^ID"
         }
    }
    
    var tags =
        customTagNamesToEmpty != undefined
            ? customTagNamesToEmpty
            : tagNamesToEmpty;

@pieper The best way is to modify the method cleanTags I guess.
Do I need to make a new PR ?

@pieper

pieper commented Sep 13, 2022

Copy link
Copy Markdown
Collaborator

Thanks for looking into this. I think the second option is better since it maintains backwards compatibility for the API. We should also add a new test demonstrating the ways to use the method and confirm it keeps working.

Yes, a new PR would be great since this has already been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants