12345678910111213141516171819202122232425262728293031 |
- def _modify_dataset(
- self,
- anonymizer: Anonymizer,
- pseudonym: str,
- ds: Dataset,
- ) -> None:
- """Optionally pseudonymize an incoming dataset with the given pseudonym
- and add the trial ID and name to the DICOM header if specified."""
- if pseudonym:
- # All dates get pseudonymized, but we want to retain the study date.
- study_date = ds.StudyDate
- anonymizer.anonymize(ds)
- ds.StudyDate = study_date
- ds.PatientID = pseudonym
- ds.PatientName = pseudonym
- trial_protocol_id = (self.transfer_task.job.trial_protocol_id,)
- trial_protocol_name = self.transfer_task.job.trial_protocol_name
- if trial_protocol_id:
- ds.ClinicalTrialProtocolID = trial_protocol_id
- if trial_protocol_name:
- ds.ClinicalTrialProtocolName = trial_protocol_name
- if pseudonym and trial_protocol_id:
- session_id = f"{ds.StudyDate}-{ds.StudyTime}"
- ds.PatientComments = f"Project:{trial_protocol_id} Subject:{pseudonym} Session:{pseudonym}_{session_id}"
|