Ejemplo n.º 1
0
        private void UpdatePatientEncoding(Patient patient)
        {
            // Note: patient can be an existing one or a new one

            // set the SpecificCharacterSet of the patient and study record. This will update the database
            // and force Patient/Study/Series level query response to be encoded in UTF8. Image level responses
            // will be encoded using the character set in the image (see QueryScpExtension) 
            //
            if (atLeastOneFileUpdatedToUTF8)
            {
                // Only update the db if necessary
                if (!IsUTF8(patient.SpecificCharacterSet))
                {
                    Platform.Log(LogLevel.Info, "Updating encoding for patient information in the database to UTF8 [ Name={0}, ID={1} ]", patient.Name, patient.PatientId);
                    
                    // update to UTF8
                    patient.SpecificCharacterSet = UTF8;

                    // This method is called at the very end of UpdateDatabase(), update the database now
                    IPatientEntityBroker broker = UpdateContext.GetBroker<IPatientEntityBroker>();
                    PatientUpdateColumns columns = new PatientUpdateColumns() { SpecificCharacterSet = UTF8 };
                    broker.Update(patient.Key, columns);
                }
            }
        }
Ejemplo n.º 2
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);
					}
				}
			}
		}
Ejemplo n.º 3
0
 static public Patient Insert(IUpdateContext update, Patient entity)
 {
     var broker = update.GetBroker<IPatientEntityBroker>();
     var updateColumns = new PatientUpdateColumns();
     updateColumns.ServerPartitionKey = entity.ServerPartitionKey;
     updateColumns.NumberOfPatientRelatedStudies = entity.NumberOfPatientRelatedStudies;
     updateColumns.NumberOfPatientRelatedSeries = entity.NumberOfPatientRelatedSeries;
     updateColumns.NumberOfPatientRelatedInstances = entity.NumberOfPatientRelatedInstances;
     updateColumns.SpecificCharacterSet = entity.SpecificCharacterSet;
     updateColumns.PatientsName = entity.PatientsName;
     updateColumns.PatientId = entity.PatientId;
     updateColumns.IssuerOfPatientId = entity.IssuerOfPatientId;
     Patient newEntity = broker.Insert(updateColumns);
     return newEntity;
 }
Ejemplo n.º 4
0
		private void UpdatePatientEncoding(Patient patient, PatientUpdateColumns update)
		{
			// set the SpecificCharacterSet of the patient and study record. This will update the database
			// and force Patient/Study/Series level query response to be encoded in UTF8. Image level responses
			// will be encoded using the character set in the image (see QueryScpExtension) 
			//
			// Only update the db if necessary
			if (IsUTF8(patient.SpecificCharacterSet))
			{
				update.SpecificCharacterSet = UTF8;
			}
		}
Ejemplo n.º 5
0
		private void UpdatePatientDemographics(ServerEntityKey patientEntityKey, PatientInfo patientInfo)
		{
			Platform.Log(LogLevel.Info, "Update patient record...");
			var patientUpdateBroker = UpdateContext.GetBroker<IPatientEntityBroker>();
			var columns = new PatientUpdateColumns();
			columns.IssuerOfPatientId = patientInfo.IssuerOfPatientId;
			columns.PatientId = patientInfo.PatientId;
			columns.PatientsName = patientInfo.PatientsName;
			if (atLeastOneFileUpdatedToUTF8) 
				columns.SpecificCharacterSet = UTF8;
			
			patientUpdateBroker.Update(patientEntityKey, columns);

		}