static public Study Find(IPersistenceContext context, ServerEntityKey studyStorageKey) { IStudyEntityBroker broker = context.GetBroker <IStudyEntityBroker>(); StudySelectCriteria criteria = new StudySelectCriteria(); criteria.StudyStorageKey.EqualTo(studyStorageKey); return(broker.FindOne(criteria)); }
public IList <Study> LoadRelatedStudies() { using (var context = new ServerExecutionContext()) { IStudyEntityBroker broker = context.ReadContext.GetBroker <IStudyEntityBroker>(); StudySelectCriteria criteria = new StudySelectCriteria(); criteria.PatientKey.EqualTo(Key); return(broker.Find(criteria)); } }
public IList <Study> LoadRelatedStudies() { using (IReadContext read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IStudyEntityBroker broker = read.GetBroker <IStudyEntityBroker>(); StudySelectCriteria criteria = new StudySelectCriteria(); criteria.PatientKey.EqualTo(Key); return(broker.Find(criteria)); } }
/// <summary> /// Find a <see cref="Study"/> with the specified study instance uid on the given partition. /// </summary> /// <param name="studyInstanceUid"></param> /// <param name="partition"></param> /// <returns></returns> /// static public Study Find(IPersistenceContext context, String studyInstanceUid, ServerPartition partition) { IStudyEntityBroker broker = context.GetBroker <IStudyEntityBroker>(); StudySelectCriteria criteria = new StudySelectCriteria(); criteria.ServerPartitionKey.EqualTo(partition.GetKey()); criteria.StudyInstanceUid.EqualTo(studyInstanceUid); Study study = broker.FindOne(criteria); return(study); }
private void LoadStudyPartition(string studyInstanceUid) { using (IReadContext read = PersistentStoreRegistry.GetDefaultStore().OpenReadContext()) { IStudyEntityBroker selectStudy = read.GetBroker <IStudyEntityBroker>(); StudySelectCriteria criteria = new StudySelectCriteria(); criteria.StudyInstanceUid.EqualTo(studyInstanceUid); Study theStudy = selectStudy.FindOne(criteria); Partition = ServerPartition.Load(read, theStudy.ServerPartitionKey); } }
private void UpdateDatabase() { // Reload the StudyStorage and Study tables. LoadEntities(); UpdateEntity(_study); UpdateEntity(_curPatient); UpdateEntity(_storage); SetStudyEncoding(_study); // Update the Study table IStudyEntityBroker studyUpdateBroker = UpdateContext.GetBroker <IStudyEntityBroker>(); studyUpdateBroker.Update(_study); // Update the StudyStorage table IStudyStorageEntityBroker storageUpdateBroker = UpdateContext.GetBroker <IStudyStorageEntityBroker>(); storageUpdateBroker.Update(_storage); // 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) { UpdateCurrentPatient(); UpdatePatientEncoding(_curPatient); } else if (_newPatient == null) { // No matching patient in the database. We should create a new patient for this study _newPatient = CreateNewPatient(_newPatientInfo); UpdatePatientEncoding(_newPatient); } 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); UpdatePatientEncoding(_newPatient); } }
protected override void OnExecute(ServerCommandProcessor theProcessor, IUpdateContext updateContext) { Study study = _location.Study ?? Study.Find(updateContext, _location.Key); if (study.StudySizeInKB != _studySizeInKB) { IStudyEntityBroker broker = updateContext.GetBroker <IStudyEntityBroker>(); StudyUpdateColumns parameters = new StudyUpdateColumns() { StudySizeInKB = _studySizeInKB }; if (!broker.Update(study.Key, parameters)) { throw new ApplicationException("Unable to update study size in the database"); } } }
private Study GetStudyAndQueues(StudyStorageLocation location, out int integrityQueueCount, out int workQueueCount) { using (IReadContext context = _store.OpenReadContext()) { IStudyIntegrityQueueEntityBroker integrityBroker = context.GetBroker <IStudyIntegrityQueueEntityBroker>(); StudyIntegrityQueueSelectCriteria integrityCriteria = new StudyIntegrityQueueSelectCriteria(); integrityCriteria.StudyStorageKey.EqualTo(location.Key); integrityQueueCount = integrityBroker.Count(integrityCriteria); IWorkQueueEntityBroker workBroker = context.GetBroker <IWorkQueueEntityBroker>(); WorkQueueSelectCriteria workCriteria = new WorkQueueSelectCriteria(); workCriteria.StudyStorageKey.EqualTo(location.Key); workQueueCount = workBroker.Count(workCriteria); IStudyEntityBroker procedure = context.GetBroker <IStudyEntityBroker>(); StudySelectCriteria criteria = new StudySelectCriteria(); criteria.StudyStorageKey.EqualTo(location.Key); return(procedure.FindOne(criteria)); } }