public void Initialize(ReconcileStudyProcessorContext context, bool complete) { Platform.CheckForNullReference(context, "context"); Context = context; ReconcileMergeToExistingStudyDescriptor desc = XmlUtils.Deserialize <ReconcileMergeToExistingStudyDescriptor>(Context.History.ChangeDescription); MergeStudyCommand command = new MergeStudyCommand(Context, context.History.DestStudyStorageKey == null, desc.Commands, complete); AddCommand(command); if (complete) { AddCleanupCommands(); } }
public void MergeStudy(ServerEntityKey itemKey, Boolean useExistingStudy) { InconsistentDataSIQRecord record = new InconsistentDataSIQRecord(StudyIntegrityQueue.Load(itemKey)); ReconcileMergeToExistingStudyDescriptor command = new ReconcileMergeToExistingStudyDescriptor { UserName = ServerHelper.CurrentUserName, Automatic = false, ExistingStudy = record.ExistingStudyInfo, ImageSetData = record.ConflictingImageDescriptor }; if (useExistingStudy) { command.Description = "Merge using existing study information."; String xml = XmlUtils.SerializeAsString(command); ReconcileStudy(xml, record.QueueItem); } else { command.Description = "Using study information from the conflicting images."; if (record.ConflictingImageDetails != null) { // The conflicting study data is stored in Details column string newPatientName = record.ConflictingImageDetails.StudyInfo.PatientInfo.Name; if (!String.IsNullOrEmpty(newPatientName)) { string acceptableName = PatientNameRules.GetAcceptableName(newPatientName); if (!acceptableName.Equals(newPatientName)) { //override the value newPatientName = acceptableName; } } command.Commands.Add(new SetTagCommand(DicomTags.PatientsName, record.ExistingStudyInfo.PatientInfo.Name, newPatientName)); command.Commands.Add(new SetTagCommand(DicomTags.PatientId, record.ExistingStudyInfo.PatientInfo.PatientId, record.ConflictingImageDetails.StudyInfo.PatientInfo.PatientId)); command.Commands.Add(new SetTagCommand(DicomTags.PatientsBirthDate, record.ExistingStudyInfo.PatientInfo.PatientsBirthdate, record.ConflictingImageDetails.StudyInfo.PatientInfo.PatientsBirthdate)); command.Commands.Add(new SetTagCommand(DicomTags.PatientsSex, record.ExistingStudyInfo.PatientInfo.Sex, record.ConflictingImageDetails.StudyInfo.PatientInfo.Sex)); command.Commands.Add(new SetTagCommand(DicomTags.IssuerOfPatientId, record.ExistingStudyInfo.PatientInfo.IssuerOfPatientId, record.ConflictingImageDetails.StudyInfo.PatientInfo.IssuerOfPatientId)); command.Commands.Add(new SetTagCommand(DicomTags.AccessionNumber, record.ExistingStudyInfo.AccessionNumber, record.ConflictingImageDetails.StudyInfo.AccessionNumber)); } else { // The conflicting study data is stored in StudyData column String patientName = record.ConflictingImageDescriptor[DicomTags.PatientsName] != null ? record.ConflictingImageDescriptor[DicomTags.PatientsName].Value : null; if (!String.IsNullOrEmpty(patientName)) { string acceptableName = PatientNameRules.GetAcceptableName(patientName); if (!acceptableName.Equals(patientName)) { //override the value patientName = acceptableName; } } if (patientName != null) { command.Commands.Add(new SetTagCommand(DicomTags.PatientsName, record.ExistingStudyInfo.PatientInfo.Name, patientName)); } String patientId = record.ConflictingImageDescriptor[DicomTags.PatientId] != null ? record.ConflictingImageDescriptor[DicomTags.PatientId].Value : null; if (patientId != null) { command.Commands.Add(new SetTagCommand(DicomTags.PatientId, record.ExistingStudyInfo.PatientInfo.PatientId, patientId)); } String patientsBirthDate = record.ConflictingImageDescriptor[DicomTags.PatientsBirthDate] != null ? record.ConflictingImageDescriptor[DicomTags.PatientsBirthDate].Value : null; if (patientsBirthDate != null) { command.Commands.Add(new SetTagCommand(DicomTags.PatientsBirthDate, record.ExistingStudyInfo.PatientInfo.PatientsBirthdate, patientsBirthDate)); } String patientsSex = record.ConflictingImageDescriptor[DicomTags.PatientsSex] != null ? record.ConflictingImageDescriptor[DicomTags.PatientsSex].Value : null; if (patientsSex != null) { command.Commands.Add(new SetTagCommand(DicomTags.PatientsSex, record.ExistingStudyInfo.PatientInfo.Sex, patientsSex)); } String issuerOfPatientId = record.ConflictingImageDescriptor[DicomTags.IssuerOfPatientId] != null ? record.ConflictingImageDescriptor[DicomTags.IssuerOfPatientId].Value : null; if (issuerOfPatientId != null) { command.Commands.Add(new SetTagCommand(DicomTags.IssuerOfPatientId, record.ExistingStudyInfo.PatientInfo.IssuerOfPatientId, issuerOfPatientId)); } String accessionNumber = record.ConflictingImageDescriptor[DicomTags.AccessionNumber] != null ? record.ConflictingImageDescriptor[DicomTags.AccessionNumber].Value : null; if (accessionNumber != null) { command.Commands.Add(new SetTagCommand(DicomTags.AccessionNumber, record.ExistingStudyInfo.AccessionNumber, accessionNumber)); } } String xml = XmlUtils.SerializeAsString(command); ReconcileStudy(xml, record.QueueItem); } }