private void AddExamInfo(ReceivedDicomElements receivedDicomElements, ref CachedDicomElements cachedDicomElements) { cachedDicomElements.PatientId = AppendIfNotExist(cachedDicomElements.PatientId, receivedDicomElements.Elements.GetSafeStringValue(t.PatientID)); cachedDicomElements.PatientName = AppendIfNotExist(cachedDicomElements.PatientName, receivedDicomElements.Elements.GetSafeStringValue(t.PatientName)); cachedDicomElements.Modality = AppendIfNotExist(cachedDicomElements.Modality, receivedDicomElements.Elements.GetSafeStringValue(t.Modality)); cachedDicomElements.AccessionNumber = AppendIfNotExist(cachedDicomElements.AccessionNumber, receivedDicomElements.Elements.GetSafeStringValue(t.AccessionNumber)); }
public IEnumerable <ReceivedDicomElements> GetStorageCommitmentReferenceDicomElements( ReceivedDicomElements receivedDicomElements) { var refDicomElementsList = new List <ReceivedDicomElements>(); var refSops = receivedDicomElements.Elements[t.ReferencedSOPSequence] as Sequence; if (refSops != null) { var count = refSops.Items.Count; for (var n = 0; n < count; n++) { var item = refSops.Items[n]; var refSop = item[t.ReferencedSOPInstanceUID].Value; if (refSop != null) { var refElements = FindReceivedDicomElementsBySopInstanceUid(refSop.ToString()); if (refElements != null) { refDicomElementsList.Add(refElements); } } } } return(refDicomElementsList); }
public CachedDicomElements CreateCachedFromReceived(ReceivedDicomElements receivedDicomElements) { var cachedDicomElements = new CachedDicomElements() { CallingAeIpAddress = receivedDicomElements.CallingAeIpAddress, CallingAeTitle = receivedDicomElements.CallingAeTitle, FileName = receivedDicomElements.FileName, ReceivedDateTime = receivedDicomElements.ReceivedDateTime, ImageSource = receivedDicomElements.ImageSource, ImageStatus = receivedDicomElements.ImageStatus, }; if (receivedDicomElements.ImageSource == ImageSource.StorageCommitment) { foreach (var storageCommitmentReferenceDicomElement in GetStorageCommitmentReferenceDicomElements(receivedDicomElements)) { AddExamInfo(storageCommitmentReferenceDicomElement, ref cachedDicomElements); } } else { AddExamInfo(receivedDicomElements, ref cachedDicomElements); } return(cachedDicomElements); }
private void OnMpps(object sender, MppsEventArgs e) { var message = string.Empty; var hasError = true; try { var receivedDicomElements = new ReceivedDicomElements { CallingAeTitle = e.CallingAeTitle, CallingAeIpAddress = e.CallingAeIpAddress, ReceivedDateTime = DateTime.Now, Elements = e.DataSet, ImageSource = ImageSource.Mpps, ImageStatus = dicomServiceWorkerUser.OpenWhenReceived() ? ImageMemoryStatus.OpenedInWindow : ImageMemoryStatus.CachedInMemory }; message = string.Format("AeTitle : {0}, IpAddress : {1}", receivedDicomElements.CallingAeTitle, receivedDicomElements.IpAddress); OnDicomElementsReceived(receivedDicomElements); message = "Mpps successfull! -- " + message; hasError = false; } catch (Exception ex) { message = "Mpps failed! -- " + message + " " + ex.Message; } finally { dicomServiceWorkerUser.ShowMessage(message, hasError, false); } }
public void OnDicomElementsReceived(ReceivedDicomElements receivedDicomElements) { ListCachedElements.Add(receivedDicomElements); if (dicomServiceWorkerUser.SaveWhenReceived()) { SaveToDicomDir(receivedDicomElements, dicomServiceWorkerUser.GetActiveStorage()); } dicomServiceWorkerUser.OnDicomElementsReceived(receivedDicomElements); }
private void OnStorageCommitRequested(object sender, StorageCommitEventArgs e) { var receivedDicomElements = new ReceivedDicomElements { Elements = e.DataSet, ReceivedDateTime = DateTime.Now, ImageSource = ImageSource.StorageCommitment, CallingAeTitle = e.CallingAeTitle, CallingAeIpAddress = e.CallingAeIpAddress, ImageStatus = ImageMemoryStatus.CachedInMemory }; OnDicomElementsReceived(receivedDicomElements); }
public void SaveToDicomDir(ReceivedDicomElements receivedDicomElements, string dicomDirName) { var message = " -- DicomDir : " + dicomDirName + ", "; var hasError = true; try { if (receivedDicomElements.ImageSource == ImageSource.LocalDicomFile) { message += "File : " + receivedDicomElements.FileName; } else { message += string.Format("AeTitle : {0}, IpAddress : {1}", receivedDicomElements.CallingAeTitle, receivedDicomElements.IpAddress); } var dicomDirPath = Path.Combine(StorageRootPath, dicomDirName); var dicomDir = new DicomDir(dicomDirPath); dicomDir.Add(receivedDicomElements.Elements); dicomDir.Save(); receivedDicomElements.OnDicomDirSaved(dicomDirName); dicomServiceWorkerUser.OnDicomDirSaved(receivedDicomElements, dicomDirName); message = "Save to dicom dir successfull!" + message; hasError = false; } catch (Exception ex) { message = "Save to dicom dir failed!" + message + " " + ex.Message; } finally { dicomServiceWorkerUser.ShowMessage(message, hasError, false); } }
private void OnImagePrinted(object sender, PrintJobEventArgs e) { var message = string.Empty; var hasError = true; try { var page = e.Session.FilmBoxes[0]; var elements = OtherImageFormats.RenderPage(page); var receivedDicomElements = new ReceivedDicomElements { CallingAeTitle = e.CallingAeTitle, CallingAeIpAddress = e.CallingAeIpAddress, ReceivedDateTime = DateTime.Now, Elements = elements, ImageSource = ImageSource.Print, ImageStatus = dicomServiceWorkerUser.OpenWhenReceived() ? ImageMemoryStatus.OpenedInWindow : ImageMemoryStatus.CachedInMemory }; message = string.Format("AeTitle : {0}, IpAddress : {1}", receivedDicomElements.CallingAeTitle, receivedDicomElements.IpAddress); OnDicomElementsReceived(receivedDicomElements); message = "Print successfull! -- " + message; hasError = false; } catch (Exception ex) { message = "Print failed! -- " + message + " " + ex.Message; } finally { dicomServiceWorkerUser.ShowMessage(message, hasError, false); } }
public bool SendStorageCommit(ReceivedDicomElements receivedDicomElements, int port, bool success) { var result = true; try { var commit = new StorageCommitServiceSCU(); commit.Syntaxes.Add(Syntax.ImplicitVrLittleEndian); commit.Role = Role.Scp; var association = new Association(); association.AddService(commit); var host = new ApplicationEntity(receivedDicomElements.CallingAeTitle, IPAddress.Parse(receivedDicomElements.IpAddress), port); if (association.Open(host)) { if (commit.Active) { try { DataSet reportElements; if (!success) { reportElements = new DataSet { { t.TransactionUID, receivedDicomElements.Elements.GetSafeStringValue(t.TransactionUID) }, { t.RetrieveAETitle, host.Title } }; // add the FailedSOPSequence var sequence = new Sequence(t.FailedSOPSequence); reportElements.Add(sequence); var failedList = GetStorageCommitmentReferenceDicomElements(receivedDicomElements) .Where(x => x.SavedToDicomDir == false && x.SavedToDisk == false).ToList(); foreach (var failedElements in failedList) { var item = sequence.NewItem(); item.Add(t.ReferencedSOPClassUID, failedElements.Elements.GetSafeStringValue(t.SOPClassUID)); item.Add(t.ReferencedSOPInstanceUID, failedElements.Elements.GetSafeStringValue(t.SOPInstanceUID)); item.Add(t.FailureReason, 274); } reportElements.Add(t.Status, 2); } else { reportElements = receivedDicomElements.Elements; reportElements.Set(t.Status, 1); } result = commit.Report(reportElements); } catch (Exception ex) { result = false; } } } else { result = false; } association.Close(); } catch { } return(result); }