/// <summary>
        /// Creates an instance of <see cref="StudyDetails"/> base on a <see cref="Study"/> object.
        /// </summary>
        /// <param name="study"></param>
        /// <returns></returns>
        public StudyDetails CreateStudyDetail(Study study)
        {
            var details = new StudyDetails();
            details.StudyInstanceUID = study.StudyInstanceUid;
            details.PatientName = study.PatientsName;
            details.AccessionNumber = study.AccessionNumber;
            details.PatientID = study.PatientId;
            details.StudyDescription = study.StudyDescription;
            details.StudyDate = study.StudyDate;
            details.StudyTime = study.StudyTime;

            var controller = new StudyController();
            using (IReadContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                details.Modalities = controller.GetModalitiesInStudy(ctx, study);
            }

            if (study.StudyInstanceUid != null)
            {
            	StudyStorage storages = StudyStorage.Load(study.StudyStorageKey);
                if (storages != null)
                {
                    details.WriteLock = storages.WriteLock;
                	details.ReadLock = storages.ReadLock;
                    details.Status = storages.StudyStatusEnum.ToString();
                }
            }
			
            return details;
        }
Example #2
0
        public IList<Series> GetSeries(Study study)
        {
            SeriesSelectCriteria criteria = new SeriesSelectCriteria();

            criteria.StudyKey.EqualTo(study.Key);

            return _seriesAdaptor.Get(criteria);
        }
Example #3
0
 public ValidationStudyInfo(Study theStudy, ServerPartition partition)
 {
     ServerAE = partition.AeTitle;
     PatientsName = theStudy.PatientsName;
     PatientsId = theStudy.PatientId;
     StudyInstaneUid = theStudy.StudyInstanceUid;
     AccessionNumber = theStudy.AccessionNumber;
     StudyDate = theStudy.StudyDate;
 }
Example #4
0
 /// <summary>
 /// Loads the related <see cref="Study"/> entity.
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 private Study LoadStudy(IPersistenceContext context)
 {
     if (_study == null)
     {
         lock (SyncRoot)
         {
             _study = Study.Find(context, StudyStorageKey);
         }
     }
     return _study;
 }
Example #5
0
        private void DoSeriesLevelValidation(StudyStorageLocation storageLocation, StudyXml studyXml, Study study)
        {
            IDictionary<string, Series> seriesList = study.Series;
            foreach (var entry in seriesList)
            {
                Series series = entry.Value;
                SeriesXml seriesXml = studyXml[series.SeriesInstanceUid];

                ValidateSeries(storageLocation, series, seriesXml);

            }
        }
Example #6
0
        /// <summary>
        /// Loads the related <see cref="Study"/> entity.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Study LoadStudy(IPersistenceContext context)
        {
            StudyStorage storage = LoadStudyStorage(context);

            if (_study == null)
            {
                lock (_syncLock)
                {
                    _study = storage.LoadStudy(context);
                }
            }
            return _study;
        }
        private void LoadAdditionalEntities()
        {
            Debug.Assert(ServerPartition != null);
            Debug.Assert(StorageLocation != null);

			using (ServerExecutionContext context = new ServerExecutionContext())
			{
				if (_filesystem != null)
					_filesystem = FilesystemMonitor.Instance.GetFilesystemInfo(StorageLocation.FilesystemKey);
				_study = StorageLocation.LoadStudy(context.ReadContext);
				_patient = Patient.Load(context.ReadContext, _study.PatientKey);
			}
        }
Example #8
0
        /// <summary>
        /// Returns an instance of <see cref="PatientSummary"/> for a <see cref="Study"/>.
        /// </summary>
        /// <param name="study"></param>
        /// <returns></returns>
        /// <remark>
        /// 
        /// </remark>
        static public PatientSummary CreatePatientSummary(Study study)
        {
            PatientSummary patient = new PatientSummary();

            patient.PatientId = study.PatientId;
            patient.Birthdate = study.PatientsBirthDate;
            patient.PatientName = study.PatientsName;
            patient.Sex = study.PatientsSex;

            PatientAdaptor adaptor = new PatientAdaptor();
            Patient pat = adaptor.Get(study.PatientKey);
            patient.IssuerOfPatientId = pat.IssuerOfPatientId;
            return patient;
        }
