-
Notifications
You must be signed in to change notification settings - Fork 6
Adding pseudonym to wador views #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
6e9ed11
adding pseudonym to wador views
chinacat567 cd86735
using pydicomweb-client
chinacat567 fd6c6b5
Merge branch 'main' into adit-pseudonym
chinacat567 32a21bb
lint fix, lockfile update
chinacat567 3ec96a7
fixing formatting
chinacat567 0524510
fixing merge conflicts
chinacat567 1c24d03
fixing formatting errors
chinacat567 1932e62
more formatting fixes
chinacat567 0cf5bff
parsing pseudonym
chinacat567 325470d
Merge branch 'main' into adit-pseudonym
chinacat567 83e29ea
adding char limit, wildcard validation and tests
chinacat567 3caa6ef
validator and test refac
chinacat567 c3ad5a4
shared pseudnymizer, test changes
chinacat567 aaf8340
bug fix
chinacat567 0e219c3
adit client deadcode removal
chinacat567 4daa0b5
pseudonymizer changes
chinacat567 7f2136e
refac validate_pseudonym -> _get_pseudonym
chinacat567 ba3e6ee
passing pseudonym through adit client and changing acceptance tests t…
chinacat567 0928602
reorg validator directory
chinacat567 8f4456d
adding metadata functions to adit_client
chinacat567 b40a44a
unit test fix
chinacat567 5bca9eb
Merge branch 'main' into adit-pseudonym
chinacat567 22a9d74
pydicomweb-client => dicomweb-client
chinacat567 9bd49c3
<broken> : pseduonymizer changes, pytest changes
chinacat567 2631705
bug fix
chinacat567 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from dicognito.anonymizer import Anonymizer | ||
| from dicognito.value_keeper import ValueKeeper | ||
| from django.conf import settings | ||
| from pydicom import Dataset | ||
|
|
||
|
|
||
| class Pseudonymizer: | ||
| """ | ||
| A utility class for pseudonymizing (or anonymizing) DICOM data. | ||
| """ | ||
|
|
||
| def __init__(self, pseudonym: str | None = None) -> None: | ||
chinacat567 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """ | ||
| Initialize the Pseudonymizer with an optional pseudonym. | ||
| :param pseudonym: The pseudonym to be used for the DICOM data. | ||
| """ | ||
| self.anonymizer = self._setup_anonymizer() | ||
| self.pseudonym = pseudonym | ||
|
|
||
| def _setup_anonymizer(self) -> Anonymizer: | ||
| """ | ||
| Set up the anonymizer instance and configure it to skip specific elements. | ||
| :return: An instance of the Anonymizer class. | ||
| """ | ||
| anonymizer = Anonymizer() | ||
| for element in settings.SKIP_ELEMENTS_ANONYMIZATION: | ||
| anonymizer.add_element_handler(ValueKeeper(element)) | ||
| return anonymizer | ||
|
|
||
| def pseudonymize( | ||
| self, | ||
| ds: Dataset, | ||
| ) -> None: | ||
| """ | ||
| Pseudonymize the given DICOM dataset using the anonymizer and optional pseudonym. | ||
| :param ds: The DICOM dataset to be pseudonymized. | ||
| """ | ||
| if self.pseudonym: | ||
| # Replace PatientID and PatientName with the provided pseudonym. | ||
| self.anonymizer.anonymize(ds) # Apply anonymization to the dataset. | ||
| ds.PatientID = self.pseudonym | ||
| ds.PatientName = self.pseudonym | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.