public IList<Series> GetSeries(Study study)
        {
            SeriesSelectCriteria criteria = new SeriesSelectCriteria();

            criteria.StudyKey.EqualTo(study.Key);

            return _seriesAdaptor.Get(criteria);
        }
		protected override void OnExecute(CommandProcessor theProcessor, IUpdateContext updateContext)
		{
			var seriesUid = _data[DicomTags.SeriesInstanceUid].ToString();

			var broker= updateContext.GetBroker<ISeriesEntityBroker>();
			
			var criteria = new SeriesSelectCriteria();
			criteria.ServerPartitionKey.EqualTo(_context.ServerPartition.Key);
			criteria.StudyKey.EqualTo(_storageLocation.Study.Key);
			criteria.SeriesInstanceUid.EqualTo(seriesUid);
			var series=broker.FindOne(criteria);

			if (series!=null)
			{
				var updates = new SeriesUpdateColumns();
				if (_data.LoadDicomFields(updates))
					broker.Update(series.Key, updates);
			}

			
		}
        protected void LoadSeries()
        {
           for (int i = 1; ; i++)
           {
                string seriesuid = Request.QueryString[string.Format(ImageServerConstants.QueryStrings.SeriesUID + "{0}", i)];

                if (!String.IsNullOrEmpty(seriesuid))
                {

                    SeriesSearchAdaptor seriesAdaptor = new SeriesSearchAdaptor();
                    SeriesSelectCriteria criteria = new SeriesSelectCriteria();
                    criteria.StudyKey.EqualTo(SelectedStudy.Key);
                    criteria.ServerPartitionKey.EqualTo(Partition.GetKey());
                    criteria.SeriesInstanceUid.EqualTo(seriesuid);

                    IList<Series> seriesList = seriesAdaptor.Get(criteria);

                    SeriesGridView.SeriesList.Add(seriesList[0]);
                }
                else
                    break;
            }
        }
        /// <summary>
        /// Method for processing Series level queries.
        /// </summary>
        /// <param name="server"></param>
        /// <param name="presentationId"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        private void OnReceiveSeriesLevelQuery(DicomServer server, byte presentationId, DicomMessage message)
        {
            //Read context for the query.
            using (IReadContext read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                var tagList = new List<DicomTag>();

                var selectSeries = read.GetBroker<ISeriesEntityBroker>();

                var criteria = new SeriesSelectCriteria();
                criteria.ServerPartitionKey.EqualTo(Partition.GetKey());

                DicomAttributeCollection data = message.DataSet;
                foreach (DicomAttribute attrib in message.DataSet)
                {
                    tagList.Add(attrib.Tag);
                    if (!attrib.IsNull)
                        switch (attrib.Tag.TagValue)
                        {
                            case DicomTags.StudyInstanceUid:
                                List<ServerEntityKey> list =
                                    LoadStudyKey(read, (string[]) data[DicomTags.StudyInstanceUid].Values);
                                if (list.Count == 0)
                                {
                                    server.SendCFindResponse(presentationId, message.MessageId, new DicomMessage(), 
                                                             DicomStatuses.Success);
                                    AuditLog(server.AssociationParams, EventIdentificationContentsEventOutcomeIndicator.Success, message);
                                    return;
                                }
                                QueryHelper.SetKeyCondition(criteria.StudyKey, list.ToArray());
                                break;
                            case DicomTags.SeriesInstanceUid:
                                QueryHelper.SetStringArrayCondition(criteria.SeriesInstanceUid,
                                                        (string[]) data[DicomTags.SeriesInstanceUid].Values);
                                break;
                            case DicomTags.Modality:
                                QueryHelper.SetStringCondition(criteria.Modality, data[DicomTags.Modality].GetString(0, string.Empty));
                                break;
                            case DicomTags.SeriesNumber:
								QueryHelper.SetStringCondition(criteria.SeriesNumber, data[DicomTags.SeriesNumber].GetString(0, string.Empty));
                                break;
                            case DicomTags.SeriesDescription:
                                QueryHelper.SetStringCondition(criteria.SeriesDescription,
												   data[DicomTags.SeriesDescription].GetString(0, string.Empty));
                                break;
                            case DicomTags.PerformedProcedureStepStartDate:
                                QueryHelper.SetRangeCondition(criteria.PerformedProcedureStepStartDate,
												  data[DicomTags.PerformedProcedureStepStartDate].GetString(0, string.Empty));
                                break;
                            case DicomTags.PerformedProcedureStepStartTime:
                                QueryHelper.SetRangeCondition(criteria.PerformedProcedureStepStartTime,
												  data[DicomTags.PerformedProcedureStepStartTime].GetString(0, string.Empty));
                                break;
                            case DicomTags.RequestAttributesSequence: // todo
                                break;
                            default:
                                foreach (var q in _queryExtensions)
                                    q.OnReceiveSeriesLevelQuery(message, attrib.Tag, criteria);
                                break;
                        }
                }

				int resultCount = 0;
				try
                {
                    // Open a second read context, in case other queries are required.
					using (IReadContext subRead = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                    {
                        selectSeries.Find(criteria, delegate(Series row)
                                                        {
															if (CancelReceived)
																throw new DicomException("DICOM C-Cancel Received");

															resultCount++;
															if (DicomSettings.Default.MaxQueryResponses != -1
																&& DicomSettings.Default.MaxQueryResponses < resultCount)
															{
																SendBufferedResponses(server, presentationId, message);
																throw new DicomException("Maximum Configured Query Responses Exceeded: " + resultCount);
															}

                                                        	var response = new DicomMessage();
                                                            PopulateSeries(subRead, message, response, tagList, row);
															_responseQueue.Enqueue(response);

															if (_responseQueue.Count >= DicomSettings.Default.BufferedQueryResponses)
																SendBufferedResponses(server, presentationId, message);
														});
						SendBufferedResponses(server, presentationId, message);
					}
                }
                catch (Exception e)
                {
					if (CancelReceived)
					{
						var errorResponse = new DicomMessage();
						server.SendCFindResponse(presentationId, message.MessageId, errorResponse,
												 DicomStatuses.Cancel);
						AuditLog(server.AssociationParams, EventIdentificationContentsEventOutcomeIndicator.Success, message);
        
					}
					else if (DicomSettings.Default.MaxQueryResponses != -1
						  && DicomSettings.Default.MaxQueryResponses < resultCount)
					{
						Platform.Log(LogLevel.Warn, "Maximum Configured Query Responses Exceeded: {0} on query from {1}",resultCount,server.AssociationParams.CallingAE);

						var errorResponse = new DicomMessage();
						server.SendCFindResponse(presentationId, message.MessageId, errorResponse,
												 DicomStatuses.Success);
						AuditLog(server.AssociationParams, EventIdentificationContentsEventOutcomeIndicator.Success, message);
        
					}
					else
					{
						Platform.Log(LogLevel.Error, e, "Unexpected exception when processing FIND request.");
						var errorResponse = new DicomMessage();
						server.SendCFindResponse(presentationId, message.MessageId, errorResponse,
						                         DicomStatuses.ProcessingFailure);
						AuditLog(server.AssociationParams, EventIdentificationContentsEventOutcomeIndicator.SeriousFailureActionTerminated, message);
        
					}
                	return;
                }

                var finalResponse = new DicomMessage();
                server.SendCFindResponse(presentationId, message.MessageId, finalResponse, DicomStatuses.Success);

				AuditLog(server.AssociationParams, EventIdentificationContentsEventOutcomeIndicator.Success, message);
        
            	return;
            }
        }
        /// <summary>
        /// Method for processing Study level queries.
        /// </summary>
        /// <param name="server"></param>
        /// <param name="presentationId"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        private void OnReceiveStudyLevelQuery(DicomServer server, byte presentationId, DicomMessage message)
        {
            var tagList = new List<DicomTag>();

            using (IReadContext read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                var find = read.GetBroker<IStudyEntityBroker>();

                var criteria = new StudySelectCriteria();
                criteria.ServerPartitionKey.EqualTo(Partition.GetKey());

                DicomAttributeCollection data = message.DataSet;
                foreach (DicomAttribute attrib in message.DataSet)
                {
                    tagList.Add(attrib.Tag);
                    if (!attrib.IsNull)
                        switch (attrib.Tag.TagValue)
                        {
                            case DicomTags.StudyInstanceUid:
                                QueryHelper.SetStringArrayCondition(criteria.StudyInstanceUid,
                                                        (string[]) data[DicomTags.StudyInstanceUid].Values);
                                break;
                            case DicomTags.PatientsName:
								QueryHelper.SetStringCondition(criteria.PatientsName, data[DicomTags.PatientsName].GetString(0, string.Empty));
                                break;
                            case DicomTags.PatientId:
								QueryHelper.SetStringCondition(criteria.PatientId, data[DicomTags.PatientId].GetString(0, string.Empty));
                                break;
                            case DicomTags.PatientsBirthDate:
                                QueryHelper.SetRangeCondition(criteria.PatientsBirthDate,
												  data[DicomTags.PatientsBirthDate].GetString(0, string.Empty));
                                break;
                            case DicomTags.PatientsSex:
								QueryHelper.SetStringCondition(criteria.PatientsSex, data[DicomTags.PatientsSex].GetString(0, string.Empty));
                                break;
                            case DicomTags.StudyDate:
								QueryHelper.SetRangeCondition(criteria.StudyDate, data[DicomTags.StudyDate].GetString(0, string.Empty));
                                break;
                            case DicomTags.StudyTime:
								QueryHelper.SetRangeCondition(criteria.StudyTime, data[DicomTags.StudyTime].GetString(0, string.Empty));
                                break;
                            case DicomTags.AccessionNumber:
                                QueryHelper.SetStringCondition(criteria.AccessionNumber,
												   data[DicomTags.AccessionNumber].GetString(0, string.Empty));
                                break;
                            case DicomTags.StudyId:
								QueryHelper.SetStringCondition(criteria.StudyId, data[DicomTags.StudyId].GetString(0, string.Empty));
                                break;
                            case DicomTags.StudyDescription:
                                QueryHelper.SetStringCondition(criteria.StudyDescription,
												   data[DicomTags.StudyDescription].GetString(0, string.Empty));
                                break;
                            case DicomTags.ReferringPhysiciansName:
                                QueryHelper.SetStringCondition(criteria.ReferringPhysiciansName,
												   data[DicomTags.ReferringPhysiciansName].GetString(0, string.Empty));
                                break;
                            case DicomTags.ModalitiesInStudy:
                                // Specify a subselect on Modality in series
                                var seriesSelect = new SeriesSelectCriteria();
                                QueryHelper.SetStringArrayCondition(seriesSelect.Modality,
                                                        (string[]) data[DicomTags.ModalitiesInStudy].Values);
                                criteria.SeriesRelatedEntityCondition.Exists(seriesSelect);
                                break;
                            default:
                                foreach (var q in _queryExtensions)
                                    q.OnReceiveStudyLevelQuery(message, attrib.Tag, criteria);
                                break;
                        }
                }

				int resultCount = 0;
				try
                {
                    // Open another read context, in case additional queries are required.
					using (IReadContext subRead = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                    {
						// First find the Online studies
                    	var storageCriteria = new StudyStorageSelectCriteria();
                    	storageCriteria.StudyStatusEnum.NotEqualTo(StudyStatusEnum.Nearline);
						storageCriteria.QueueStudyStateEnum.NotIn(new[] {QueueStudyStateEnum.DeleteScheduled, QueueStudyStateEnum.WebDeleteScheduled, QueueStudyStateEnum.EditScheduled});
                    	criteria.StudyStorageRelatedEntityCondition.Exists(storageCriteria);

                        find.Find(criteria, delegate(Study row)
                                                {
													if (CancelReceived)
														throw new DicomException("DICOM C-Cancel Received");

													resultCount++;
													if (DicomSettings.Default.MaxQueryResponses != -1
														&& DicomSettings.Default.MaxQueryResponses < resultCount)
													{
														SendBufferedResponses(server, presentationId, message);
														throw new DicomException("Maximum Configured Query Responses Exceeded: " + resultCount);
													}

                                                    var response = new DicomMessage();
                                                    PopulateStudy(subRead, response, tagList, row, "ONLINE");
													_responseQueue.Enqueue(response);

													if (_responseQueue.Count >= DicomSettings.Default.BufferedQueryResponses)
														SendBufferedResponses(server, presentationId, message);
											
                                                });

						// Now find the Nearline studies
						storageCriteria = new StudyStorageSelectCriteria();
						storageCriteria.StudyStatusEnum.EqualTo(StudyStatusEnum.Nearline);
						storageCriteria.QueueStudyStateEnum.NotIn(new[] { QueueStudyStateEnum.DeleteScheduled, QueueStudyStateEnum.WebDeleteScheduled, QueueStudyStateEnum.EditScheduled });
						criteria.StudyStorageRelatedEntityCondition.Exists(storageCriteria);

						find.Find(criteria, delegate(Study row)
												{
													if (CancelReceived)
														throw new DicomException("DICOM C-Cancel Received");

													resultCount++;
													if (DicomSettings.Default.MaxQueryResponses != -1
														&& DicomSettings.Default.MaxQueryResponses < resultCount)
													{
														SendBufferedResponses(server, presentationId, message);
														throw new DicomException("Maximum Configured Query Responses Exceeded: " + resultCount);
													}

													var response = new DicomMessage();
													PopulateStudy(subRead, response, tagList, row, "NEARLINE");
													_responseQueue.Enqueue(response);

													if (_responseQueue.Count >= DicomSettings.Default.BufferedQueryResponses)
														SendBufferedResponses(server, presentationId, message);

												});

						SendBufferedResponses(server, presentationId, message);
					}
                }
                catch (Exception e)
                {
					if (CancelReceived)
					{
						var errorResponse = new DicomMessage();
						server.SendCFindResponse(presentationId, message.MessageId, errorResponse,
												 DicomStatuses.Cancel);
						AuditLog(server.AssociationParams, EventIdentificationContentsEventOutcomeIndicator.Success, message);
        
					}
					else if (DicomSettings.Default.MaxQueryResponses != -1
						  && DicomSettings.Default.MaxQueryResponses < resultCount)
					{
						Platform.Log(LogLevel.Warn, "Maximum Configured Query Responses Exceeded: {0} on query from {1}", resultCount, server.AssociationParams.CallingAE);
						var errorResponse = new DicomMessage();
						server.SendCFindResponse(presentationId, message.MessageId, errorResponse,
												 DicomStatuses.Success);
						AuditLog(server.AssociationParams, EventIdentificationContentsEventOutcomeIndicator.Success, message);
        
					}
					else
					{
						Platform.Log(LogLevel.Error, e, "Unexpected exception when processing FIND request.");
						var errorResponse = new DicomMessage();
						server.SendCFindResponse(presentationId, message.MessageId, errorResponse,
						                         DicomStatuses.ProcessingFailure);
						AuditLog(server.AssociationParams,
								 EventIdentificationContentsEventOutcomeIndicator.SeriousFailureActionTerminated, message);

					}
                	return;
                }
            }

            var finalResponse = new DicomMessage();
            server.SendCFindResponse(presentationId, message.MessageId, finalResponse, DicomStatuses.Success);

			AuditLog(server.AssociationParams, EventIdentificationContentsEventOutcomeIndicator.Success, message);
        
        	return;
        }
Exemple #6
0
        private void LoadSeriesDetails()
        {

            if (!String.IsNullOrEmpty(_serverae) && !String.IsNullOrEmpty(_studyInstanceUid) && !String.IsNullOrEmpty(_seriesInstanceUid))
            {
                StudyAdaptor studyAdaptor = new StudyAdaptor();
                SeriesSearchAdaptor seriesAdaptor = new SeriesSearchAdaptor();
                        
                ServerPartitionDataAdapter adaptor = new ServerPartitionDataAdapter();
                ServerPartitionSelectCriteria criteria = new ServerPartitionSelectCriteria();
                criteria.AeTitle.EqualTo(_serverae);

                Model.ServerPartition partition = adaptor.GetFirst(criteria);
                if (partition != null)
                {
                    Partition = partition;

                    StudySelectCriteria studyCriteria = new StudySelectCriteria();
                    studyCriteria.StudyInstanceUid.EqualTo(_studyInstanceUid);
                    studyCriteria.ServerPartitionKey.EqualTo(Partition.GetKey());
                    Model.Study study = studyAdaptor.GetFirst(studyCriteria);

                    if (study != null)
                    {
                        // there should be only one study
                        _study = study;

                        SeriesSelectCriteria seriesCriteria = new SeriesSelectCriteria();
                        seriesCriteria.SeriesInstanceUid.EqualTo(_seriesInstanceUid);
                        Series series = seriesAdaptor.GetFirst(seriesCriteria);

                        if (series != null)
                        {
                            _series = series;
                        }
                    }

                }
            }

            if (_study!=null && _series != null)
            {
                SeriesDetailsPanel1.Study = _study;
                SeriesDetailsPanel1.Series = _series;
            }

            DataBind();
        }
		private void Initialize()
		{
			_study = Study.Find(ServerExecutionContext.Current.ReadContext,_studyLocation.StudyInstanceUid, _partition);
			_curPatient = _study.LoadPatient(ServerExecutionContext.Current.ReadContext);
			_oldPatientInfo = new PatientInfo
				{
					PatientsName = _curPatient.PatientsName,
					PatientId = _curPatient.PatientId,
					IssuerOfPatientId = _curPatient.IssuerOfPatientId
				};

			_seriesInstanceUid = _file.DataSet[DicomTags.SeriesInstanceUid].ToString();
			var broker = ServerExecutionContext.Current.ReadContext.GetBroker<ISeriesEntityBroker>();
			var select = new SeriesSelectCriteria();
			select.SeriesInstanceUid.EqualTo(_seriesInstanceUid);
			select.ServerPartitionKey.EqualTo(_partition.Key);
			_curSeries = broker.FindOne(select);

			_newPatientInfo = new PatientInfo(_oldPatientInfo);
			_file.DataSet.LoadDicomFields(_newPatientInfo);

			_newPatient = FindPatient(_newPatientInfo, ServerExecutionContext.Current.ReadContext);
			_patientInfoIsNotChanged = _newPatientInfo.Equals(_oldPatientInfo);
		}
 public SeriesSelectCriteria(SeriesSelectCriteria other)
 : base(other)
 {}
Exemple #9
0
        /// <summary>
        /// Method for processing Series level queries.
        /// </summary>
        /// <param name="message"></param>
        /// <param name="del"></param>
        /// <returns></returns>
        public override void Query(DicomAttributeCollection message, ServerQueryResultDelegate del)
        {
            //Read context for the query.
            using (IReadContext read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                var tagList = new List<uint>();

                var selectSeries = read.GetBroker<ISeriesEntityBroker>();

                //TODO (CR May 2010): Should change so that the Partition AE Title is passed in the RetrieveAeTitle tag in the query message.
                var criteria = new SeriesSelectCriteria();
                if (Partition!=null)
                    criteria.ServerPartitionKey.EqualTo(Partition.Key);

                DicomAttributeCollection data = message;
                foreach (DicomAttribute attrib in message)
                {
                    tagList.Add(attrib.Tag.TagValue);
                    if (!attrib.IsNull)
                        switch (attrib.Tag.TagValue)
                        {
                            case DicomTags.StudyInstanceUid:
                                List<ServerEntityKey> list =
                                    LoadStudyKey(read, (string[])data[DicomTags.StudyInstanceUid].Values);
                                QueryHelper.SetKeyCondition(criteria.StudyKey, list.ToArray());
                                break;
                            case DicomTags.SeriesInstanceUid:
                                QueryHelper.SetStringArrayCondition(criteria.SeriesInstanceUid,
                                                        (string[])data[DicomTags.SeriesInstanceUid].Values);
                                break;
                            case DicomTags.Modality:
                                QueryHelper.SetStringCondition(criteria.Modality, data[DicomTags.Modality].GetString(0, string.Empty));
                                break;
                            case DicomTags.SeriesNumber:
                                QueryHelper.SetStringCondition(criteria.SeriesNumber, data[DicomTags.SeriesNumber].GetString(0, string.Empty));
                                break;
                            case DicomTags.SeriesDescription:
                                QueryHelper.SetStringCondition(criteria.SeriesDescription,
                                                   data[DicomTags.SeriesDescription].GetString(0, string.Empty));
                                break;
                            case DicomTags.PerformedProcedureStepStartDate:
                                QueryHelper.SetRangeCondition(criteria.PerformedProcedureStepStartDate,
                                                  data[DicomTags.PerformedProcedureStepStartDate].GetString(0, string.Empty));
                                break;
                            case DicomTags.PerformedProcedureStepStartTime:
                                QueryHelper.SetRangeCondition(criteria.PerformedProcedureStepStartTime,
                                                  data[DicomTags.PerformedProcedureStepStartTime].GetString(0, string.Empty));
                                break;
                            case DicomTags.RequestAttributesSequence: // todo
                                break;
                        }
                }

                // Open a second read context, in case other queries are required.
                using (IReadContext subRead = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                {
                    selectSeries.Find(criteria, delegate(Series row)
                    {
                        if (CancelReceived)
                            throw new DicomException("DICOM C-Cancel Received");

                        var response = new DicomMessage();
                        PopulateSeries(subRead, message, response, tagList, row);
                        del(response.DataSet);
                    });
                }

                return;
            }
        }
Exemple #10
0
		private StudySelectCriteria GetSelectCriteria()
		{
			var criteria = new StudySelectCriteria();

			// only query for device in this partition
			criteria.ServerPartitionKey.EqualTo(Partition.Key);

            QueryHelper.SetGuiStringCondition(criteria.PatientId,PatientId);
            QueryHelper.SetGuiStringCondition(criteria.PatientsName, PatientName);

			criteria.PatientsName.SortAsc(0);

            QueryHelper.SetGuiStringCondition(criteria.AccessionNumber, AccessionNumber);

            if (!String.IsNullOrEmpty(ToStudyDate) && !String.IsNullOrEmpty(FromStudyDate))
			{
                string toKey = DateTime.ParseExact(ToStudyDate, DateFormats, null).ToString(STUDYDATE_DATEFORMAT) + " 23:59:59.997";
                string fromKey = DateTime.ParseExact(FromStudyDate, DateFormats, null).ToString(STUDYDATE_DATEFORMAT);
				criteria.StudyDate.Between(fromKey, toKey);
            }
            else if (!String.IsNullOrEmpty(ToStudyDate))
            {
                string toKey = DateTime.ParseExact(ToStudyDate, DateFormats, null).ToString(STUDYDATE_DATEFORMAT);
                criteria.StudyDate.LessThanOrEqualTo(toKey);
            }
            else if (!String.IsNullOrEmpty(FromStudyDate))
            {
                string fromKey = DateTime.ParseExact(FromStudyDate, DateFormats, null).ToString(STUDYDATE_DATEFORMAT);
                criteria.StudyDate.MoreThanOrEqualTo(fromKey);
            }

            QueryHelper.SetGuiStringCondition(criteria.StudyDescription, StudyDescription);
            QueryHelper.SetGuiStringCondition(criteria.ReferringPhysiciansName, ReferringPhysiciansName);
            QueryHelper.SetGuiStringCondition(criteria.ResponsiblePerson, ResponsiblePerson);
            QueryHelper.SetGuiStringCondition(criteria.ResponsibleOrganization, ResponsibleOrganization);

            if(Modalities != null && Modalities.Length > 0)
			{
				var seriesCriteria = new SeriesSelectCriteria();

                QueryHelper.SetStringArrayCondition(seriesCriteria.Modality, Modalities);

				criteria.SeriesRelatedEntityCondition.Exists(seriesCriteria);
			}

            if (Statuses != null && Statuses.Length > 0)
            {
                var storageCriteria = new StudyStorageSelectCriteria();
                if (Statuses.Length == 1)
                    storageCriteria.StudyStatusEnum.EqualTo(StudyStatusEnum.GetEnum(Statuses[0]));
                else
                {
                    var statusList = new List<StudyStatusEnum>();
                    foreach(string status in Statuses)
                    {
                        statusList.Add(StudyStatusEnum.GetEnum(status));
                    }

                    storageCriteria.StudyStatusEnum.In(statusList);
                }

                criteria.StudyStorageRelatedEntityCondition.Exists(storageCriteria);
            }

			return criteria;
		}
Exemple #11
0
 public SeriesSelectCriteria(SeriesSelectCriteria other)
     : base(other)
 {
 }
Exemple #12
0
        protected override void OnInit(EventArgs e)
        {
            //This sets the GridView Page Size to the number of series. Needs to be done in the OnInit method,
            //since the page size needs to be set here, and the Study and Partition aren't set until the databind
            //happens in StudyDetailsTabs.
            
            var studyInstanceUID = Request.QueryString[ImageServerConstants.QueryStrings.StudyInstanceUID];
            var serverAE = Request.QueryString[ImageServerConstants.QueryStrings.ServerAE];

            if (!String.IsNullOrEmpty(studyInstanceUID) && !String.IsNullOrEmpty(serverAE))
            {
                var adaptor = new ServerPartitionDataAdapter();
                var partitionCriteria = new ServerPartitionSelectCriteria();
                partitionCriteria.AeTitle.EqualTo(serverAE);
                IList<ServerPartition> partitions = adaptor.Get(partitionCriteria);
                if (partitions != null && partitions.Count > 0)
                {
                    if (partitions.Count == 1)
                    {
                        var partition = partitions[0];

                        var studyAdaptor = new StudyAdaptor();
                        var studyCriteria = new StudySelectCriteria();
                        studyCriteria.StudyInstanceUid.EqualTo(studyInstanceUID);
                        studyCriteria.ServerPartitionKey.EqualTo(partition.GetKey());
                        var study = studyAdaptor.GetFirst(studyCriteria);

                        if (study!=null)
                        {
                            var seriesAdaptor = new SeriesSearchAdaptor();
                            var criteria = new SeriesSelectCriteria();
                            criteria.StudyKey.EqualTo(study.GetKey());
                            criteria.ServerPartitionKey.EqualTo(partition.GetKey());

                            Series = seriesAdaptor.Get(criteria);

                            GridView1.PageSize = Series.Count;
                        }
                        
                    }
                }
            }
            else
            {
                GridView1.PageSize = 150;   //Set it to a large number to ensure that all series are displayed if more than 25.
            }         
        }
Exemple #13
0
        public override void DataBind()
        {
            if (Study != null && Partition != null)
            {
                var seriesAdaptor = new SeriesSearchAdaptor();
                var criteria = new SeriesSelectCriteria();
                criteria.StudyKey.EqualTo(Study.Key);
                criteria.ServerPartitionKey.EqualTo(Partition.Key);

                Series = seriesAdaptor.Get(criteria);

                GridView1.DataSource = Series;
            }

            base.DataBind();
        }
Exemple #14
0
        /// <summary>
        /// Method for processing Study level queries.
        /// </summary>
        /// <param name="message"></param>
        /// <param name="del"></param>
        /// <returns></returns>
        public override void Query(DicomAttributeCollection message, ServerQueryResultDelegate del)
        {
            var tagList = new List<uint>();

            using (IReadContext read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
            {
                var find = read.GetBroker<IStudyEntityBroker>();

                //TODO (CR May 2010): Should change so that the Partition AE Title is passed in the RetrieveAeTitle tag in the query message.

                var criteria = new StudySelectCriteria();
                if (Partition !=null)
                    criteria.ServerPartitionKey.EqualTo(Partition.Key);

                if (!Thread.CurrentPrincipal.IsInRole(ClearCanvas.Enterprise.Common.AuthorityTokens.DataAccess.AllStudies))
                {
                    var principal = Thread.CurrentPrincipal as CustomPrincipal;
                    if (principal != null)
                    {
                        var oidList = new List<ServerEntityKey>();
                        foreach (var oid in principal.Credentials.DataAccessAuthorityGroups)
                            oidList.Add(new ServerEntityKey("OID", oid));
                        var dataAccessGroupSelectCriteria = new DataAccessGroupSelectCriteria();
                        dataAccessGroupSelectCriteria.AuthorityGroupOID.In(oidList);
                        IList<DataAccessGroup> groups;
                        using (IReadContext context = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                        {
                            var broker = context.GetBroker<IDataAccessGroupEntityBroker>();
                            groups = broker.Find(dataAccessGroupSelectCriteria);
                        }

                        var entityList = new List<ServerEntityKey>();
                        foreach (DataAccessGroup group in groups)
                        {
                            entityList.Add(group.Key);
                        }

                        var dataAccessSelectCriteria = new StudyDataAccessSelectCriteria();
                        dataAccessSelectCriteria.DataAccessGroupKey.In(entityList);

                        criteria.StudyDataAccessRelatedEntityCondition.Exists(dataAccessSelectCriteria);
                    }
                }



                DicomAttributeCollection data = message;
                foreach (DicomAttribute attrib in message)
                {
                    tagList.Add(attrib.Tag.TagValue);
                    if (!attrib.IsNull)
                        switch (attrib.Tag.TagValue)
                        {
                            case DicomTags.StudyInstanceUid:
                                QueryHelper.SetStringArrayCondition(criteria.StudyInstanceUid,
                                                        (string[]) data[DicomTags.StudyInstanceUid].Values);
                                break;
                            case DicomTags.PatientsName:
                                QueryHelper.SetStringCondition(criteria.PatientsName,
                                                   data[DicomTags.PatientsName].GetString(0, string.Empty));
                                break;
                            case DicomTags.PatientId:
                                QueryHelper.SetStringCondition(criteria.PatientId,
                                                   data[DicomTags.PatientId].GetString(0, string.Empty));
                                break;
                            case DicomTags.PatientsBirthDate:
                                QueryHelper.SetRangeCondition(criteria.PatientsBirthDate,
                                                  data[DicomTags.PatientsBirthDate].GetString(0, string.Empty));
                                break;
                            case DicomTags.PatientsSex:
                                QueryHelper.SetStringCondition(criteria.PatientsSex,
                                                   data[DicomTags.PatientsSex].GetString(0, string.Empty));
                                break;
                            case DicomTags.StudyDate:
                                QueryHelper.SetRangeCondition(criteria.StudyDate,
                                                  data[DicomTags.StudyDate].GetString(0, string.Empty));
                                break;
                            case DicomTags.StudyTime:
                                QueryHelper.SetRangeCondition(criteria.StudyTime,
                                                  data[DicomTags.StudyTime].GetString(0, string.Empty));
                                break;
                            case DicomTags.AccessionNumber:
                                QueryHelper.SetStringCondition(criteria.AccessionNumber,
                                                   data[DicomTags.AccessionNumber].GetString(0, string.Empty));
                                break;
                            case DicomTags.StudyId:
                                QueryHelper.SetStringCondition(criteria.StudyId, data[DicomTags.StudyId].GetString(0, string.Empty));
                                break;
                            case DicomTags.StudyDescription:
                                QueryHelper.SetStringCondition(criteria.StudyDescription,
                                                   data[DicomTags.StudyDescription].GetString(0, string.Empty));
                                break;
                            case DicomTags.ReferringPhysiciansName:
                                QueryHelper.SetStringCondition(criteria.ReferringPhysiciansName,
                                                   data[DicomTags.ReferringPhysiciansName].GetString(0, string.Empty));
                                break;
                            case DicomTags.ModalitiesInStudy:
                                // Specify a subselect on Modality in series
                                var seriesSelect = new SeriesSelectCriteria();
                                QueryHelper.SetStringArrayCondition(seriesSelect.Modality,
                                                        (string[]) data[DicomTags.ModalitiesInStudy].Values);
                                criteria.SeriesRelatedEntityCondition.Exists(seriesSelect);
                                break;
                        }
                }

                // Open another read context, in case additional queries are required.
                using (IReadContext subRead = PersistentStoreRegistry.GetDefaultStore().OpenReadContext())
                {
                    // First find the Online studies
                    var storageCriteria = new StudyStorageSelectCriteria();
                    storageCriteria.StudyStatusEnum.NotEqualTo(StudyStatusEnum.Nearline);
                    storageCriteria.QueueStudyStateEnum.NotIn(new[]
                                                                  {
                                                                      QueueStudyStateEnum.DeleteScheduled,
                                                                      QueueStudyStateEnum.WebDeleteScheduled,
                                                                      QueueStudyStateEnum.EditScheduled
                                                                  });
                    criteria.StudyStorageRelatedEntityCondition.Exists(storageCriteria);

                    find.Find(criteria, delegate(Study row)
                                            {
                                                var response = new DicomMessage();

                                            	//TODO (CR May 2010): should the availability be NEARLINE?  The criteria above was for ONLINE studies.
                                                PopulateStudy(subRead, response, tagList, row, "NEARLINE");
                                                del(response.DataSet);
                                            });

                    // Now find the Nearline studies
                    storageCriteria = new StudyStorageSelectCriteria();
                    storageCriteria.StudyStatusEnum.EqualTo(StudyStatusEnum.Nearline);
                    storageCriteria.QueueStudyStateEnum.NotIn(new[]
                                                                  {
                                                                      QueueStudyStateEnum.DeleteScheduled,
                                                                      QueueStudyStateEnum.WebDeleteScheduled,
                                                                      QueueStudyStateEnum.EditScheduled
                                                                  });
                    criteria.StudyStorageRelatedEntityCondition.Exists(storageCriteria);

                    find.Find(criteria, delegate(Study row)
                    {
                        var response = new DicomMessage();
                        PopulateStudy(subRead, response, tagList, row, "NEARLINE");
                        del(response.DataSet);
                    });

                }
            }

            return;
        }