Example #9
0
        public Study GetStudy()
        {
            if (_study == null)
            {
                lock (SyncRoot)
                {
                    using (var context = new ServerExecutionContext())
                    {
                        _study = LoadStudy(context.ReadContext);
                    }
                }
            }

            return _study;
        }
Example #10
0
        private void LoadRelatedEntities()
        {
            if (_study==null || _studyStorage==null)
            {
                using (var context = new ServerExecutionContext())
                {
                    lock (SyncRoot)
                    {
                        if (_study == null)
                            _study = LoadStudy(context.ReadContext);

                        if (_studyStorage == null)
                            _studyStorage = LoadStudyStorage(context.ReadContext);
                    }
                }    
            }
        }
Example #11
0
        public Study GetStudy()
        {
            if (_study == null)
            {
                lock (SyncRoot)
                {
                    // TODO: Use ExecutionContext to re-use db connection if possible
                    // This however requires breaking the Common --> Model dependency.
                    using (IReadContext readContext = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                    {
                        _study = LoadStudy(readContext);
                    }
                }
            }

            return _study;
        }
Example #12
0
        private void LoadRelatedEntities()
        {
            if (_study==null || _studyStorage==null)
            {
                using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                {
                    lock (SyncRoot)
                    {
                        if (_study == null)
                            _study = LoadStudy(context);

                        if (_studyStorage == null)
                            _studyStorage = LoadStudyStorage(context);
                    }

                }    
            }
            
        }
Example #13
0
        private void LoadRelatedEntities()
        {
            if (_study == null || _studyStorage == null)
            {
                using (var context = new ServerExecutionContext())
                {
                    lock (SyncRoot)
                    {
                        if (_study == null)
                        {
                            _study = LoadStudy(context.ReadContext);
                        }

                        if (_studyStorage == null)
                        {
                            _studyStorage = LoadStudyStorage(context.ReadContext);
                        }
                    }
                }
            }
        }
Example #14
0
        private void LoadRelatedEntities()
        {
            if (_study == null || _studyStorage == null)
            {
                using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                {
                    lock (SyncRoot)
                    {
                        if (_study == null)
                        {
                            _study = LoadStudy(context);
                        }

                        if (_studyStorage == null)
                        {
                            _studyStorage = LoadStudyStorage(context);
                        }
                    }
                }
            }
        }
Example #15
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="thePartition"></param>
		/// <param name="location"></param>
		/// <param name="thePatient"></param>
		/// <param name="theStudy"></param>
		public StudyEditor(ServerPartition thePartition, StudyStorageLocation location, Patient thePatient, Study theStudy, WorkQueue workQueue)
		{
			FailureReason = string.Empty;
			Platform.CheckForNullReference(thePartition, "thePartition");
			Platform.CheckForNullReference(location, "location");
			Platform.CheckForNullReference(thePatient, "thePatient");
			Platform.CheckForNullReference(theStudy, "theStudy");

			ServerPartition = thePartition;
			StorageLocation = location;
			
            Patient = thePatient;
            Study = theStudy;
			_workQueue = workQueue;

            // Scrub for invalid characters that may cause a failure when the Xml is generated for the history
		    Patient.PatientId = XmlUtils.XmlCharacterScrub(Patient.PatientId);
            Patient.PatientsName = XmlUtils.XmlCharacterScrub(Patient.PatientsName);
            
            Study.StudyDescription = XmlUtils.XmlCharacterScrub(Study.StudyDescription);
            Study.ReferringPhysiciansName = XmlUtils.XmlCharacterScrub(Study.ReferringPhysiciansName);
            Study.PatientId = XmlUtils.XmlCharacterScrub(Study.PatientId);
            Study.PatientsName = XmlUtils.XmlCharacterScrub(Study.PatientsName);            
		}
Example #16
0
        static public Study Insert(IUpdateContext update, Study entity)
        {
            var broker        = update.GetBroker <IStudyEntityBroker>();
            var updateColumns = new StudyUpdateColumns();

            updateColumns.StudyInstanceUid              = entity.StudyInstanceUid;
            updateColumns.ServerPartitionKey            = entity.ServerPartitionKey;
            updateColumns.PatientKey                    = entity.PatientKey;
            updateColumns.NumberOfStudyRelatedSeries    = entity.NumberOfStudyRelatedSeries;
            updateColumns.NumberOfStudyRelatedInstances = entity.NumberOfStudyRelatedInstances;
            updateColumns.QCStatusEnum                  = entity.QCStatusEnum;
            updateColumns.QCOutput                = entity.QCOutput;
            updateColumns.QCUpdateTimeUtc         = entity.QCUpdateTimeUtc;
            updateColumns.OrderKey                = entity.OrderKey;
            updateColumns.StudySizeInKB           = entity.StudySizeInKB;
            updateColumns.ResponsiblePerson       = entity.ResponsiblePerson;
            updateColumns.ResponsibleOrganization = entity.ResponsibleOrganization;
            updateColumns.QueryXml                = entity.QueryXml;
            updateColumns.SpecificCharacterSet    = entity.SpecificCharacterSet;
            updateColumns.StudyStorageKey         = entity.StudyStorageKey;
            updateColumns.PatientsName            = entity.PatientsName;
            updateColumns.PatientId               = entity.PatientId;
            updateColumns.IssuerOfPatientId       = entity.IssuerOfPatientId;
            updateColumns.PatientsBirthDate       = entity.PatientsBirthDate;
            updateColumns.PatientsAge             = entity.PatientsAge;
            updateColumns.PatientsSex             = entity.PatientsSex;
            updateColumns.StudyDate               = entity.StudyDate;
            updateColumns.StudyTime               = entity.StudyTime;
            updateColumns.AccessionNumber         = entity.AccessionNumber;
            updateColumns.StudyId                 = entity.StudyId;
            updateColumns.StudyDescription        = entity.StudyDescription;
            updateColumns.ReferringPhysiciansName = entity.ReferringPhysiciansName;
            Study newEntity = broker.Insert(updateColumns);

            return(newEntity);
        }
Example #17
0
        public int GetCountPendingWorkQueueItems(Study study)
        {
            Platform.CheckForNullReference(study, "Study");

            var adaptor = new WorkQueueAdaptor();
            var workQueueCriteria = new WorkQueueSelectCriteria();
            workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey);
            workQueueCriteria.WorkQueueStatusEnum.In(new [] {WorkQueueStatusEnum.Idle, WorkQueueStatusEnum.InProgress, WorkQueueStatusEnum.Pending});
            return adaptor.GetCount(workQueueCriteria);
        }
