private void Initialize()
        {
            _study          = Study.Find(ServerExecutionContext.Current.ReadContext, _studyLocation.StudyInstanceUid, _partition);
            _curPatient     = _study.LoadPatient(ServerExecutionContext.Current.ReadContext);
            _oldPatientInfo = new PatientInfo
            {
                Name              = _curPatient.PatientsName,
                PatientId         = _curPatient.PatientId,
                IssuerOfPatientId = _curPatient.IssuerOfPatientId
            };

            _seriesInstanceUid = _file.DataSet[DicomTags.SeriesInstanceUid].ToString();
            var broker = ServerExecutionContext.Current.ReadContext.GetBroker <ISeriesEntityBroker>();
            var select = new SeriesSelectCriteria();

            select.SeriesInstanceUid.EqualTo(_seriesInstanceUid);
            select.ServerPartitionKey.EqualTo(_partition.Key);
            _curSeries = broker.FindOne(select);

            _newPatientInfo = new PatientInfo(_oldPatientInfo);
            _file.DataSet.LoadDicomFields(_newPatientInfo);

            _newPatient = FindPatient(_newPatientInfo, ServerExecutionContext.Current.ReadContext);
            _patientInfoIsNotChanged = _newPatientInfo.Equals(_oldPatientInfo);
        }
		private void Initialize()
		{
			_backupDir = ProcessorContext.BackupDirectory;

				_oldStudyPath = _oldStudyLocation.GetStudyPath();
				_oldStudyInstanceUid = _oldStudyLocation.StudyInstanceUid;
				_oldStudyFolder = _oldStudyLocation.StudyFolder;
				_newStudyInstanceUid = _oldStudyInstanceUid;

			_study = _oldStudyLocation.LoadStudy(ServerExecutionContext.Current.ReadContext);
				_totalSopCount = _study.NumberOfStudyRelatedInstances;
			_curPatient = _study.LoadPatient(ServerExecutionContext.Current.ReadContext);
				_oldPatientInfo = new PatientInfo
				                  	{
				                  		Name = _curPatient.PatientsName,
				                  		PatientId = _curPatient.PatientId,
				                  		IssuerOfPatientId = _curPatient.IssuerOfPatientId
				                  	};

				_newPatientInfo = new PatientInfo(_oldPatientInfo);
				Debug.Assert(_newPatientInfo.Equals(_oldPatientInfo));

				foreach (BaseImageLevelUpdateCommand command in _commands)
				{
					ImageLevelUpdateEntry imageLevelUpdate = command.UpdateEntry;
					if (imageLevelUpdate == null)
						continue;

					if (imageLevelUpdate.TagPath.Tag.TagValue == DicomTags.StudyInstanceUid)
					{
						_newStudyInstanceUid = imageLevelUpdate.GetStringValue();
					}
					else if (imageLevelUpdate.TagPath.Tag.TagValue == DicomTags.PatientId)
					{
						_newPatientInfo.PatientId = imageLevelUpdate.GetStringValue();
					}
					else if (imageLevelUpdate.TagPath.Tag.TagValue == DicomTags.IssuerOfPatientId)
					{
						_newPatientInfo.IssuerOfPatientId = imageLevelUpdate.GetStringValue();
					}
					else if (imageLevelUpdate.TagPath.Tag.TagValue == DicomTags.PatientsName)
					{
						_newPatientInfo.Name = imageLevelUpdate.GetStringValue();
					}
				}

				Platform.CheckForNullReference(_newStudyInstanceUid, "_newStudyInstanceUid");

				NewStudyPath = Path.Combine(_oldStudyLocation.FilesystemPath, _partition.PartitionFolder);
				NewStudyPath = Path.Combine(NewStudyPath, _oldStudyFolder);
				NewStudyPath = Path.Combine(NewStudyPath, _newStudyInstanceUid);

			_newPatient = FindPatient(_newPatientInfo, ServerExecutionContext.Current.ReadContext);
				_patientInfoIsNotChanged = _newPatientInfo.Equals(_oldPatientInfo);

				Statistics.InstanceCount = _study.NumberOfStudyRelatedInstances;
				Statistics.StudySize = (ulong) _oldStudyLocation.LoadStudyXml().GetStudySize();

				// The study path will be changed. We will need to delete the original folder at the end.
				// May be too simple to test if two paths are the same. But let's assume it is good enough for 99% of the time.
				_deleteOriginalFolder = NewStudyPath != _oldStudyPath;
				_initialized = true;
			}
        public void Equals_PatientsWithSameIDAndNameAreEqual()
        {
            // Arrange
            var birthNumber = new BirthNumber("9107256444");
            var name = new PatientName("Doe^John");
            var patient1 = new PatientInfo
            {
                PatientID = birthNumber,
                PatientName = name
            };
            var patient2 = new PatientInfo
            {
                PatientID = birthNumber,
                PatientName = name
            };

            // Act
            var result = patient1.Equals(patient2);

            // Assert
            Assert.That(result, Is.True);
        }
        public void Equals_WithItself_ReturnsTrue()
        {
            // Arrange
            var birthNumber = new BirthNumber("9107256444");
            var patient = new PatientInfo
            {
                PatientID = birthNumber
            };

            // Act
            var result = patient.Equals(patient);

            // Assert
            Assert.That(result, Is.True);
        }
        public void Equals_WithDifferentType_ReturnsFalse()
        {
            // Arrange
            var birthNumber = new BirthNumber("9107256444");
            var name = new PatientName("Doe^John");
            var patient = new PatientInfo
            {
                PatientID = birthNumber,
                PatientName = name
            };
            
            // Act
            var result = patient.Equals(new object());

            // Assert
            Assert.That(result, Is.False);
        }
        public void Equals_PatientsWithDifferentIDAndNameAreNotEqual()
        {
            // Arrange
            var patient1 = new PatientInfo
            {
                PatientID = new BirthNumber("9107256444"),
                PatientName = new PatientName("Doe^John")
            };
            var patient2 = new PatientInfo
            {
                PatientID = new BirthNumber("1510180012"),
                PatientName = new PatientName("Smith^Jack")
            };

            // Act
            var result = patient1.Equals(patient2);

            // Assert
            Assert.That(result, Is.False);
        }
		private void Initialize()
		{
			_study = Study.Find(ServerExecutionContext.Current.ReadContext,_studyLocation.StudyInstanceUid, _partition);
			_curPatient = _study.LoadPatient(ServerExecutionContext.Current.ReadContext);
			_oldPatientInfo = new PatientInfo
				{
					PatientsName = _curPatient.PatientsName,
					PatientId = _curPatient.PatientId,
					IssuerOfPatientId = _curPatient.IssuerOfPatientId
				};

			_seriesInstanceUid = _file.DataSet[DicomTags.SeriesInstanceUid].ToString();
			var broker = ServerExecutionContext.Current.ReadContext.GetBroker<ISeriesEntityBroker>();
			var select = new SeriesSelectCriteria();
			select.SeriesInstanceUid.EqualTo(_seriesInstanceUid);
			select.ServerPartitionKey.EqualTo(_partition.Key);
			_curSeries = broker.FindOne(select);

			_newPatientInfo = new PatientInfo(_oldPatientInfo);
			_file.DataSet.LoadDicomFields(_newPatientInfo);

			_newPatient = FindPatient(_newPatientInfo, ServerExecutionContext.Current.ReadContext);
			_patientInfoIsNotChanged = _newPatientInfo.Equals(_oldPatientInfo);
		}