private static IList<StudyIntegrityQueueUid> LoadDuplicateSopUid(DuplicateSopReceivedQueue entry)
        {
            IStudyIntegrityQueueUidEntityBroker broker =
                HttpContextData.Current.ReadContext.GetBroker<IStudyIntegrityQueueUidEntityBroker>();

            StudyIntegrityQueueUidSelectCriteria criteria = new StudyIntegrityQueueUidSelectCriteria();
            criteria.StudyIntegrityQueueKey.EqualTo(entry.GetKey());
            return broker.Find(criteria);
        }
 public StudyIntegrityQueueUidSelectCriteria(StudyIntegrityQueueUidSelectCriteria other)
 : base(other)
 {}
예제 #3
0
        public static ReconcileDetails CreateReconcileDetails(StudyIntegrityQueueSummary item)
        {
            ReconcileDetails details = item.TheStudyIntegrityQueueItem.StudyIntegrityReasonEnum.Equals(
                                           StudyIntegrityReasonEnum.InconsistentData)
                                           ? new ReconcileDetails(item.TheStudyIntegrityQueueItem)
                                           : new DuplicateEntryDetails(item.TheStudyIntegrityQueueItem);

            Study study = item.StudySummary.TheStudy;
            details.StudyInstanceUid = study.StudyInstanceUid;

            //Set the demographic details of the Existing Patient
            details.ExistingStudy = new ReconcileDetails.StudyInfo();
            details.ExistingStudy.StudyInstanceUid = item.StudySummary.StudyInstanceUid;
            details.ExistingStudy.AccessionNumber = item.StudySummary.AccessionNumber;
            details.ExistingStudy.StudyDate = item.StudySummary.StudyDate;
            details.ExistingStudy.Patient.PatientID = item.StudySummary.PatientId;
            details.ExistingStudy.Patient.Name = item.StudySummary.PatientsName;
            details.ExistingStudy.Patient.Sex = study.PatientsSex;
            details.ExistingStudy.Patient.IssuerOfPatientID = study.IssuerOfPatientId;
            details.ExistingStudy.Patient.BirthDate = study.PatientsBirthDate;
            details.ExistingStudy.Series = CollectionUtils.Map(
                study.Series.Values,
                delegate(Series theSeries)
                    {
                        var seriesDetails = new ReconcileDetails.SeriesDetails
                                                {
                                                    Description = theSeries.SeriesDescription,
                                                    SeriesInstanceUid = theSeries.SeriesInstanceUid,
                                                    Modality = theSeries.Modality,
                                                    NumberOfInstances = theSeries.NumberOfSeriesRelatedInstances,
                                                    SeriesNumber = theSeries.SeriesNumber
                                                };
                        return seriesDetails;
                    });


            details.ConflictingImageSet = item.QueueData.Details;


            details.ConflictingStudyInfo = new ReconcileDetails.StudyInfo();

            if (item.QueueData.Details != null)
            {
                // extract the conflicting study info from Details
                details.ConflictingStudyInfo.AccessionNumber = item.QueueData.Details.StudyInfo.AccessionNumber;
                details.ConflictingStudyInfo.StudyDate = item.QueueData.Details.StudyInfo.StudyDate;
                details.ConflictingStudyInfo.StudyInstanceUid = item.QueueData.Details.StudyInfo.StudyInstanceUid;
                details.ConflictingStudyInfo.StudyDate = item.QueueData.Details.StudyInfo.StudyDate;

                details.ConflictingStudyInfo.Patient = new ReconcileDetails.PatientInfo
                                                           {
                                                               BirthDate =
                                                                   item.QueueData.Details.StudyInfo.PatientInfo.
                                                                   PatientsBirthdate,
                                                               IssuerOfPatientID =
                                                                   item.QueueData.Details.StudyInfo.PatientInfo.
                                                                   IssuerOfPatientId,
                                                               Name = item.QueueData.Details.StudyInfo.PatientInfo.Name,
                                                               PatientID =
                                                                   item.QueueData.Details.StudyInfo.PatientInfo.
                                                                   PatientId,
                                                               Sex = item.QueueData.Details.StudyInfo.PatientInfo.Sex
                                                           };

                details.ConflictingStudyInfo.Series =
                    CollectionUtils.Map(
                        item.QueueData.Details.StudyInfo.Series,
                        delegate(SeriesInformation input)
                            {
                                var seriesDetails = new ReconcileDetails.SeriesDetails
                                                        {
                                                            Description = input.SeriesDescription,
                                                            Modality = input.Modality,
                                                            SeriesInstanceUid = input.SeriesInstanceUid,
                                                            NumberOfInstances = input.NumberOfInstances
                                                        };
                                return seriesDetails;
                            });
            }
            else
            {
                // Extract the conflicting study info from StudyData
                // Note: Not all fields are available.
                ImageSetDescriptor desc =
                    ImageSetDescriptor.Parse(item.TheStudyIntegrityQueueItem.StudyData.DocumentElement);
                string value;

                if (desc.TryGetValue(DicomTags.AccessionNumber, out value))
                    details.ConflictingStudyInfo.AccessionNumber = value;

                if (desc.TryGetValue(DicomTags.StudyDate, out value))
                    details.ConflictingStudyInfo.StudyDate = value;

                if (desc.TryGetValue(DicomTags.StudyInstanceUid, out value))
                    details.ConflictingStudyInfo.StudyInstanceUid = value;

                details.ConflictingStudyInfo.Patient = new ReconcileDetails.PatientInfo();

                if (desc.TryGetValue(DicomTags.PatientsBirthDate, out value))
                    details.ConflictingStudyInfo.Patient.BirthDate = value;

                if (desc.TryGetValue(DicomTags.IssuerOfPatientId, out value))
                    details.ConflictingStudyInfo.Patient.IssuerOfPatientID = value;

                if (desc.TryGetValue(DicomTags.PatientsName, out value))
                    details.ConflictingStudyInfo.Patient.Name = value;

                if (desc.TryGetValue(DicomTags.PatientId, out value))
                    details.ConflictingStudyInfo.Patient.PatientID = value;

                if (desc.TryGetValue(DicomTags.PatientsSex, out value))
                    details.ConflictingStudyInfo.Patient.Sex = value;


                var series = new List<ReconcileDetails.SeriesDetails>();
                details.ConflictingStudyInfo.Series = series;

                var uidBroker =
                    HttpContextData.Current.ReadContext.GetBroker<IStudyIntegrityQueueUidEntityBroker>();
                var criteria = new StudyIntegrityQueueUidSelectCriteria();
                criteria.StudyIntegrityQueueKey.EqualTo(item.TheStudyIntegrityQueueItem.GetKey());

                IList<StudyIntegrityQueueUid> uids = uidBroker.Find(criteria);

                Dictionary<string, List<StudyIntegrityQueueUid>> seriesGroups = CollectionUtils.GroupBy(uids,
                                                                                                        uid =>
                                                                                                        uid.
                                                                                                            SeriesInstanceUid);

                foreach (string seriesUid in seriesGroups.Keys)
                {
                    var seriesDetails = new ReconcileDetails.SeriesDetails
                                            {
                                                SeriesInstanceUid = seriesUid,
                                                Description = seriesGroups[seriesUid][0].SeriesDescription,
                                                NumberOfInstances = seriesGroups[seriesUid].Count
                                            };
                    //seriesDetails.Modality = "N/A";
                    series.Add(seriesDetails);
                }
            }


            return details;
        }