Example #18
0
        public IList<WorkQueue> GetWorkQueueItems(Study study)
        {
            Platform.CheckForNullReference(study, "Study");

            WorkQueueAdaptor adaptor = new WorkQueueAdaptor();
            WorkQueueSelectCriteria workQueueCriteria = new WorkQueueSelectCriteria();
			workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey);
            workQueueCriteria.ScheduledTime.SortAsc(0);
            return adaptor.Get(workQueueCriteria);
        }
Example #19
0
    	/// <summary>
		/// Returns a value indicating whether the specified study has been scheduled for delete.
		/// </summary>
		/// <param name="study"></param>
		/// <param name="read"></param>
		/// <returns></returns>
		public string GetModalitiesInStudy(IPersistenceContext read, Study study)
		{
			Platform.CheckForNullReference(study, "Study");

            IQueryModalitiesInStudy select = read.GetBroker<IQueryModalitiesInStudy>();
            ModalitiesInStudyQueryParameters parms = new ModalitiesInStudyQueryParameters { StudyKey = study.Key };
            IList<Series> seriesList = select.Find(parms);
			List<string> modalities = new List<string>();
			
			foreach (Series series in seriesList)
			{
				bool found = false;
				foreach (string modality in modalities)
					if (modality.Equals(series.Modality))
					{
						found = true;
						break;
					}
				if (!found)
					modalities.Add(series.Modality);
			}

			string modalitiesInStudy = "";
			foreach (string modality in modalities)
				if (modalitiesInStudy.Length == 0)
					modalitiesInStudy = modality;
				else
					modalitiesInStudy += "\\" + modality;

			return modalitiesInStudy;
		}
