private InstanceStorageInfo(DicomCStoreRequest request, string storageRootFullPath, string calledAeTitle, uint associationId, IFileSystem fileSystem) { Guard.Against.Null(request, nameof(request)); Guard.Against.NullOrWhiteSpace(storageRootFullPath, nameof(storageRootFullPath)); Guard.Against.NullOrWhiteSpace(calledAeTitle, nameof(calledAeTitle)); Guard.Against.Null(fileSystem, nameof(fileSystem)); _fileSystem = fileSystem; AeStoragePath = storageRootFullPath; CalledAeTitle = calledAeTitle; var temp = string.Empty; var missingTags = new List <DicomTag>(); if (!request.Dataset.TryGetSingleValue(DicomTag.PatientID, out temp)) { missingTags.Add(DicomTag.PatientID); } else { PatientId = temp; } if (!request.Dataset.TryGetSingleValue(DicomTag.StudyInstanceUID, out temp)) { missingTags.Add(DicomTag.StudyInstanceUID); } else { StudyInstanceUid = temp; } if (!request.Dataset.TryGetSingleValue(DicomTag.SeriesInstanceUID, out temp)) { missingTags.Add(DicomTag.SeriesInstanceUID); } else { SeriesInstanceUid = temp; } if (missingTags.Count != 0) { throw new MissingRequiredTagException(missingTags.ToArray()); } SopClassUid = request.SOPClassUID.UID; SopInstanceUid = request.SOPInstanceUID.UID; AeStoragePath = fileSystem.Path.Combine(AeStoragePath, associationId.ToString()); AeStoragePath = fileSystem.Path.GetDicomStoragePath(AeStoragePath); PatientStoragePath = fileSystem.Path.Combine(AeStoragePath, PatientId.RemoveInvalidPathChars()); StudyStoragePath = fileSystem.Path.Combine(PatientStoragePath, StudyInstanceUid.RemoveInvalidPathChars()); SeriesStoragePath = fileSystem.Path.Combine(StudyStoragePath, SeriesInstanceUid.RemoveInvalidPathChars()); fileSystem.Directory.CreateDirectoryIfNotExists(SeriesStoragePath); InstanceStorageFullPath = fileSystem.Path.Combine(SeriesStoragePath, SopInstanceUid.RemoveInvalidPathChars()) + ".dcm"; }
public string CopyTo(string targetRoot) { Guard.Against.NullOrWhiteSpace(targetRoot, nameof(targetRoot)); var targetPath = _fileSystem.Path.Combine(targetRoot, PatientId.RemoveInvalidPathChars(), StudyInstanceUid.RemoveInvalidPathChars(), SeriesInstanceUid.RemoveInvalidPathChars()); _fileSystem.Directory.CreateDirectoryIfNotExists(targetPath); targetPath = _fileSystem.Path.Combine(targetPath, SopInstanceUid.RemoveInvalidPathChars()) + ".dcm"; _fileSystem.File.Copy(InstanceStorageFullPath, targetPath, true); return(targetPath); }