Example #1
0
        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";
        }
Example #2
0
        public override bool Equals(object obj)
        {
            if (obj is InstanceIdentifier identifier)
            {
                return(StudyInstanceUid.Equals(identifier.StudyInstanceUid, EqualsStringComparison) &&
                       SeriesInstanceUid.Equals(identifier.SeriesInstanceUid, EqualsStringComparison) &&
                       SopInstanceUid.Equals(identifier.SopInstanceUid, EqualsStringComparison));
            }

            return(false);
        }
        public override bool Equals(object obj)
        {
            if (obj is DicomInstanceId instanceId)
            {
                return(StudyInstanceUid.Equals(instanceId.StudyInstanceUid, EqualsStringComparison) &&
                       SeriesInstanceUid.Equals(instanceId.SeriesInstanceUid, EqualsStringComparison) &&
                       SopInstanceUid.Equals(instanceId.SopInstanceUid, EqualsStringComparison) &&
                       PartitionName.Equals(instanceId.PartitionName, EqualsStringComparison));
            }

            return(false);
        }
Example #4
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 10, Configuration.FieldSeparator),
                       Id,
                       AccessionIdentifier?.ToDelimitedString(),
                       RequestedProcedureId?.ToDelimitedString(),
                       StudyInstanceUid?.ToDelimitedString(),
                       ScheduledProcedureStepId?.ToDelimitedString(),
                       Modality?.ToDelimitedString(),
                       ProtocolCode != null ? string.Join(Configuration.FieldRepeatSeparator, ProtocolCode.Select(x => x.ToDelimitedString())) : null,
                       ScheduledStationName?.ToDelimitedString(),
                       ScheduledProcedureStepLocation != null ? string.Join(Configuration.FieldRepeatSeparator, ScheduledProcedureStepLocation.Select(x => x.ToDelimitedString())) : null,
                       ScheduledStationAeTitle
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Example #5
0
 // override object.GetHashCode
 public override int GetHashCode() => StudyInstanceUid.GetHashCode();
 public bool Equals(StudyAlert other)
 {
     return(StudyInstanceUid.Equals(other.StudyInstanceUid) &&
            AlertType == other.AlertType &&
            Message.Equals(other.Message, StringComparison.InvariantCultureIgnoreCase));
 }
Example #7
0
        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);
        }
 public override int GetHashCode()
 {
     return(0x256E197F ^ StudyInstanceUid.GetHashCode() ^ SeriesInstanceUid.GetHashCode() ^ SopInstanceUid.GetHashCode());
 }