Example #20
0
        /// <summary>
        /// Returns a value indicating whether the specified study has been scheduled for delete.
        /// </summary>
        /// <param name="study"></param>
        /// <param name="workQueueType"></param>
        /// <returns></returns>           
		private static bool IsStudyInWorkQueue(Study study, WorkQueueTypeEnum workQueueType)
        {
        	Platform.CheckForNullReference(study, "Study");

        	WorkQueueAdaptor adaptor = new WorkQueueAdaptor();
        	WorkQueueSelectCriteria workQueueCriteria = new WorkQueueSelectCriteria();
        	workQueueCriteria.WorkQueueTypeEnum.EqualTo(workQueueType);
        	workQueueCriteria.ServerPartitionKey.EqualTo(study.ServerPartitionKey);
        	workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey);

        	workQueueCriteria.WorkQueueStatusEnum.EqualTo(WorkQueueStatusEnum.Pending);

        	IList<WorkQueue> list = adaptor.Get(workQueueCriteria);
        	if (list != null && list.Count > 0)
        		return true;

        	workQueueCriteria.WorkQueueStatusEnum.EqualTo(WorkQueueStatusEnum.Idle); // not likely but who knows
        	list = adaptor.Get(workQueueCriteria);
        	if (list != null && list.Count > 0)
        		return true;

        	return false;
        }
Example #21
0
        public IList<StudyStorageLocation> GetStudyStorageLocation(Study study)
        {
            Platform.CheckForNullReference(study, "Study");

            
            IQueryStudyStorageLocation select = HttpContext.Current.GetSharedPersistentContext().GetBroker<IQueryStudyStorageLocation>();
            StudyStorageLocationQueryParameters parms = new StudyStorageLocationQueryParameters
                                                        	{StudyStorageKey = study.StudyStorageKey};

        	IList<StudyStorageLocation> storage = select.Find(parms);

            if (storage == null)
			{
				storage = new List<StudyStorageLocation>();
			    Platform.Log(LogLevel.Warn, "Unable to find storage location for Study item: {0}",
                             study.GetKey().ToString());
            }

            if (storage.Count > 1)
            {
                Platform.Log(LogLevel.Warn,
                             "StudyController:GetStudyStorageLocation: multiple study storage found for study {0}",
                             study.GetKey().Key);
            }

            return storage;        
        }
Example #22
0
		public int GetArchiveQueueCount(Study study)
		{
			Platform.CheckForNullReference(study, "Study");

			ArchiveQueueAdaptor adaptor = new ArchiveQueueAdaptor();
			ArchiveQueueSelectCriteria archiveQueueCriteria = new ArchiveQueueSelectCriteria();
			archiveQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey);
			archiveQueueCriteria.ScheduledTime.SortDesc(0);
			return adaptor.GetCount(archiveQueueCriteria);
		}
Example #23
0
        public int GetCountPendingExternalEditWorkQueueItems(Study study)
        {
            Platform.CheckForNullReference(study, "Study");

            var adaptor = new WorkQueueAdaptor();
            var workQueueCriteria = new WorkQueueSelectCriteria();
            workQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey);
            workQueueCriteria.WorkQueueTypeEnum.EqualTo(WorkQueueTypeEnum.ExternalEdit);
            return adaptor.GetCount(workQueueCriteria);
        }
Example #24
0
 public bool MoveStudy(Study study, Device device)
 {
     return MoveStudy(study, device, null);
 }
Example #25
0
		/// <summary>
		/// Restore a nearline study.
		/// </summary>
		/// <param name="study">The <see cref="Study"/> to restore.</param>
		/// <returns>true on success, false on failure.</returns>
		public bool RestoreStudy(Study study)
		{
			return _partitionArchiveAdaptor.RestoreStudy(study);
		}
