Esempio n. 1
0
		private SeriesData GetAnonymizedSeriesData(SeriesData original)
		{
			if (_anonymizeSeriesDataDelegate != null)
				return _anonymizeSeriesDataDelegate(original.Clone());
			else
				return SeriesDataPrototype.Clone();
		}
			/// <summary>
			/// Gets a list of <see cref="ValidationFailureDescription"/>s describing all validation failures.
			/// </summary>
			/// <remarks>
			/// When an empty list is returned, it means there were no validation failures.
			/// </remarks>
			internal ReadOnlyCollection<ValidationFailureDescription> GetValidationFailures(SeriesData originalData, SeriesData anonymizedData)
			{
				_failures = new List<ValidationFailureDescription>();
				ReadOnlyCollection<ValidationFailureDescription> failures = _failures.AsReadOnly();

				//nothing to validate for now.

				_failures = null;
				return failures;
			}
Esempio n. 3
0
		private SeriesData GetAnonymizedSeriesData()
		{
			string originalSeriesInstanceUid = _currentFile.DataSet[DicomTags.SeriesInstanceUid].ToString();
			if (string.IsNullOrEmpty(originalSeriesInstanceUid))
				throw new DicomAnonymizerException("The SeriesInstanceUid of the source file cannot be empty.");

			SeriesData anonymizedData;
			if (_anonymizedSeriesDataMap.ContainsKey(originalSeriesInstanceUid))
			{
				anonymizedData = _anonymizedSeriesDataMap[originalSeriesInstanceUid];
			}
			else
			{
				SeriesData originalData = new SeriesData();
				originalData.LoadFrom(_currentFile);

				anonymizedData = GetAnonymizedSeriesData(originalData);

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

				if (String.IsNullOrEmpty(anonymizedData.SeriesInstanceUid) || anonymizedData.SeriesInstanceUid == originalData.SeriesInstanceUid)
					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.SeriesInstanceUid] = anonymizedData.SeriesInstanceUid;

				_anonymizedSeriesDataMap[originalSeriesInstanceUid] = anonymizedData;
			}

			return anonymizedData;
		}