ClearCanvas.ImageServer.Core.Edit.UpdateStudyCommand.Initialize C# (CSharp) Method

Initialize() private method

private Initialize ( ) : void
return void
		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
				                  	{
					PatientsName = _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.PatientsName = 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);
			_patientInfoChanged = !_newPatientInfo.AreSame(_oldPatientInfo, false);

				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;
			}