예제 #4
0
		/// <summary>
		/// Checks for the existinance of a SOP for a given Study in the <see cref="StudyIntegrityQueue"/>.
		/// </summary>
		/// <param name="studyStorageKey">The StudyStorage primary key</param>
		/// <param name="sopInstanceUid">The Sop Instance ot look for</param>
		/// <param name="seriesInstanceUid">The Series Instance Uid of the Sop</param>
		/// <returns>true if an entry exists, false if it doesn't</returns>
		static public bool StudyIntegrityUidExists(ServerEntityKey studyStorageKey, string seriesInstanceUid, string sopInstanceUid)
		{
			Platform.CheckForNullReference(studyStorageKey, "studyStorageKey");

			using (ServerExecutionContext scope = new ServerExecutionContext())
			{
				IStudyIntegrityQueueEntityBroker broker = scope.PersistenceContext.GetBroker<IStudyIntegrityQueueEntityBroker>();
				StudyIntegrityQueueUidSelectCriteria uidSelectCriteria = new StudyIntegrityQueueUidSelectCriteria();
				uidSelectCriteria.SeriesInstanceUid.EqualTo(seriesInstanceUid);
				uidSelectCriteria.SopInstanceUid.EqualTo(sopInstanceUid);
				StudyIntegrityQueueSelectCriteria selectCriteria = new StudyIntegrityQueueSelectCriteria();
				selectCriteria.StudyStorageKey.EqualTo(studyStorageKey);
				selectCriteria.StudyIntegrityQueueUidRelatedEntityCondition.Exists(uidSelectCriteria);

				return broker.Count(selectCriteria) > 0;
			}
		}
