protected override void ProcessFile(Model.WorkQueueUid queueUid, DicomFile file, ClearCanvas.Dicom.Utilities.Xml.StudyXml stream, bool compare)
		{
            Platform.CheckFalse(compare, "compare");

			SopInstanceProcessor processor = new SopInstanceProcessor(Context);

			FileInfo fileInfo = new FileInfo(file.Filename);
			long fileSize = fileInfo.Length;
			processor.InstanceStats.FileSize = (ulong)fileSize;
			string sopInstanceUid = file.DataSet[DicomTags.SopInstanceUid].GetString(0, "File:" + fileInfo.Name);
			processor.InstanceStats.Description = sopInstanceUid;

			if (Study != null)
			{
				StudyComparer comparer = new StudyComparer();
				DifferenceCollection list = comparer.Compare(file, Study, ServerPartition.GetComparisonOptions());
				if (list != null && list.Count > 0)
				{
					Platform.Log(LogLevel.Warn, "Dicom file contains information inconsistent with the study in the system");
				}
			}

		    string groupID = ServerHelper.GetUidGroup(file, StorageLocation.ServerPartition, WorkQueueItem.InsertTime);
			processor.ProcessFile(groupID, file, stream, false, false, null, null);

			Statistics.StudyInstanceUid = StorageLocation.StudyInstanceUid;
			if (String.IsNullOrEmpty(processor.Modality) == false)
				Statistics.Modality = processor.Modality;

			// Update the statistics
			Statistics.NumInstances++;
		}
        /// <summary>
        /// Returns a value indicating whether the Dicom image must be reconciled.
        /// </summary>
        /// <param name="storageLocation"></param>
        /// <param name="message">The Dicom message</param>
        /// <returns></returns>
        private bool ShouldReconcile(StudyStorageLocation storageLocation, DicomMessageBase message)
        {
            Platform.CheckForNullReference(_context, "_context");
            Platform.CheckForNullReference(message, "message");

            if (_context.Study == null)
            {
                // the study doesn't exist in the database
                return(false);
            }

            StudyComparer        comparer = new StudyComparer();
            DifferenceCollection list     = comparer.Compare(message, storageLocation.Study, storageLocation.ServerPartition.GetComparisonOptions());

            if (list != null && list.Count > 0)
            {
                LogDifferences(message, list);
                return(true);
            }
            return(false);
        }
Exemple #3
0
        private bool UpdateNameBasedOnTheStudy(DicomFile file)
        {
            bool   updated = false;
            string orginalPatientsNameInFile = file.DataSet[DicomTags.PatientsName].ToString();

            if (_theStudy == null)
            {
                return(false);
            }

            StudyComparer        comparer  = new StudyComparer();
            ServerPartition      partition = ServerPartitionMonitor.Instance.FindPartition(_theStudy.ServerPartitionKey);
            DifferenceCollection list      = comparer.Compare(file, _theStudy, partition.GetComparisonOptions());

            if (list.Count == 1)
            {
                ComparisionDifference different = list[0];
                if (different.DicomTag.TagValue == DicomTags.PatientsName)
                {
                    if (DicomNameUtils.LookLikeSameNames(orginalPatientsNameInFile, _theStudy.PatientsName))
                    {
                        using (ServerCommandProcessor processor = new ServerCommandProcessor("Update Patient's Name"))
                        {
                            SetTagCommand command = new SetTagCommand(file, DicomTags.PatientsName, orginalPatientsNameInFile, _theStudy.PatientsName);
                            processor.AddCommand(command);

                            if (!processor.Execute())
                            {
                                throw new ApplicationException(String.Format("AUTO-CORRECTION Failed: Unable to correct the patient's name in the image. Reason: {0}",
                                                                             processor.FailureReason), processor.FailureException);
                            }

                            updated = true;
                        }
                    }
                }
            }
            return(updated);
        }
