Example #1
0
        /// <summary>
        /// Returns an instance of <see cref="StudySummary"/> based on a <see cref="Study"/> object.
        /// </summary>
        /// <param name="study"></param>
        /// <param name="read"></param>
        /// <returns></returns>
        /// <remark>
        ///
        /// </remark>
        static public StudySummary CreateStudySummary(IPersistenceContext read, Study study)
        {
            if (study == null)
            {
                return(null);
            }

            var studySummary = new StudySummary();
            var controller   = new StudyController();

            studySummary.TheStudy = study;

            studySummary.Key             = study.GetKey();
            studySummary.AccessionNumber = study.AccessionNumber;
            studySummary.NumberOfStudyRelatedInstances = study.NumberOfStudyRelatedInstances;
            studySummary.NumberOfStudyRelatedSeries    = study.NumberOfStudyRelatedSeries;
            studySummary.PatientId               = study.PatientId;
            studySummary.PatientsName            = study.PatientsName;
            studySummary.StudyDate               = study.StudyDate;
            studySummary.StudyInstanceUid        = study.StudyInstanceUid;
            studySummary.StudyDescription        = study.StudyDescription;
            studySummary.ModalitiesInStudy       = controller.GetModalitiesInStudy(read, study);
            studySummary.ReferringPhysiciansName = study.ReferringPhysiciansName;
            studySummary.ResponsibleOrganization = study.ResponsibleOrganization;
            studySummary.ResponsiblePerson       = study.ResponsiblePerson;
            studySummary.StudyTime               = study.StudyTime;
            studySummary.StudyId  = study.StudyId;
            studySummary.HasOrder = study.OrderKey != null;

            if (study.OrderKey != null)
            {
                var order = Order.Load(study.OrderKey);
                studySummary.OrderRequiresQC = order.QCExpected;
                studySummary.StudyIsQCed     = (study.QCStatusEnum != null && study.QCStatusEnum != QCStatusEnum.NA);
            }



            studySummary.ThePartition = ServerPartitionMonitor.Instance.FindPartition(study.ServerPartitionKey) ??
                                        ServerPartition.Load(read, study.ServerPartitionKey);

            studySummary.ReferringPhysiciansName = study.ReferringPhysiciansName;
            studySummary.TheStudyStorage         = StudyStorage.Load(read, study.StudyStorageKey);
            studySummary.StudyStatusEnum         = studySummary.TheStudyStorage.StudyStatusEnum;
            studySummary.QueueStudyStateEnum     = studySummary.TheStudyStorage.QueueStudyStateEnum;

            studySummary.TheArchiveLocation = controller.GetFirstArchiveStudyStorage(read, studySummary.TheStudyStorage.Key);

            studySummary.IsArchiving = controller.GetArchiveQueueCount(study) > 0;

            studySummary.IsProcessing = studySummary.TheStudyStorage.WriteLock;

            // the study is considered "locked" if it's being processed or some action which requires the lock has been scheduled
            // No additional action should be allowed on the study until everything is completed.
            studySummary.IsLocked = studySummary.IsProcessing ||
                                    (studySummary.TheStudyStorage.QueueStudyStateEnum != QueueStudyStateEnum.Idle);

            if (controller.GetStudyIntegrityQueueCount(studySummary.TheStudyStorage.Key) > 0)
            {
                studySummary.IsReconcileRequired = true;
            }

            studySummary.HasPendingExternalEdit = controller.GetCountPendingExternalEditWorkQueueItems(study) > 0;
            if (studySummary.HasPendingExternalEdit)
            {
                studySummary.HasPendingWorkQueueItems = true;
            }
            else
            {
                studySummary.HasPendingWorkQueueItems = controller.GetCountPendingWorkQueueItems(study) > 0;
            }

            var ep = new StudySummaryAssemblerExtensionPoint();

            foreach (IStudySummaryAssembler assemblerPlugin in ep.CreateExtensions())
            {
                assemblerPlugin.PopulateStudy(studySummary, study);
            }

            return(studySummary);
        }
Example #2
0
		/// <summary>
		/// Returns an instance of <see cref="StudySummary"/> based on a <see cref="Study"/> object.
		/// </summary>
		/// <param name="study"></param>
		/// <param name="read"></param>
		/// <returns></returns>
		/// <remark>
		/// 
		/// </remark>
		static public StudySummary CreateStudySummary(IPersistenceContext read, Study study)
		{
            if (study==null)
			{
			    return null;
			}

			var studySummary = new StudySummary();
			var controller = new StudyController();

			studySummary.Key = study.GetKey();
			studySummary.AccessionNumber = study.AccessionNumber;
			studySummary.NumberOfStudyRelatedInstances = study.NumberOfStudyRelatedInstances;
			studySummary.NumberOfStudyRelatedSeries = study.NumberOfStudyRelatedSeries;
			studySummary.PatientId = study.PatientId;
			studySummary.PatientsName = study.PatientsName;
			studySummary.StudyDate = study.StudyDate;
			studySummary.StudyInstanceUid = study.StudyInstanceUid;
			studySummary.StudyDescription = study.StudyDescription;
			studySummary.ModalitiesInStudy = controller.GetModalitiesInStudy(read, study);
		    studySummary.ReferringPhysiciansName = study.ReferringPhysiciansName;
		    studySummary.ResponsibleOrganization = study.ResponsibleOrganization;
		    studySummary.ResponsiblePerson = study.ResponsiblePerson;
			studySummary.StudyTime = study.StudyTime;
			studySummary.StudyId = study.StudyId;
			studySummary.TheStudy = study;

			studySummary.ThePartition = ServerPartitionMonitor.Instance.FindPartition(study.ServerPartitionKey) ??
			                            ServerPartition.Load(read, study.ServerPartitionKey);

		    studySummary.ReferringPhysiciansName = study.ReferringPhysiciansName;
			studySummary.TheStudyStorage = StudyStorage.Load(read, study.StudyStorageKey);
			studySummary.StudyStatusEnum = studySummary.TheStudyStorage.StudyStatusEnum;
			studySummary.QueueStudyStateEnum = studySummary.TheStudyStorage.QueueStudyStateEnum;

			studySummary.TheArchiveLocation = controller.GetFirstArchiveStudyStorage(read, studySummary.TheStudyStorage.Key);

			studySummary.IsArchiving = controller.GetArchiveQueueCount(study) > 0;

			studySummary.IsProcessing = studySummary.TheStudyStorage.WriteLock;

			// the study is considered "locked" if it's being processed or some action which requires the lock has been scheduled
			// No additional action should be allowed on the study until everything is completed.
			studySummary.IsLocked = studySummary.IsProcessing ||
			                        (studySummary.TheStudyStorage.QueueStudyStateEnum != QueueStudyStateEnum.Idle);
           
    		if (controller.GetStudyIntegrityQueueCount(studySummary.TheStudyStorage.Key) > 0)
			{
				studySummary.IsReconcileRequired = true;
			}

		    studySummary.HasPendingExternalEdit = controller.GetCountPendingExternalEditWorkQueueItems(study) > 0;
            if (studySummary.HasPendingExternalEdit)            
                studySummary.HasPendingWorkQueueItems = true;            
            else
		        studySummary.HasPendingWorkQueueItems = controller.GetCountPendingWorkQueueItems(study) > 0;
            
            var ep = new StudySummaryAssemblerExtensionPoint();
            foreach (IStudySummaryAssembler assemblerPlugin in ep.CreateExtensions())
            {
                assemblerPlugin.PopulateStudy(studySummary, study);
            }

			return studySummary;
		}