Example #26
0
 public Study LoadStudy(IPersistenceContext context)
 {
     return(Study.Find(context, StudyInstanceUid, ServerPartition));
 }
Example #27
0
        public IList<FilesystemQueue> GetFileSystemQueueItems(Study study)
        {
            Platform.CheckForNullReference(study, "Study");

            FileSystemQueueAdaptor adaptor = new FileSystemQueueAdaptor();
            FilesystemQueueSelectCriteria fileSystemQueueCriteria = new FilesystemQueueSelectCriteria();
			fileSystemQueueCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey);
            fileSystemQueueCriteria.ScheduledTime.SortAsc(0);
            return adaptor.Get(fileSystemQueueCriteria);
        }
Example #28
0
        public void EditStudy(Study study, List<UpdateItem> updateItems, string reason)
        {
            Platform.Log(LogLevel.Info, String.Format("Editing study {0}", study.StudyInstanceUid));

			using (IUpdateContext ctx = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
			{
                IList<WorkQueue> entries = StudyEditorHelper.EditStudy(ctx, study.StudyStorageKey, updateItems, reason, ServerHelper.CurrentUserName, EditType.WebEdit);
                if (entries!=null)
			        ctx.Commit();
			}
        }
Example #29
0
        public IList<ArchiveStudyStorage> GetArchiveStudyStorage(Study study)
        {
        	Platform.CheckForNullReference(study, "Study");

        	ArchiveStudyStorageAdaptor adaptor = new ArchiveStudyStorageAdaptor();
        	ArchiveStudyStorageSelectCriteria archiveStudyStorageCriteria = new ArchiveStudyStorageSelectCriteria();
        	archiveStudyStorageCriteria.StudyStorageKey.EqualTo(study.StudyStorageKey);
        	archiveStudyStorageCriteria.ArchiveTime.SortDesc(0);

        	return adaptor.Get(archiveStudyStorageCriteria);
        }
Example #30
0
		public bool UpdateStudy(Study study, StudyUpdateColumns columns)
		{
			return _adaptor.Update(study.Key, columns);
		}
Example #31
0
		public StudyStorage GetStudyStorage(Study study)
		{
			Platform.CheckForNullReference(study, "Study");

			return StudyStorage.Load(study.StudyStorageKey);
		}
Example #32
0
 public bool IsScheduledForEdit(Study study)
 {
     return IsStudyInWorkQueue(study, WorkQueueTypeEnum.WebEditStudy);
 }
Example #33
0
        public bool MoveStudy(Study study, Device device, IList<Series> seriesList)
        {            
			if (seriesList != null)
			{
                using (
					IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
				{
                    ServerPartition partition = ServerPartition.Load(study.ServerPartitionKey);

				    List<string> seriesUids = new List<string>();
                    foreach (Series series in seriesList)
					{
					    seriesUids.Add(series.SeriesInstanceUid);    
					}

                    IList<WorkQueue> entries = StudyEditorHelper.MoveSeries(context, partition, study.StudyInstanceUid, device.Key, seriesUids);
                        if(entries != null) context.Commit();

				    return true;
				}
			}
        	WorkQueueAdaptor workqueueAdaptor = new WorkQueueAdaptor();
			DateTime time = Platform.Time;
			WorkQueueUpdateColumns columns = new WorkQueueUpdateColumns
			                                 	{
			                                 		WorkQueueTypeEnum = WorkQueueTypeEnum.WebMoveStudy,
			                                 		WorkQueueStatusEnum = WorkQueueStatusEnum.Pending,
			                                 		ServerPartitionKey = study.ServerPartitionKey,
			                                 		StudyStorageKey = study.StudyStorageKey,
			                                 		FailureCount = 0,
			                                 		DeviceKey = device.Key,
			                                 		ScheduledTime = time,
			                                 		ExpirationTime = time.AddMinutes(4)
			                                 	};

        	workqueueAdaptor.Add(columns);

        	return true;
	    }
Example #34
0
 public bool IsScheduledForDelete(Study study)
 {
     return IsStudyInWorkQueue(study, WorkQueueTypeEnum.WebDeleteStudy);
 }