Beispiel #1
0
        public IEnumerable <StudySummary> Select(int startRowIndex, int maximumRows)
        {
            if (maximumRows == 0 || Partition == null)
            {
                return(new List <StudySummary>());
            }

            StudySelectCriteria criteria = GetSelectCriteria();

            IList <Study> studyList = _searchController.GetRangeStudies(criteria, startRowIndex, maximumRows);

            _list = new List <StudySummary>();

            foreach (Study study in studyList)
            {
                _list.Add(StudySummaryAssembler.CreateStudySummary(HttpContext.Current.GetSharedPersistentContext(), study));
            }

            if (StudyFoundSet != null)
            {
                StudyFoundSet(_list);
            }

            return(_list);
        }
        /// <summary>
        /// Constructs an instance of <see cref="WorkQueue"/> based on a <see cref="WorkQueueSummary"/> object.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        /// <remark>
        ///
        /// </remark>
        private StudyIntegrityQueueSummary CreateStudyIntegrityQueueSummary(StudyIntegrityQueue item)
        {
            var summary = new StudyIntegrityQueueSummary();

            var ssAdaptor = new StudyStorageAdaptor();
            var storages  = ssAdaptor.Get(HttpContext.Current.GetSharedPersistentContext(), item.StudyStorageKey);

            try
            {
                summary.Reason = item.StudyIntegrityReasonEnum;
                summary.TheStudyIntegrityQueueItem = item;
                summary.ThePartition = Partition;

                var queueDescription = new ReconcileStudyQueueDescription();
                queueDescription.Parse(item.Description);

                summary.QueueData = item.StudyIntegrityReasonEnum.Equals(StudyIntegrityReasonEnum.InconsistentData) ? XmlUtils.Deserialize <ReconcileStudyWorkQueueData>(item.Details) : XmlUtils.Deserialize <DuplicateSIQQueueData>(item.Details);

                ImageSetDescriptor studyData = ImageSetDescriptor.Parse(item.StudyData.DocumentElement);


                // These fields only exists in Enterprise version
                if (summary.QueueData.Details != null && summary.QueueData.Details.StudyInfo != null)
                {
                    summary.ReceivedTime                = item.InsertTime;
                    summary.ConflictingPatientId        = summary.QueueData.Details.StudyInfo.PatientInfo.PatientId;
                    summary.ConflictingPatientName      = summary.QueueData.Details.StudyInfo.PatientInfo.Name;
                    summary.ConflictingAccessionNumber  = summary.QueueData.Details.StudyInfo.AccessionNumber;
                    summary.ConflictingStudyDate        = summary.QueueData.Details.StudyInfo.StudyDate;
                    summary.ConflictingStudyDescription = summary.QueueData.Details.StudyInfo.StudyDescription;

                    var modalities = new List <string>();
                    List <SeriesInformation> seriesList = summary.QueueData.Details.StudyInfo.Series;
                    foreach (SeriesInformation series in seriesList)
                    {
                        if (!modalities.Contains(series.Modality))
                        {
                            modalities.Add(series.Modality);
                        }
                    }
                    summary.ConflictingModalities = modalities.ToArray();
                }
                else
                {
                    string value;
                    if (studyData.TryGetValue(DicomTags.PatientId, out value))
                    {
                        summary.ConflictingPatientId = value;
                    }

                    if (studyData.TryGetValue(DicomTags.PatientsName, out value))
                    {
                        summary.ConflictingPatientName = value;
                    }

                    if (studyData.TryGetValue(DicomTags.AccessionNumber, out value))
                    {
                        summary.ConflictingAccessionNumber = value;
                    }

                    if (studyData.TryGetValue(DicomTags.StudyDate, out value))
                    {
                        summary.ConflictingStudyDate = value;
                    }

                    if (studyData.TryGetValue(DicomTags.StudyDescription, out value))
                    {
                        summary.ConflictingStudyDescription = value;
                    }

                    // no modality info
                }


                // Fetch existing study info. Note: this is done last because the study may not exist.
                Study study = storages.LoadStudy(HttpContext.Current.GetSharedPersistentContext());
                summary.StudySummary = StudySummaryAssembler.CreateStudySummary(HttpContext.Current.GetSharedPersistentContext(), study);
                if (summary.StudySummary != null)
                {
                    summary.StudyInstanceUid        = summary.StudySummary.StudyInstanceUid;
                    summary.ExistingPatientName     = summary.StudySummary.PatientsName;
                    summary.ExistingPatientId       = summary.StudySummary.PatientId;
                    summary.ExistingAccessionNumber = summary.StudySummary.AccessionNumber;
                }
            }
            catch (StudyNotFoundException)
            {
                // Study record may not exist. For eg, duplicate arrives but the existing study hasn't been processed.
            }


            return(summary);
        }