示例#1
0
		private StudyData GetAnonymizedStudyData(StudyData original)
		{
			if (_anonymizeStudyDataDelegate != null)
				return _anonymizeStudyDataDelegate(original.Clone());
			else
				return StudyDataPrototype.Clone();
		}
			public ReadOnlyCollection<ValidationFailureDescription> GetValidationFailures(StudyData originalData, StudyData anonymizedData)
			{
				_failures = new List<ValidationFailureDescription>();

				ValidatePatientNamesNotEqual(originalData.PatientsName, anonymizedData.PatientsName);
				ValidateNotEqual(originalData.PatientId, anonymizedData.PatientId, "PatientId");
				ValidateNotEqual(originalData.AccessionNumber, anonymizedData.AccessionNumber, "AccessionNumber");
				ValidateNotEqual(originalData.StudyId, anonymizedData.StudyId, "StudyId");

				if (!IsOptionSet(_options, ValidationOptions.AllowEqualBirthDate))
					ValidateNotEqual(originalData.PatientsBirthDateRaw, anonymizedData.PatientsBirthDateRaw, "PatientsBirthDate");
				if (!IsOptionSet(_options, ValidationOptions.AllowEmptyPatientId))
					ValidateNotEmpty(anonymizedData.PatientId, "PatientId");
				if (!IsOptionSet(_options, ValidationOptions.AllowEmptyPatientName))
					ValidateNotEmpty(anonymizedData.PatientsNameRaw, "PatientsName");

				ReadOnlyCollection<ValidationFailureDescription> failures = _failures.AsReadOnly();
				_failures = null;
				return failures;
			}
示例#3
0
		private StudyData GetAnonymizedStudyData()
		{
			StudyData originalData = new StudyData();
			originalData.LoadFrom(_currentFile);

			_oldStudyDate = originalData.StudyDate;

			if (string.IsNullOrEmpty(originalData.StudyInstanceUid))
				throw new DicomAnonymizerException("The StudyInstanceUid in the source file cannot be empty.");

			StudyData anonymizedData;
			if (_anonymizedStudyDataMap.ContainsKey(originalData.StudyInstanceUid))
			{
				anonymizedData = _anonymizedStudyDataMap[originalData.StudyInstanceUid];
			}
			else
			{
				anonymizedData = GetAnonymizedStudyData(originalData);

				// generate the new study uid if it hasn't already been remapped
				if (_uidMap.ContainsKey(originalData.StudyInstanceUid))
					anonymizedData.StudyInstanceUid = _uidMap[originalData.StudyInstanceUid];
				else
					anonymizedData.StudyInstanceUid = _uidMap[originalData.StudyInstanceUid] = DicomUid.GenerateUid().UID;

				if (String.IsNullOrEmpty(anonymizedData.StudyInstanceUid) || anonymizedData.StudyInstanceUid == originalData.StudyInstanceUid)
					throw new DicomAnonymizerException("An error occurred while generating a new Uid.");

				ReadOnlyCollection<ValidationFailureDescription> failures = _validationStrategy.GetValidationFailures(originalData, anonymizedData);
				if (failures.Count > 0)
					throw new DicomAnonymizerValidationException("At least one validation failure has occurred.", failures);

				_uidMap[originalData.StudyInstanceUid] = anonymizedData.StudyInstanceUid;

				//store the anonymized data.
				_anonymizedStudyDataMap[originalData.StudyInstanceUid] = anonymizedData;
			}

			_newStudyDate = anonymizedData.StudyDate;

			return anonymizedData;
		}