Exemple #4
0
        private bool UpdateNameBasedOnTheStudy(DicomFile file)
        {
            bool updated = false;
            string orginalPatientsNameInFile = file.DataSet[DicomTags.PatientsName].ToString();

            if (_theStudy==null)
            {
                return false;
            }

            StudyComparer comparer = new StudyComparer();
            ServerPartition partition = ServerPartitionMonitor.Instance.FindPartition(_theStudy.ServerPartitionKey);
            DifferenceCollection list = comparer.Compare(file, _theStudy, partition.GetComparisonOptions());

            if (list.Count == 1)
            {
                ComparisionDifference different = list[0];
                if (different.DicomTag.TagValue == DicomTags.PatientsName)
                {
                    if (DicomNameUtils.LookLikeSameNames(orginalPatientsNameInFile, _theStudy.PatientsName))
                    {
                        using (ServerCommandProcessor processor = new ServerCommandProcessor("Update Patient's Name"))
                        {
                            SetTagCommand command = new SetTagCommand(file, DicomTags.PatientsName, orginalPatientsNameInFile, _theStudy.PatientsName);
                            processor.AddCommand(command);

                            if (!processor.Execute())
                            {
                                throw new ApplicationException(String.Format("AUTO-CORRECTION Failed: Unable to correct the patient's name in the image. Reason: {0}",
                                                                             processor.FailureReason), processor.FailureException);
                            }

                            updated = true;
                        }
                    }
                }
            }
            return updated;
        }
Exemple #5
0
        protected override void ProcessFile(Model.WorkQueueUid queueUid, DicomFile file, ClearCanvas.Dicom.Utilities.Xml.StudyXml stream, bool compare)
        {
            Platform.CheckFalse(compare, "compare");

            SopInstanceProcessor processor = new SopInstanceProcessor(Context);

            FileInfo fileInfo = new FileInfo(file.Filename);
            long     fileSize = fileInfo.Length;

            processor.InstanceStats.FileSize = (ulong)fileSize;
            string sopInstanceUid = file.DataSet[DicomTags.SopInstanceUid].GetString(0, "File:" + fileInfo.Name);

            processor.InstanceStats.Description = sopInstanceUid;

            if (Study != null)
            {
                StudyComparer        comparer = new StudyComparer();
                DifferenceCollection list     = comparer.Compare(file, Study, ServerPartition.GetComparisonOptions());
                if (list != null && list.Count > 0)
                {
                    Platform.Log(LogLevel.Warn, "Dicom file contains information inconsistent with the study in the system");
                }
            }

            string groupID = ServerHelper.GetUidGroup(file, StorageLocation.ServerPartition, WorkQueueItem.InsertTime);

            processor.ProcessFile(groupID, file, stream, false, false, null, null);

            Statistics.StudyInstanceUid = StorageLocation.StudyInstanceUid;
            if (String.IsNullOrEmpty(processor.Modality) == false)
            {
                Statistics.Modality = processor.Modality;
            }

            // Update the statistics
            Statistics.NumInstances++;
        }
		/// <summary>
		/// Returns a value indicating whether the Dicom image must be reconciled.
		/// </summary>
		/// <param name="storageLocation"></param>
		/// <param name="message">The Dicom message</param>
		/// <returns></returns>
		private bool ShouldReconcile(StudyStorageLocation storageLocation, DicomMessageBase message)
		{
			Platform.CheckForNullReference(_context, "_context");
			Platform.CheckForNullReference(message, "message");

			if (_context.Study == null)
			{
				// the study doesn't exist in the database
				return false;
			}

		    StudyComparer comparer = new StudyComparer();
            DifferenceCollection list = comparer.Compare(message, storageLocation.Study, storageLocation.ServerPartition.GetComparisonOptions());

		    if (list != null && list.Count > 0)
		    {
		        LogDifferences(message, list);
		        return true;
		    }
		    return false;
		}