Ejemplo n.º 1
0
		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);
			}

			
		}
Ejemplo n.º 2
0
 static public Series Insert(IUpdateContext update, Series entity)
 {
     var broker = update.GetBroker<ISeriesEntityBroker>();
     var updateColumns = new SeriesUpdateColumns();
     updateColumns.ServerPartitionKey = entity.ServerPartitionKey;
     updateColumns.StudyKey = entity.StudyKey;
     updateColumns.SeriesInstanceUid = entity.SeriesInstanceUid;
     updateColumns.Modality = entity.Modality;
     updateColumns.NumberOfSeriesRelatedInstances = entity.NumberOfSeriesRelatedInstances;
     updateColumns.PerformedProcedureStepStartDate = entity.PerformedProcedureStepStartDate;
     updateColumns.PerformedProcedureStepStartTime = entity.PerformedProcedureStepStartTime;
     updateColumns.SourceApplicationEntityTitle = entity.SourceApplicationEntityTitle;
     updateColumns.SeriesNumber = entity.SeriesNumber;
     updateColumns.SeriesDescription = entity.SeriesDescription;
     Series newEntity = broker.Insert(updateColumns);
     return newEntity;
 }
Ejemplo n.º 3
0
		private void UpdateDatabase()
		{
			var patientUpdate = new PatientUpdateColumns();
			var seriesUpdate = new SeriesUpdateColumns();
			var studyUpdate = new StudyUpdateColumns();

			// Update Patient level info. Different cases can occur here: 
			//      A) Patient demographic info is not changed ==> update the current patient
			//      B) New patient demographics matches (another) existing patient in the datbase 
			//              ==> Transfer the study to that patient. This means the study count on both patients must be updated.
			//                  The current patient should also be deleted if there's no more study attached to it after the transfer.
			//      C) New patient demographics doesn't match any patient in the database
			//              ==> A new patient should be created for this study. The study count on the current patient should be updated
			//                  and the patient should also be deleted if this is the only study attached to it.
			if (_patientInfoIsNotChanged)
			{
				_newPatient = _curPatient;
			}
			else if (_newPatient == null)
			{
				// No matching patient in the database. We should create a new patient for this study
				_newPatient = CreateNewPatient(_newPatientInfo);
			}
			else
			{
				// There's already patient in the database with the new patient demographics
				// The study should be attached to that patient.
				TransferStudy(_study.Key, _oldPatientInfo, _newPatient);
			}

			// Copy the existing valus over into the study & series objects
			// Note, this sets up an update statement that will update the key columns for
			// Study Instance UID, Series Instance UID, however, note that the columns will not
			// actually change value.  Its alittle ugly, but it will make it so if we add new
			// columns in the future, it just "works".
			_file.DataSet.LoadDicomFields(patientUpdate);
			_file.DataSet.LoadDicomFields(studyUpdate);
			_file.DataSet.LoadDicomFields(seriesUpdate);

			// Get any extensions that exist and process them
			var ep = new ProcessorInsertExtensionPoint();
			var extensions = ep.CreateExtensions();
			foreach (IInsertExtension e in extensions)
				e.UpdateExtension(_partition.Key, patientUpdate,studyUpdate,seriesUpdate, _file);

			UpdatePatientEncoding(_newPatient, patientUpdate);
			SetStudyEncoding(_study, studyUpdate);

			// Update the Study table
			var patientUpdateBroker = UpdateContext.GetBroker<IPatientEntityBroker>();
			patientUpdateBroker.Update(_newPatient.Key, patientUpdate);

			// Update the Study table
			var studyUpdateBroker = UpdateContext.GetBroker<IStudyEntityBroker>();
			studyUpdateBroker.Update(_study.Key, studyUpdate);

			// Update the Series table
			var seriesUpdateBroker = UpdateContext.GetBroker<ISeriesEntityBroker>();
			seriesUpdateBroker.Update(_curSeries.Key, seriesUpdate);

			// If the Request Attributes Sequence is in the dataset, do an insert.
			// Small hole in this that if the value of this sequence has changed, both the old and
			// the new values will stay in the database, not much to do about it, except
			// reprocess the whole series, which doesn't seem worth it.
			if (_file.DataSet.Contains(DicomTags.RequestAttributesSequence))
			{
				var attribute = _file.DataSet[DicomTags.RequestAttributesSequence] as DicomAttributeSQ;
				if (attribute != null && !attribute.IsEmpty)
				{
					foreach (DicomSequenceItem sequenceItem in (DicomSequenceItem[])attribute.Values)
					{
						var requestParms = new RequestAttributesInsertParameters();
						sequenceItem.LoadDicomFields(requestParms);
						requestParms.SeriesKey = _curSeries.Key;

						var insertRequest = UpdateContext.GetBroker<IInsertRequestAttributes>();
						insertRequest.Execute(requestParms);
					}
				}
			}
		}