예제 #5
0
        private static void ReconcileStudy(string command,StudyIntegrityQueue item )
        {
            //Ignore the reconcile command if the item is null.
            if (item == null) return;

			// Preload the change description so its not done during the DB transaction
			XmlDocument changeDescription = new XmlDocument();
			changeDescription.LoadXml(command);

			// The Xml in the SIQ item was generated when the images were received and put into the SIQ.
			// We now add the user info to it so that it will be logged in the history
            ReconcileStudyWorkQueueData queueData = XmlUtils.Deserialize<ReconcileStudyWorkQueueData>(item.Details);
            queueData.TimeStamp = Platform.Time;
            queueData.UserId = ServerHelper.CurrentUserName;

			using (IUpdateContext context = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
			{
                
                LockStudyParameters lockParms = new LockStudyParameters
                                                	{
                                                		QueueStudyStateEnum = QueueStudyStateEnum.ReconcileScheduled,
                                                		StudyStorageKey = item.StudyStorageKey
                                                	};
				ILockStudy broker = context.GetBroker<ILockStudy>();
                broker.Execute(lockParms);
                if (!lockParms.Successful)
                {
                    throw new ApplicationException(lockParms.FailureReason);
                }

                
				//Add to Study History
				StudyHistoryeAdaptor historyAdaptor = new StudyHistoryeAdaptor();
				StudyHistoryUpdateColumns parameters = new StudyHistoryUpdateColumns
				                                       	{
				                                       		StudyData = item.StudyData,
				                                       		ChangeDescription = changeDescription,
				                                       		StudyStorageKey = item.StudyStorageKey,
				                                       		StudyHistoryTypeEnum = StudyHistoryTypeEnum.StudyReconciled
				                                       	};

				StudyHistory history = historyAdaptor.Add(context, parameters);

				//Create WorkQueue Entry
				WorkQueueAdaptor workQueueAdaptor = new WorkQueueAdaptor();
				WorkQueueUpdateColumns row = new WorkQueueUpdateColumns
				                             	{
				                             		Data = XmlUtils.SerializeAsXmlDoc(queueData),
				                             		ServerPartitionKey = item.ServerPartitionKey,
				                             		StudyStorageKey = item.StudyStorageKey,
				                             		StudyHistoryKey = history.GetKey(),
				                             		WorkQueueTypeEnum = WorkQueueTypeEnum.ReconcileStudy,
				                             		WorkQueueStatusEnum = WorkQueueStatusEnum.Pending,
				                             		ScheduledTime = Platform.Time,
				                             		ExpirationTime = Platform.Time.AddHours(1),
                                                    GroupID = item.GroupID
				                             	};
				WorkQueue newWorkQueueItem = workQueueAdaptor.Add(context, row);

				StudyIntegrityQueueUidAdaptor studyIntegrityQueueUidAdaptor = new StudyIntegrityQueueUidAdaptor();
				StudyIntegrityQueueUidSelectCriteria crit = new StudyIntegrityQueueUidSelectCriteria();
				crit.StudyIntegrityQueueKey.EqualTo(item.GetKey());
				IList<StudyIntegrityQueueUid> uidList = studyIntegrityQueueUidAdaptor.Get(context, crit);

				WorkQueueUidAdaptor workQueueUidAdaptor = new WorkQueueUidAdaptor();
				WorkQueueUidUpdateColumns update = new WorkQueueUidUpdateColumns();
				foreach (StudyIntegrityQueueUid uid in uidList)
				{
					update.WorkQueueKey = newWorkQueueItem.GetKey();
					update.SeriesInstanceUid = uid.SeriesInstanceUid;
					update.SopInstanceUid = uid.SopInstanceUid;
				    update.RelativePath = uid.RelativePath;
					workQueueUidAdaptor.Add(context, update);
				}

				//DeleteStudyIntegrityQueue Item
				StudyIntegrityQueueUidSelectCriteria criteria = new StudyIntegrityQueueUidSelectCriteria();
				criteria.StudyIntegrityQueueKey.EqualTo(item.GetKey());
				studyIntegrityQueueUidAdaptor.Delete(context, criteria);

				StudyIntegrityQueueAdaptor studyIntegrityQueueAdaptor = new StudyIntegrityQueueAdaptor();
				studyIntegrityQueueAdaptor.Delete(context, item.GetKey());

				context.Commit();
			}

		}
예제 #6
0
 public StudyIntegrityQueueUidSelectCriteria(StudyIntegrityQueueUidSelectCriteria other)
     : base(other)
 {
 }