private ReconcileStudyQueueDescription CreateQueueEntryDescription(DicomFile file) { using(var context = new ServerExecutionContext()) { Study study = _studyLocation.LoadStudy(context.PersistenceContext); if (study!=null) { var desc = new ReconcileStudyQueueDescription { ExistingPatientId = study.PatientId, ExistingPatientName = study.PatientsName, ExistingAccessionNumber = study.AccessionNumber, ConflictingPatientName = file.DataSet[DicomTags.PatientsName].ToString(), ConflictingPatientId = file.DataSet[DicomTags.PatientId].ToString(), ConflictingAccessionNumber = file.DataSet[DicomTags.AccessionNumber].ToString() }; return desc; } return null; } }
private static ReconcileStudyQueueDescription GetQueueEntryDescription(StudyStorageLocation existingStorage, DicomMessageBase file) { ReconcileStudyQueueDescription desc = new ReconcileStudyQueueDescription { ExistingPatientId = existingStorage.Study.PatientId, ExistingPatientName = existingStorage.Study.PatientsName, ExistingAccessionNumber = existingStorage.Study.AccessionNumber, ConflictingPatientName = file.DataSet[DicomTags.PatientsName].GetString(0, String.Empty), ConflictingPatientId = file.DataSet[DicomTags.PatientId].GetString(0, String.Empty), ConflictingAccessionNumber = file.DataSet[DicomTags.AccessionNumber].GetString(0, String.Empty) }; return desc; }
/// <summary> /// Constructs an instance of <see cref="WorkQueue"/> based on a <see cref="WorkQueueSummary"/> object. /// </summary> /// <param name="item"></param> /// <returns></returns> /// <remark> /// /// </remark> private StudyIntegrityQueueSummary CreateStudyIntegrityQueueSummary(StudyIntegrityQueue item) { var summary = new StudyIntegrityQueueSummary(); var ssAdaptor = new StudyStorageAdaptor(); var storages = ssAdaptor.Get(HttpContextData.Current.ReadContext, item.StudyStorageKey); try { summary.Reason = item.StudyIntegrityReasonEnum; summary.TheStudyIntegrityQueueItem = item; summary.ThePartition = Partition; var queueDescription = new ReconcileStudyQueueDescription(); queueDescription.Parse(item.Description); summary.QueueData = item.StudyIntegrityReasonEnum.Equals(StudyIntegrityReasonEnum.InconsistentData) ? XmlUtils.Deserialize<ReconcileStudyWorkQueueData>(item.Details) : XmlUtils.Deserialize<DuplicateSIQQueueData>(item.Details); ImageSetDescriptor studyData = ImageSetDescriptor.Parse(item.StudyData.DocumentElement); // These fields only exists in Enterprise version if (summary.QueueData.Details != null && summary.QueueData.Details.StudyInfo!=null) { summary.ReceivedTime = item.InsertTime; summary.ConflictingPatientId = summary.QueueData.Details.StudyInfo.PatientInfo.PatientId; summary.ConflictingPatientName = summary.QueueData.Details.StudyInfo.PatientInfo.Name; summary.ConflictingAccessionNumber = summary.QueueData.Details.StudyInfo.AccessionNumber; summary.ConflictingStudyDate = summary.QueueData.Details.StudyInfo.StudyDate; summary.ConflictingStudyDescription = summary.QueueData.Details.StudyInfo.StudyDescription; var modalities = new List<string>(); List<SeriesInformation> seriesList = summary.QueueData.Details.StudyInfo.Series; foreach (SeriesInformation series in seriesList) { if (!modalities.Contains(series.Modality)) modalities.Add(series.Modality); } summary.ConflictingModalities = modalities.ToArray(); } else { string value; if (studyData.TryGetValue(DicomTags.PatientId, out value)) summary.ConflictingPatientId = value; if (studyData.TryGetValue(DicomTags.PatientsName, out value)) summary.ConflictingPatientName = value; if (studyData.TryGetValue(DicomTags.AccessionNumber, out value)) summary.ConflictingAccessionNumber = value; if (studyData.TryGetValue(DicomTags.StudyDate, out value)) summary.ConflictingStudyDate = value; if (studyData.TryGetValue(DicomTags.StudyDescription, out value)) summary.ConflictingStudyDescription = value; // no modality info } // Fetch existing study info. Note: this is done last because the study may not exist. Study study = storages.LoadStudy(HttpContextData.Current.ReadContext); summary.StudySummary = StudySummaryAssembler.CreateStudySummary(HttpContextData.Current.ReadContext, study); if (summary.StudySummary!=null) { summary.StudyInstanceUid = summary.StudySummary.StudyInstanceUid; summary.ExistingPatientName = summary.StudySummary.PatientsName; summary.ExistingPatientId = summary.StudySummary.PatientId; summary.ExistingAccessionNumber = summary.StudySummary.AccessionNumber; } } catch(StudyNotFoundException) { // Study record may not exist. For eg, duplicate arrives but the existing study hasn't been processed. } return summary; }