Beispiel #1
0
        private void HandleMappingLoadingException(Exception e, string filename)
        {
            this.SetTaskbarProgressValue(100, 100);
            this.SetTaskbarProgressState(Taskbar.ThumbnailProgressState.Error);

            if (e is NanoXmlParsingException ||
                e is ObfuscarParserException ||
                e is IOException)
            {
                TaskDialogHelper.ShowMessageBox(
                    Handle,
                    "Mapping Loading Failed",
                    "Loading of mapping file is failed.",
                    "File:\n" + filename + "\nReason: " + e.Message,
                    TaskDialogStandardIcon.Error
                    );
            }
            else
            {
                RestApi.Instance.SendCrashReport(
                    new CrashReport("Mapping loading thread failed handler", "Error on loading document", CrashType.JustReport)
                {
                    Exception = e
                },
                    this
                    );
            }
        }
        private async void CheckForUpdates(bool silent)
        {
            miUpdateVersion.Enabled = false;
            VersionResponse oldVersion = Configs.Instance.UpdateHelper.UpdateAvailable;
            await Task.Run(() => Configs.Instance.UpdateHelper.CheckForUpdates());

            VersionResponse version = Configs.Instance.UpdateHelper.UpdateAvailable;

            miUpdateVersion.Enabled = true;

            if (version == null || version == oldVersion)
            {
                miUpdateVersion.Text = "Check for Updates";
                if (!silent)
                {
                    MessageBox.Show(this, $"You are using an actual version of the {APP_TITLE}.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                return;
            }

            miUpdateVersion.Text = $"Update to {version.Version}...";
            if (TaskDialogHelper.ShowTaskDialog(
                    Handle,
                    "Update is Available",
                    "The Obfuscar Mapping Parser update is available. Update now?",
                    version.Description,
                    TaskDialogStandardIcon.Information,
                    new string[] { "Update now", "Don't update" },
                    null,
                    new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                    ) == TaskDialogResult.Yes)
            {
                DoUpdateVersion();
            }
        }
Beispiel #3
0
        private async void miUpdateVersion_Click(object sender, EventArgs e)
        {
            BeginLoading("Checking for updates");
            UpdateHelper.UpdateCheckResult result = await Configs.Instance.UpdateHelper.CheckForUpdates();

            switch (result)
            {
            case UpdateHelper.UpdateCheckResult.NoUpdates:
                EndLoading("");
                TaskDialogHelper.ShowMessageBox(
                    Handle,
                    "No Updates",
                    $"You are using the most recent version of the {APP_TITLE}.",
                    null,
                    TaskDialogStandardIcon.Information
                    );
                break;

            case UpdateHelper.UpdateCheckResult.UpdateFound:
                EndLoading("");
                UpdateFound(Configs.Instance.UpdateHelper);
                break;

            case UpdateHelper.UpdateCheckResult.Failure:
                EndLoading("Failed to check for updates.");
                TaskDialogHelper.ShowMessageBox(
                    Handle,
                    "Failure",
                    "Unable to check for updates.",
                    null,
                    TaskDialogStandardIcon.Error
                    );
                break;
            }
        }
Beispiel #4
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            Patient patient = DicomUtils.FindPatient(this, _find, _scp, textBoxId.Text);

            if (patient != null)
            {
                textBoxLastname.Text      = patient.Name.Family;
                textBoxFirstname.Text     = patient.Name.Given;
                comboBoxSex.SelectedIndex = comboBoxSex.FindStringExact(patient.Sex);
                if (patient.BirthDate.HasValue)
                {
                    dateTimePickerBirth.Value   = patient.BirthDate.Value;
                    dateTimePickerBirth.Checked = true;
                }

                if (Program.OtherPID.ContainsKey(patient.Id))
                {
                    textBoxOtherPid.Text = Program.OtherPID[patient.Id];
                }
                else
                {
                    OtherPatientIds.Text = string.Empty;
                    textBoxOtherPid.Text = string.Empty;
                }
            }
            else
            {
                TaskDialogHelper.ShowMessageBox(this, "Patient Search", "Patient with specified id was not found.", string.Empty,
                                                string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                null);
            }
            ActionButton.Enabled = patient != null;
        }
Beispiel #5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var pluginManager = App.Context.PluginManager;
            var handle        = new WindowInteropHelper(this).Handle;

            pluginManager.LoadAll();
            pluginManager.InitAll();
            if (pluginLoadExceptions.Count > 0)
            {
                TaskDialogHelper.ShowMessage("Plugin load error",
                                             "One or more errors occurred while loading plugins. Some plugins may be unavailable. Check the log for more details.",
                                             TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Warning, handle);
                pluginLoadExceptions.Clear();
            }
            if (!pluginManager.AreAnyLoaded)
            {
#if DEBUG
                var buttons = TaskDialogStandardButtons.Ok | TaskDialogStandardButtons.Cancel;
#else
                var buttons = TaskDialogStandardButtons.Ok;
#endif
                if (TaskDialogHelper.ShowMessage("No plugins installed",
                                                 "No plugins could be found. If you have attempted to install a plugin, it may not be installed properly.",
                                                 buttons, TaskDialogStandardIcon.Error, handle) != TaskDialogResult.Cancel)
                {
                    Application.Current.Shutdown();
                }
            }
        }
Beispiel #6
0
        private void MoveSeries()
        {
            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Moving Series");

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                MoveSeries             move     = new MoveSeries();
                DicomCommandStatusType status   = DicomCommandStatusType.Success;
                ProgressDialog         progress = new ProgressDialog();

                move.PatientId = textBoxId.Text.Replace(@"\", @"\\").Replace("'", @"''");
                move.PatientToMerge.Add(new MergePatientSequence(_Patient.Id));
                move.SeriesInstanceUID = _Series.InstanceUID;
                move.Reason            = dlgReason.Reason;
                move.Operator          = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                move.Description       = "Move Series";

                Thread thread = new Thread(() =>
                {
                    try
                    {
                        status = _naction.SendNActionRequest <MoveSeries>(_scp, move, NActionScu.MoveSeries,
                                                                          NActionScu.PatientUpdateInstance);
                    }
                    catch (Exception e)
                    {
                        ApplicationUtils.ShowException(this, e);
                        status = DicomCommandStatusType.Failure;
                    }
                });

                progress.ActionThread = thread;
                progress.Title        = "Moving Series";
                progress.ProgressInfo = "Performing series move to patient: " + textBoxFirstname.Text + " " + textBoxLastname.Text + ".";
                progress.ShowDialog(this);

                if (status == DicomCommandStatusType.Success)
                {
                    _Action = ActionType.Merge;
                    TaskDialogHelper.ShowMessageBox(this, "Move Series", "The series has been successfully move.", GetMergeInfo(),
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    string message = "The series was not move.\r\nError - " + _naction.GetErrorMessage();

                    if (status == DicomCommandStatusType.MissingAttribute)
                    {
                        message = "The series was not move.\r\nSeries not found on server.";
                    }

                    TaskDialogHelper.ShowMessageBox(this, "Move Series Error", "The series was not moved.", message,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }
        private void AttachRelatedPdbs(IList <string> pdb, bool addToRecent)
        {
            if (pdb == null)
            {
                return;
            }

            TaskDialogResult allResult = TaskDialogResult.None;

            foreach (string s in pdb)
            {
                if (!File.Exists(s))
                {
                    continue;
                }

                TaskDialogResult result = allResult;

                if (result == TaskDialogResult.None)
                {
                    using (TaskDialog dialog = TaskDialogHelper.ConstructTaskDialog(
                               Handle,
                               "Attach PDB File",
                               "Attach related PDB file?",
                               s,
                               TaskDialogStandardIcon.Information
                               ))
                    {
                        dialog.AddCommandLink(TaskDialogResult.Yes, "Attach");
                        dialog.AddCommandLink(TaskDialogResult.Yes, "Don't attach");
                        dialog.FooterCheckBoxText    = "Do this for other PDBs of this mapping.";
                        dialog.FooterCheckBoxChecked = false;

                        result = dialog.Show();
                        if (dialog.FooterCheckBoxChecked.Value)
                        {
                            allResult = result;
                        }
                    }
                }

                switch (result)
                {
                case TaskDialogResult.Yes:
                    if (AttachPDB(s, this) && addToRecent)
                    {
                        Configs.Instance.AddRecentPdb(mapping.Filename, s);
                    }
                    break;

                case TaskDialogResult.No:
                    break;

                default:
                    return;
                }
            }
        }
Beispiel #8
0
        private void DeletePatientButton_Click(object sender, EventArgs e)
        {
            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Deleting Patient")
            {
                Icon = Icon
            };

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                ProgressDialog         progress   = new ProgressDialog();
                Patient                patient    = listViewPatients.SelectedItems[0].Tag as Patient;
                DeletePatient          delPatient = new DeletePatient();
                DicomCommandStatusType status     = DicomCommandStatusType.Success;

                delPatient.Reason      = dlgReason.Reason;
                delPatient.Operator    = Environment.UserName != string.Empty?Environment.UserName:Environment.MachineName;
                delPatient.Station     = Environment.MachineName;
                delPatient.PatientId   = patient.Id;
                delPatient.Description = "Patient Delete";
                Thread thread = new Thread(() =>
                {
                    try
                    {
                        status = _naction.SendNActionRequest <DeletePatient>(_server, delPatient, NActionScu.DeletePatient,
                                                                             NActionScu.PatientUpdateInstance);
                    }
                    catch (Exception ex)
                    {
                        ApplicationUtils.ShowException(this, ex);
                    }
                });

                progress.ActionThread = thread;
                progress.Title        = "Deleting Patient: " + patient.Name.Full;
                progress.ProgressInfo = "Performing patient delete.";
                progress.ShowDialog(this);
                if (status == DicomCommandStatusType.Success)
                {
                    //
                    // Remove the deleted patient from the list
                    //
                    DeletePatient(listViewPatients.SelectedItems[0]);
                }
                else
                {
                    if (status == DicomCommandStatusType.UnrecognizedOperation)
                    {
                        TaskDialogHelper.ShowMessageBox(this, "Error Deleting Patient", "Check Server Permissions", "There was an error deleting the patient. " +
                                                        "This is usually caused by invalid AE permissions.", string.Empty, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, null);
                    }
                    else
                    {
                        TaskDialogHelper.ShowMessageBox(this, "Error Deleting Patient", "Check Server Log", "There was an error deleting the patient. " +
                                                        string.Format("The server return the following error: {0}.", _naction.GetErrorMessage()), string.Empty, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, null);
                    }
                }
            }
        }
Beispiel #9
0
        public async void OpenInVisualStudio(string filename, int line)
        {
            if (!File.Exists(filename))
            {
                if (TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "File Not Exists",
                        "File not found. Would you like to locate file by sourself?",
                        "Filename: " + filename,
                        TaskDialogStandardIcon.Error,
                        new string[] { "Browse", "Cancel" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No, }
                        ) != TaskDialogResult.Yes)
                {
                    return;
                }

                string file = PathUtils.GetFilename(filename);
                odSourceFile.Filter   = file + "|" + file;
                odSourceFile.FileName = file;
                if (odSourceFile.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }

                filename = odSourceFile.FileName;
            }
            string vs = Configs.Instance.GetRecentProperty(mapping.Mapping.Filename, Configs.PROPERTY_EDITOR);

            if (vs == null)
            {
                vs = Configs.Instance.Editor;
            }
            IVisualStudioInfo visualStudio = VisualStudioDetector.GetVisualStudioInfo(vs);

            BeginLoading("Starting the Visual Studio...");
            try
            {
                await Task.Run(() => visualStudio.OpenFile(filename, line));
            }
            catch (Exception ex)
            {
                this.SetTaskbarProgressValue(100, 100);
                this.SetTaskbarProgressState(Taskbar.ThumbnailProgressState.Error);
                TaskDialogHelper.ShowMessageBox(
                    Handle,
                    "Failed to Open in Visual Studio",
                    "Failed to open in Visual Studio. Try to use another version of Visual Studio.",
                    filename + ":" + line + "\n" + ex.Message,
                    TaskDialogStandardIcon.Error
                    );
            }
            EndLoading("");
        }
 private void btnProcess_Click(object sender, EventArgs e)
 {
     try
     {
         tbValue.Text = mapping.Mapping.ProcessCrashlogText(tbValue.Text, btnSkipPrefix.Checked);
     }
     catch (Exception ex)
     {
         TaskDialogHelper.ShowMessageBox(
             Handle,
             "Failed",
             "Unable to process crashlog.",
             "Reason: " + ex.Message,
             TaskDialogStandardIcon.Error
             );
     }
 }
Beispiel #11
0
        private void DeleteCurrentPhoto()
        {
            string filename = (pictureBox.SelectedItem as ListBoxItem).Tag as string;

            bool proceed = false;

            if (System.Environment.OSVersion.Version.Major >= 6)
            {
                // Windows Vista or later, so use TaskDialog
                TaskDialogResult result = TaskDialogHelper.TaskDialog(new System.Windows.Interop.WindowInteropHelper(this).Handle,
                                                                      IntPtr.Zero, "Delete Picture",
                                                                      "Are you sure you want to delete '" + filename + "'?",
                                                                      "This will delete the picture permanently, rather than sending it to the Recycle Bin.",
                                                                      TaskDialogButtons.Yes | TaskDialogButtons.No, TaskDialogIcon.Warning);

                if (result == TaskDialogResult.Yes)
                {
                    proceed = true;
                }
            }
            else
            {
                // Earlier than Windows Vista, so just use MessageBox
                MessageBoxResult result = MessageBox.Show("Are you sure you want to delete '" + filename + "'?",
                                                          "Delete Picture", MessageBoxButton.YesNo, MessageBoxImage.Warning);

                if (result == MessageBoxResult.Yes)
                {
                    proceed = true;
                }
            }

            if (proceed)
            {
                try
                {
                    File.Delete(filename);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Cannot Rename File", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Beispiel #12
0
        private void UpdateFound(UpdateHelper updateHelper)
        {
            TaskDialogResult result = TaskDialogHelper.ShowTaskDialog(
                Handle,
                "Update is Available",
                $"The Obfuscar Mapping Parser update to {updateHelper.UpdateAvailable.Version} is available. Update now?",
                updateHelper.UpdateAvailable.Description,
                TaskDialogStandardIcon.Information,
                new string[] { "Update Now", "Schedule Update", "Ignore Update", "Cancel" },
                new string[] { "Perform update and restart app", "Perform update when app is closed", "Don't update to this version", null },
                new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.Ok, TaskDialogResult.No, TaskDialogResult.Cancel, }
                );

            switch (result)
            {
            // update now
            case TaskDialogResult.Yes:
                updateHelper.ScheduleUpdate(
                    UpdateHelper.BuildCommandLine(
                        null,
                        new Dictionary <string, string>
                {
                    { "doRestart", null },
                    { "restartCmd", mappingFilename }
                }
                        )
                    );
                Close();
                break;

            // schedule
            case TaskDialogResult.Ok:
                // run updater silently
                updateHelper.ScheduleUpdate(updateHelper.SilentCommandline);
                break;

            // ignore
            case TaskDialogResult.No:
                updateHelper.IgnoreUpdate();
                break;
            }
        }
Beispiel #13
0
        private void MainForm_Activated(object sender, EventArgs e)
        {
            if (mapping == null)
            {
                return;
            }

            foreach (PdbFile pdbFile in mapping.PdbFiles)
            {
                if (pdbFile.CheckFileModification() &&
                    TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "PDB File Change Detected",
                        "External PDB file change detected. Reload?",
                        pdbFile.Filename,
                        TaskDialogStandardIcon.Information,
                        new string[] { "Reload", "Don't reload" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                        ) == TaskDialogResult.Yes)
                {
                    pdbFile.ReloadFile();
                }
            }

            if (mapping.CheckModifications() &&
                TaskDialogHelper.ShowTaskDialog(
                    Handle,
                    "Mapping File Change Detected",
                    "External mapping file change detected. Reload?",
                    mapping.Mapping.Filename,
                    TaskDialogStandardIcon.Information,
                    new string[] { "Reload", "Don't reload" },
                    null,
                    new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                    ) == TaskDialogResult.Yes)
            {
                ReloadFile();
            }
        }
Beispiel #14
0
        private void DeleteSeriesButton_Click(object sender, EventArgs e)
        {
            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Deleting Series")
            {
                Icon = Icon
            };

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                Series                 series    = listViewSeries.SelectedItems[0].Tag as Series;
                DeleteSeries           delSeries = new DeleteSeries();
                DicomCommandStatusType status    = DicomCommandStatusType.Success;

                delSeries.Reason            = dlgReason.Reason;
                delSeries.Operator          = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                delSeries.Description       = "Series Delete";
                delSeries.StudyInstanceUID  = listViewSeries.SelectedItems[0].SubItems[listViewSeries.SelectedItems[0].SubItems.Count - 1].Text;
                delSeries.SeriesInstanceUID = series.InstanceUID;

                status = _naction.SendNActionRequest <DeleteSeries>(_server, delSeries, NActionScu.DeleteSeries,
                                                                    NActionScu.PatientUpdateInstance);
                if (status == DicomCommandStatusType.Success)
                {
                    DeleteSeries(listViewSeries.SelectedItems[0]);
                }
                else
                {
                    if (status == DicomCommandStatusType.UnrecognizedOperation)
                    {
                        TaskDialogHelper.ShowMessageBox(this, "Error Deleting Series", "Check Server Permissions", "There was an error deleting the series. " +
                                                        "This is usually caused by invalid AE permissions.", string.Empty, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, null);
                    }
                    else
                    {
                        TaskDialogHelper.ShowMessageBox(this, "Error Deleting Series", "Check Server Log", "There was an error deleting the series. " +
                                                        string.Format("The server return the following error: {0}.", _naction.GetErrorMessage()), string.Empty, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, null);
                    }
                }
            }
        }
Beispiel #15
0
        private void VerifyButton_Click(object sender, EventArgs e)
        {
            DicomScp scp = new DicomScp();
            PatientUpdaterConnection scu = new PatientUpdaterConnection();

            scp.AETitle     = _textBoxServerAE.Text;
            scp.PeerAddress = ResolveIPAddress(_textBoxServerIP.Text);
            scp.Port        = Convert.ToInt32(_textBoxServerPort.Text);
            scu.AETitle     = _textBoxClientAE.Text;
            try
            {
                bool   ret     = scu.Verify(scp);
                string scpInfo = scp.PeerAddress.ToString() + " (" + scp.Port.ToString() + ")";

                if (!scu.Rejected)
                {
                    if (ret)
                    {
                        TaskDialogHelper.ShowMessageBox(this, "Successful Verification", "Verified " + scp.AETitle, string.Empty,
                                                        scpInfo, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Information, null);
                    }
                    else
                    {
                        TaskDialogHelper.ShowMessageBox(this, "Failed Verification", "Unable to verify " + scp.AETitle, string.Empty,
                                                        scpInfo, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, null);
                    }
                }
                else
                {
                    TaskDialogHelper.ShowMessageBox(this, "Failed Verification", "Unable to verify " + scp.AETitle, scu.Reason,
                                                    scpInfo, TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, null);
                }
            }
            catch (Exception ex)
            {
                ApplicationUtils.ShowException(this, ex);
            }
        }
        private void btnDetach_Click(object sender, EventArgs e)
        {
            if (TaskDialogHelper.ShowTaskDialog(
                    Handle,
                    "Detach PDBs",
                    "Detach selected PDB files?",
                    null,
                    TaskDialogStandardIcon.Information,
                    new string[] { "Detach", "Don't detach" },
                    null,
                    new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                    ) != TaskDialogResult.Yes)
            {
                return;
            }

            foreach (ListViewItem item in lvList.SelectedItems)
            {
                PdbFile file = (PdbFile)item.Tag;
                files.Remove(file);
                Configs.Instance.RemoveRecentPdb(mainForm.Mapping.Filename, file.Filename);
                item.Remove();
            }
        }
Beispiel #17
0
        private void CopyPatient()
        {
            //
            // If the patient ID has changed then we need to see if a patient with that id already exists
            //
            if (_Patient.Id != textBoxId.Text)
            {
                PatientRootQueryPatient query    = new PatientRootQueryPatient();
                List <Patient>          patients = new List <Patient>();

                query.PatientQuery.PatientId = textBoxId.Text;
                try
                {
                    _find.Find <PatientRootQueryPatient, Patient>(_scp, query, (patient, ds) => patients.Add(patient));
                    if (patients.Count > 0)
                    {
                        TaskDialogResult result = TaskDialogResult.Yes;

                        result = TaskDialogHelper.ShowMessageBox(this, "Patient Id Already Exits", "Would you like to merge with existing patient?",
                                                                 "The patient id already exisits.", "Existing Patient: " + patients[0].Name.Full,
                                                                 TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No, TaskDialogStandardIcon.Error, TaskDialogStandardIcon.Warning);

                        if (result == TaskDialogResult.Yes)
                        {
                            radioButtonMerge.Checked = true;
                            textBoxLastname.Text     = patients[0].Name.Family;
                            textBoxFirstname.Text    = patients[0].Name.Given;
                            if (string.IsNullOrEmpty(patients[0].Sex))
                            {
                                comboBoxSex.Text = string.Empty;
                            }
                            else
                            {
                                comboBoxSex.SelectedIndex = comboBoxSex.FindStringExact(patients[0].Sex);
                            }
                            if (patients[0].BirthDate.HasValue)
                            {
                                dateTimePickerBirth.Value   = patients[0].BirthDate.Value;
                                dateTimePickerBirth.Checked = true;
                            }
                            else
                            {
                                dateTimePickerBirth.Checked = false;
                            }
                        }
                        else
                        {
                            textBoxId.Text = _Patient.Id;
                            return;
                        }
                    }
                }
                catch (Exception e)
                {
                    ApplicationUtils.ShowException(this, e);
                    return;
                }
            }

            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Copying Patient");

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                CopyPatient            change = new CopyPatient();
                DicomCommandStatusType status = DicomCommandStatusType.Success;

                change.OriginalPatientId = _Patient.Id.Replace(@"\", @"\\").Replace("'", @"''");
                change.Operator          = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                change.PatientId         = textBoxId.Text.Replace(@"\", @"\\").Replace("'", @"''");
                change.Reason            = dlgReason.Reason;
                change.Description       = "Copy Patient";
                change.Name.Given        = textBoxFirstname.Text.Replace(@"\", @"\\").Replace("'", @"''");
                change.Name.Family       = textBoxLastname.Text.Replace(@"\", @"\\").Replace("'", @"''");
                change.Sex = comboBoxSex.Text;
                if (dateTimePickerBirth.Checked)
                {
                    change.Birthdate = dateTimePickerBirth.Value;
                }
                else
                {
                    change.Birthdate = null;
                }

#if (LEADTOOLS_V19_OR_LATER)
                if (textBoxOtherPid.Text.Length > 0)
                {
                    Leadtools.Dicom.Common.DataTypes.PatientUpdater.OtherPatientID opid = new Leadtools.Dicom.Common.DataTypes.PatientUpdater.OtherPatientID();

                    change.OtherPatientIdsSequence = new List <Leadtools.Dicom.Common.DataTypes.PatientUpdater.OtherPatientID>();
                    opid.PatientId       = textBoxOtherPid.Text.Replace(@"\", @"\\").Replace("'", @"''");
                    opid.TypeOfPatientId = "TEXT";
                    change.OtherPatientIdsSequence.Add(opid);
                }
#endif

                status = _naction.SendNActionRequest <CopyPatient>(_scp, change, NActionScu.CopyPatient, NActionScu.PatientUpdateInstance);
                if (status == DicomCommandStatusType.Success)
                {
                    //_Patient.Id = textBoxId.Text;
                    //_Patient.Name.Given = textBoxFirstname.Text;
                    //_Patient.Name.Family = textBoxLastname.Text;
                    //_Patient.Sex = comboBoxSex.Text;
                    //if (dateTimePickerBirth.Checked)
                    //    _Patient.BirthDate = dateTimePickerBirth.Value;
                    //else
                    //    _Patient.BirthDate = null;
                    Action = ActionType.CopyPatient;
                    TaskDialogHelper.ShowMessageBox(this, "Patient Copied", "The patient has been successfully copied.", string.Empty,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    TaskDialogHelper.ShowMessageBox(this, "Copy Error", "The patient has not been successfully copied.", string.Empty,
                                                    "Error - " + _naction.GetErrorMessage(), TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }
Beispiel #18
0
        private void MergePatient()
        {
            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Merging Patient");

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                MergePatient           merge    = new MergePatient();
                DicomCommandStatusType status   = DicomCommandStatusType.Success;
                ProgressDialog         progress = new ProgressDialog();

                merge.PatientId   = textBoxId.Text;
                merge.Operator    = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                merge.Reason      = dlgReason.Reason;
                merge.Description = "Merge Patient";
                merge.PatientToMerge.Add(new MergePatientSequence(_Patient.Id));

                Thread thread = new Thread(() =>
                {
                    try
                    {
                        status = _naction.SendNActionRequest <MergePatient>(_scp, merge, NActionScu.MergePatient,
                                                                            NActionScu.PatientUpdateInstance);
                    }
                    catch (Exception e)
                    {
                        ApplicationUtils.ShowException(this, e);
                        status = DicomCommandStatusType.Failure;
                    }
                });

                progress.ActionThread = thread;
                progress.Title        = "Merging Patient: " + _Patient.Name.Full;
                progress.ProgressInfo = "Performing patient merge.";
                progress.ShowDialog(this);
                if (status == DicomCommandStatusType.Success)
                {
                    Action = ActionType.Merge;
                    TaskDialogHelper.ShowMessageBox(this, "Patient Merge", "The patient has been successfully merged.", GetMergeInfo(),
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    string message = "The patient has not been merged.\r\nError - ";
                    string footer  = string.Empty;

                    if (status == DicomCommandStatusType.Reserved2)
                    {
                        message += "Missing Files";
                    }
                    else
                    {
                        message += _naction.GetErrorMessage();
                    }

                    if (status == DicomCommandStatusType.MissingAttribute)
                    {
                        message = "The patient has not been merged.\r\nPatient not found on server.";
                    }
                    else if (status == DicomCommandStatusType.Reserved2)
                    {
                        footer = "Contact system administrator for help in resolving this issue.";
                    }

                    TaskDialogHelper.ShowMessageBox(this, "Merge Patient Error", "The patient has not been merged.", message,
                                                    footer, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }
Beispiel #19
0
        private void ChangePatient()
        {
            //
            // If the patient ID has changed then we need to see if a patient with that id already exists
            //
            if (_Patient.Id != textBoxId.Text)
            {
                PatientRootQueryPatient query    = new PatientRootQueryPatient();
                List <Patient>          patients = new List <Patient>();

                query.PatientQuery.PatientId = textBoxId.Text;
                try
                {
                    _find.Find <PatientRootQueryPatient, Patient>(_scp, query, (patient, ds) => patients.Add(patient));
                    if (patients.Count > 0)
                    {
                        TaskDialogResult result = TaskDialogResult.Yes;

                        result = TaskDialogHelper.ShowMessageBox(this, "Patient Id Already Exits", "Would you like to merge with existing patient?",
                                                                 "The patient id already exisits.", "Existing Patient: " + patients[0].Name.Full,
                                                                 TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No, TaskDialogStandardIcon.Error, TaskDialogStandardIcon.Warning);

                        if (result == TaskDialogResult.Yes)
                        {
                            radioButtonMerge.Checked  = true;
                            textBoxLastname.Text      = patients[0].Name.Family;
                            textBoxFirstname.Text     = patients[0].Name.Given;
                            comboBoxSex.SelectedIndex = comboBoxSex.FindStringExact(patients[0].Sex);
                            if (patients[0].BirthDate.HasValue)
                            {
                                dateTimePickerBirth.Value   = patients[0].BirthDate.Value;
                                dateTimePickerBirth.Checked = true;
                            }
                            else
                            {
                                dateTimePickerBirth.Checked = false;
                            }
                            MergePatient();
                            return;
                        }
                        else
                        {
                            textBoxId.Text = _Patient.Id;
                            return;
                        }
                    }
                }
                catch (Exception e)
                {
                    ApplicationUtils.ShowException(this, e);
                    return;
                }
            }

            bool isError = VerifyPatientSettings();

            if (isError)
            {
                return;
            }

            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Changing Patient");

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                ChangePatient          change = new ChangePatient();
                DicomCommandStatusType status = DicomCommandStatusType.Success;

                change.OriginalPatientId = _Patient.Id.Replace(@"\", @"\\").Replace("'", @"''");
                change.Operator          = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                change.PatientId         = textBoxId.Text.Replace(@"\", @"\\").Replace("'", @"''");
                change.Reason            = dlgReason.Reason;
                change.Description       = "Change Patient";
                change.Name.Given        = textBoxFirstname.Text.Replace(@"\", @"\\").Replace("'", @"''");
                change.Name.Family       = textBoxLastname.Text.Replace(@"\", @"\\").Replace("'", @"''");
                change.Sex = comboBoxSex.Text;
                if (dateTimePickerBirth.Checked)
                {
                    change.Birthdate = dateTimePickerBirth.Value;
                }
                else
                {
                    change.Birthdate = null;
                }

#if (LEADTOOLS_V19_OR_LATER)
                if (textBoxOtherPid.Text.Length > 0)
                {
                    change.OtherPatientIdsSequence = new List <Leadtools.Dicom.Common.DataTypes.PatientUpdater.OtherPatientID>();
                    string textBoxStringOtherPid = textBoxOtherPid.Text.Replace("'", @"''");

                    if (!string.IsNullOrEmpty(textBoxStringOtherPid))
                    {
                        char[]   delimiterChars  = { '\\' };
                        string[] otherPatientIds = textBoxStringOtherPid.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);

                        foreach (string otherPatientId in otherPatientIds)
                        {
                            Leadtools.Dicom.Common.DataTypes.PatientUpdater.OtherPatientID opid = new Leadtools.Dicom.Common.DataTypes.PatientUpdater.OtherPatientID();
                            opid.PatientId       = otherPatientId;
                            opid.TypeOfPatientId = "TEXT";
                            change.OtherPatientIdsSequence.Add(opid);
                        }
                    }
                }
#endif

                status = _naction.SendNActionRequest <ChangePatient>(_scp, change, NActionScu.ChangePatient,
                                                                     NActionScu.PatientUpdateInstance);
                if (status == DicomCommandStatusType.Success)
                {
                    _Patient.Id          = textBoxId.Text;
                    _Patient.Name.Given  = textBoxFirstname.Text;
                    _Patient.Name.Family = textBoxLastname.Text;
                    _Patient.Sex         = comboBoxSex.Text;
                    if (dateTimePickerBirth.Checked)
                    {
                        _Patient.BirthDate = dateTimePickerBirth.Value;
                    }
                    else
                    {
                        _Patient.BirthDate = null;
                    }
                    Action = ActionType.Change;
                    TaskDialogHelper.ShowMessageBox(this, "Patient Changed", "The patient has been successfully changed.", string.Empty,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                    DialogResult = DialogResult.OK;

                    if (change.OriginalPatientId != _Patient.Id)
                    {
                        if (Program.OtherPID.ContainsKey(change.OriginalPatientId))
                        {
                            Program.OtherPID.Remove(change.OriginalPatientId);
                        }
                    }

                    Program.OtherPID[_Patient.Id] = textBoxOtherPid.Text;
                }
                else
                {
                    string message = "The patient was not changed.\r\nError - " + _naction.GetErrorMessage();

                    if (status == DicomCommandStatusType.MissingAttribute)
                    {
                        message = "The patient was not changed.\r\nPatient not found on server.";
                    }

                    TaskDialogHelper.ShowMessageBox(this, "Change Patient Error", "The patient was not changed.", message,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }
        private void MainForm_DragDrop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            List <string> files = new List <string>((string[])e.Data.GetData(DataFormats.FileDrop));

            string fileToOpen = null;
            int    i          = 0;

            do
            {
                // search for xml files to open
                if (string.Compare(Path.GetExtension(files[i]).ToLower(), ".xml", StringComparison.Ordinal) == 0)
                {
                    fileToOpen = files[i];
                    files.RemoveAt(i);
                    continue;
                }

                // search for pdb files to attach after open
                if (string.Compare(Path.GetExtension(files[i]).ToLower(), ".pdb", StringComparison.Ordinal) == 0)
                {
                    if (pdbToAttach == null)
                    {
                        pdbToAttach = new List <string>();
                    }
                    pdbToAttach.Add(files[i]);
                }

                i++;
            }while (i < files.Count);

            // open file if found. found pdbs will be attached after open (pdbToAttach)
            if (fileToOpen != null)
            {
                if (MessageBox.Show(this, "Open file\n" + fileToOpen + "\n?", "Open file", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }

                OpenFile(fileToOpen);
                return;
            }

            if (mapping == null)
            {
                return;
            }

            // attach pdb files
            foreach (string file in files)
            {
                if (string.Compare(Path.GetExtension(file).ToLower(), ".pdb", StringComparison.Ordinal) == 0)
                {
                    TaskDialogResult d = TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "Attach PDB File",
                        "Attach related PDB file?",
                        file,
                        TaskDialogStandardIcon.Information,
                        new string[] { "Attach", "Don't attach", "Cancel operation" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No, TaskDialogResult.Cancel, }
                        );
                    switch (d)
                    {
                    case TaskDialogResult.Yes:
                        AttachPDB(file, this);
                        break;

                    case TaskDialogResult.No:
                        break;

                    default:
                        return;
                    }
                }
            }
        }
Beispiel #21
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            Patient patient = DicomUtils.FindPatient(this, _find, _scp, textBoxId.Text);

            if (!radioButtonMoveStudyToNewPatient.Checked)
            {
                if (patient != null)
                {
                    textBoxLastname.Text  = patient.Name.Family;
                    textBoxFirstname.Text = patient.Name.Given;
                    if (Program.OtherPID.ContainsKey(patient.Id))
                    {
                        textBoxOtherPid.Text = Program.OtherPID[patient.Id];
                    }
                    else
                    {
                        textBoxOtherPid.Text = string.Empty;
                    }
                    if (string.IsNullOrEmpty(patient.Sex))
                    {
                        comboBoxSex.Text = string.Empty;
                    }
                    else
                    {
                        comboBoxSex.SelectedIndex = comboBoxSex.FindStringExact(patient.Sex);
                    }
                    if (patient.BirthDate.HasValue)
                    {
                        dateTimePickerBirth.Value   = patient.BirthDate.Value;
                        dateTimePickerBirth.Checked = true;
                    }
                    else
                    {
                        dateTimePickerBirth.Checked = false;
                    }
                }
                else
                {
                    TaskDialogHelper.ShowMessageBox(this, "Patient Search", "Patient with specified id was not found.", string.Empty,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
                ActionButton.Enabled = patient != null;
            }
            else
            {
                if (patient != null)
                {
                    TaskDialogResult result = TaskDialogResult.Yes;

                    result = TaskDialogHelper.ShowMessageBox(this, "Patient Id Already Exits", "Would you like to merge the study with existing patient?",
                                                             "The patient id already exisits.", "Existing Patient: " + patient.Name.Full,
                                                             TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No, TaskDialogStandardIcon.Error, TaskDialogStandardIcon.Warning);
                    if (result == TaskDialogResult.Yes)
                    {
                        radioButtonMoveStudyToExistingPatient.Checked = true;
                        textBoxLastname.Text  = patient.Name.Family;
                        textBoxFirstname.Text = patient.Name.Given;
                        if (string.IsNullOrEmpty(patient.Sex))
                        {
                            comboBoxSex.Text = string.Empty;
                        }
                        else
                        {
                            comboBoxSex.SelectedIndex = comboBoxSex.FindStringExact(patient.Sex);
                        }
                        if (patient.BirthDate.HasValue)
                        {
                            dateTimePickerBirth.Value   = patient.BirthDate.Value;
                            dateTimePickerBirth.Checked = true;
                        }
                        else
                        {
                            dateTimePickerBirth.Checked = false;
                        }
                        ActionButton.Enabled = true;
                    }
                    else
                    {
                        ActionButton.Enabled = false;
                    }
                }
                else
                {
                    ActionButton.Enabled = true;
                }
            }

            CopyButton.Enabled = ActionButton.Enabled && !radioButtonMoveSeriesToExistingPatient.Checked;
        }
Beispiel #22
0
        /*
         * Example for deleting a study
         *
         * private void DeleteStudy()
         * {
         *   ReasonDialog dlgReason = new ReasonDialog("Input Reason For Deleting Study");
         *
         *   if (dlgReason.ShowDialog(this) == DialogResult.OK)
         *   {
         *      Leadtools.Dicom.Common.DataTypes.PatientUpdater.DeleteStudy deleteStudy = new Leadtools.Dicom.Common.DataTypes.PatientUpdater.DeleteStudy();
         *       DicomCommandStatusType status = DicomCommandStatusType.Success;
         *       ProgressDialog progress = new ProgressDialog();
         *
         *       deleteStudy.StudyInstanceUID = _StudyInstanceUID;
         *       deleteStudy.Operator = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
         *       deleteStudy.Reason = dlgReason.Reason;
         *       deleteStudy.Description = "Delete Study";
         *
         *       Thread thread = new Thread(() =>
         *           {
         *               try
         *               {
         *                  status = _naction.SendNActionRequest<Leadtools.Dicom.Common.DataTypes.PatientUpdater.DeleteStudy>(_scp, deleteStudy,
         *                     Leadtools.Dicom.Common.DataTypes.PatientUpdater.PatientUpdaterConstants.Action.DeleteStudy,
         *                                                               NActionScu.PatientUpdateInstance);
         *               }
         *               catch (Exception e)
         *               {
         *                   ApplicationUtils.ShowException(this, e);
         *                   status = DicomCommandStatusType.Failure;
         *               }
         *           });
         *
         *       progress.ActionThread = thread;
         *       progress.Title = "Deleting Study";
         *       progress.ProgressInfo = "Performing study delete.";
         *       progress.ShowDialog(this);
         *       if (status == DicomCommandStatusType.Success)
         *       {
         *           _Action = ActionType.Change;
         *           TaskDialogHelper.ShowMessageBox(this, "Study Deleted", "The study has been successfully deleted.", string.Empty,
         *                                           string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
         *                                           null);
         *           DialogResult = DialogResult.OK;
         *       }
         *       else
         *       {
         *          string message = "The study was not deleted.\r\nError - " + _naction.GetErrorMessage();
         *
         *           if (status == DicomCommandStatusType.MissingAttribute)
         *               message = "The study was not deleted.\r\nStudy not found on server.";
         *
         *           TaskDialogHelper.ShowMessageBox(this, "Delete Study Error", "The study was not deleted.", message,
         *                                       string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
         *                                       null);
         *       }
         *   }
         * }*/


        //Example for changing study information

        private void ChangeStudy()
        {
            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Changing Study");

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
#if LEADTOOLS_V19_OR_LATER
                ChangeStudy change = new ChangeStudy();
#else
                Leadtools.Dicom.Common.DataTypes.PatientUpdater.ChangeStudy change = new Leadtools.Dicom.Common.DataTypes.PatientUpdater.ChangeStudy();
#endif
                DicomCommandStatusType status   = DicomCommandStatusType.Success;
                ProgressDialog         progress = new ProgressDialog();
                change.StudyID          = txtID.Text;
                change.AccessionNumber  = txtAccession.Text;
                change.Description      = "Change Study";
                change.StudyDescription = txtDescription.Text;

                if (dateTimePickerStudyDate.Checked)
                {
                    change.StudyDate = dateTimePickerStudyDate.Value;
                }
                else
                {
                    change.StudyDate = null;
                }

                change.StudyInstanceUID = _StudyInstanceUID;
                change.Operator         = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                change.Reason           = dlgReason.Reason;

                Thread thread = new Thread(() =>
                {
                    try
                    {
#if LEADTOOLS_V19_OR_LATER
                        status = _naction.SendNActionRequest <ChangeStudy>(_scp, change, NActionScu.ChangeStudy,
                                                                           NActionScu.PatientUpdateInstance);
#else
                        status = _naction.SendNActionRequest <Leadtools.Dicom.Common.DataTypes.PatientUpdater.ChangeStudy>(_scp, change, NActionScu.ChangeStudy,
                                                                                                                           NActionScu.PatientUpdateInstance);
#endif
                    }
                    catch (Exception e)
                    {
                        ApplicationUtils.ShowException(this, e);
                        status = DicomCommandStatusType.Failure;
                    }
                });

                progress.ActionThread = thread;
                progress.Title        = "Changing Study";
                progress.ProgressInfo = "Performing study change.";
                progress.ShowDialog(this);
                if (status == DicomCommandStatusType.Success)
                {
                    _Action = ActionType.Change;
                    TaskDialogHelper.ShowMessageBox(this, "Study Changed", "The study has been successfully changed.", string.Empty,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    string message = "The study was not changed.\r\nError - " + _naction.GetErrorMessage();

                    if (status == DicomCommandStatusType.MissingAttribute)
                    {
                        message = "The study was not changed.\r\nStudy not found on server.";
                    }

                    TaskDialogHelper.ShowMessageBox(this, "Change Study Error", "The study was not changed.", message,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }
Beispiel #23
0
        private void AttachPDB(IList <string> files, bool addToRecent)
        {
            if (files == null || mapping == null)
            {
                return;
            }

            // single file - different dialog
            if (files.Count == 1)
            {
                if (TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "Attach PDB File",
                        "Attach PDB file?",
                        files[0],
                        TaskDialogStandardIcon.Information,
                        new string[] { "Attach", "Don't attach" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                        ) ==
                    TaskDialogResult.Yes)
                {
                    AttachPDB(files[0], this, addToRecent);
                }

                return;
            }

            bool isYesToAll = false;

            for (int i = 0; i < files.Count; i++)
            {
                string file = files[i];
                if (!File.Exists(file))
                {
                    continue;
                }

                if (mapping.IsPdbAttached(file))
                {
                    continue;
                }

                TaskDialogResult result;

                if (isYesToAll)
                {
                    result = TaskDialogResult.Yes;
                }
                else if (i == files.Count - 1)
                {
                    result = TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "Attach PDB File",
                        "Attach PDB file?",
                        files[0],
                        TaskDialogStandardIcon.Information,
                        new string[] { "Attach", "Don't attach" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.No }
                        );
                }
                else
                {
                    result = TaskDialogHelper.ShowTaskDialog(
                        Handle,
                        "Attach PDB File",
                        "Attach PDB file?",
                        files[0],
                        TaskDialogStandardIcon.Information,
                        new string[] { "Attach", "Attach All", "Don't attach", "Cancel" },
                        null,
                        new TaskDialogResult[] { TaskDialogResult.Yes, TaskDialogResult.Ok, TaskDialogResult.No, TaskDialogResult.Cancel, }
                        );
                }

                switch (result)
                {
                case TaskDialogResult.Yes: // "yes"
                    AttachPDB(file, this, addToRecent);
                    break;

                case TaskDialogResult.Ok: // "yes to all"
                    isYesToAll = true;
                    goto case TaskDialogResult.Yes;

                case TaskDialogResult.Cancel: // "cancel"
                    return;
                }
            }
        }
Beispiel #24
0
        private void ChangeSeries()
        {
            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Changing Series");

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                ChangeSeries           change   = new ChangeSeries();
                DicomCommandStatusType status   = DicomCommandStatusType.Success;
                ProgressDialog         progress = new ProgressDialog();

                change.SeriesInstanceUID = _Series.InstanceUID;
                change.Operator          = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                change.Reason            = dlgReason.Reason;
                change.Description       = "Change Series";
                change.Modality          = comboBoxModality.Text;
                change.SeriesDescription = textBoxDescription.Text.Replace(@"\", @"\\").Replace("'", @"''");
                if (dateTimePickerSeriesDate.Checked)
                {
                    change.SeriesDate = dateTimePickerSeriesDate.Value;
                }
                else
                {
                    change.SeriesDate = null;
                }

                if (dateTimePickerSeriesTime.Checked)
                {
                    change.SeriesTime = dateTimePickerSeriesTime.Value;
                }
                else
                {
                    change.SeriesTime = null;
                }

                Thread thread = new Thread(() =>
                {
                    try
                    {
                        status = _naction.SendNActionRequest <ChangeSeries>(_scp, change, NActionScu.ChangeSeries,
                                                                            NActionScu.PatientUpdateInstance);
                    }
                    catch (Exception e)
                    {
                        ApplicationUtils.ShowException(this, e);
                        status = DicomCommandStatusType.Failure;
                    }
                });

                progress.ActionThread = thread;
                progress.Title        = "Changing Series";
                progress.ProgressInfo = "Performing series change.";
                progress.ShowDialog(this);
                if (status == DicomCommandStatusType.Success)
                {
                    _Series.Modality    = comboBoxModality.Text;
                    _Series.Description = textBoxDescription.Text;
                    if (dateTimePickerSeriesDate.Checked)
                    {
                        _Series.Date = change.SeriesDate;
                    }
                    else
                    {
                        _Series.Date = null;
                    }

                    if (dateTimePickerSeriesTime.Checked)
                    {
                        _Series.Time = change.SeriesTime;
                    }
                    else
                    {
                        _Series.Time = null;
                    }

                    _Action = ActionType.Change;
                    TaskDialogHelper.ShowMessageBox(this, "Series Changed", "The series has been successfully changed.", string.Empty,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    string message = "The series was not changed.\r\nError - " + _naction.GetErrorMessage();

                    if (status == DicomCommandStatusType.MissingAttribute)
                    {
                        message = "The series was not changed.\r\nSeries not found on server.";
                    }

                    TaskDialogHelper.ShowMessageBox(this, "Change Series Error", "The series was not changed.", message,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }
Beispiel #25
0
        private void MoveToNewPatient()
        {
            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Moving Study To New Patient");

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                MoveToNewPatient       move     = new MoveToNewPatient();
                DicomCommandStatusType status   = DicomCommandStatusType.Success;
                ProgressDialog         progress = new ProgressDialog();

                move.PatientId = textBoxId.Text.Replace(@"\", @"\\").Replace("'", @"''");

#if (LEADTOOLS_V19_OR_LATER)
                if (textBoxOtherPid.Text.Length > 0)
                {
                    move.OtherPatientIds = new List <string>();
                    string textBoxStringOtherPid = textBoxOtherPid.Text.Replace("'", @"''");

                    if (!string.IsNullOrEmpty(textBoxStringOtherPid))
                    {
                        char[]   delimiterChars  = { '\\' };
                        string[] otherPatientIds = textBoxStringOtherPid.Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);

                        foreach (string otherPatientId in otherPatientIds)
                        {
                            move.OtherPatientIds.Add(otherPatientId);
                        }
                    }
                }
#endif

                move.Name.Given  = textBoxFirstname.Text.Replace(@"\", @"\\").Replace("'", @"''");
                move.Name.Family = textBoxLastname.Text.Replace(@"\", @"\\").Replace("'", @"''");
                move.Sex         = comboBoxSex.Text;
                move.PatientToMerge.Add(new MergePatientSequence(_Patient.Id));
                if (dateTimePickerBirth.Checked)
                {
                    move.Birthdate = dateTimePickerBirth.Value;
                }
                else
                {
                    move.Birthdate = null;
                }
                move.StudyInstanceUID = _StudyInstanceUID;
                move.Reason           = dlgReason.Reason;
                move.Operator         = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                move.Description      = "Move Study To New Patient";

                Thread thread = new Thread(() =>
                {
                    try
                    {
                        status = _naction.SendNActionRequest <MoveToNewPatient>(_scp, move, NActionScu.MoveStudyToNewPatient,
                                                                                NActionScu.PatientUpdateInstance);
                    }
                    catch (Exception e)
                    {
                        ApplicationUtils.ShowException(this, e);
                        status = DicomCommandStatusType.Failure;
                    }
                });

                progress.ActionThread = thread;
                progress.Title        = "Moving Study To New Patient";
                progress.ProgressInfo = "Performing study move to patient: " + textBoxFirstname.Text + " " + textBoxLastname.Text + ".";
                progress.ShowDialog(this);

                if (status == DicomCommandStatusType.Success)
                {
                    _Patient.Id          = textBoxId.Text;
                    _Patient.Name.Given  = textBoxFirstname.Text;
                    _Patient.Name.Family = textBoxLastname.Text;
                    _Patient.Sex         = comboBoxSex.Text;
                    if (dateTimePickerBirth.Checked)
                    {
                        _Patient.BirthDate = dateTimePickerBirth.Value;
                    }
                    else
                    {
                        _Patient.BirthDate = null;
                    }
                    _Action = ActionType.Move;
                    TaskDialogHelper.ShowMessageBox(this, "Study Moved To New Patient", "The study has been successfully moved.", string.Empty,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    string message = "The series was not moved.\r\nError - " + _naction.GetErrorMessage();

                    if (status == DicomCommandStatusType.MissingAttribute)
                    {
                        message = "The series was not moved.\r\nSeries not found on server.";
                    }

                    TaskDialogHelper.ShowMessageBox(this, "Move Series Error", "The series was not moved.", message,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }
Beispiel #26
0
        private void DoSearch()
        {
            ProgressDialog progress = new ProgressDialog();

            _query.PatientQuery.PatientId   = textBoxPatientId.Text;
            _query.PatientQuery.PatientName = GetPatientNameSearch();
            listViewSeries.BeginUpdate();
            listViewSeries.Items.Clear();
            listViewSeries.EndUpdate();
            //listViewPatients.BeginUpdate();
            listViewPatients.Items.Clear();
            _CurrentPatient             = null;
            EditPatientButton.Enabled   = false;
            DeletePatientButton.Enabled = false;
            EditSeriesButton.Enabled    = false;
            DeleteSeriesButton.Enabled  = false;

            DicomAE scp = GetScp();

            if (scp == null)
            {
                return;
            }

            _server.AETitle     = scp.AE;
            _server.PeerAddress = OptionsDialog.ResolveIPAddress(scp.IPAddress);
            _server.Port        = scp.Port;
            _server.Timeout     = scp.Timeout;

            Program.OtherPID.Clear();

            Thread thread = new Thread(delegate()
            {
                try
                {
                    _patientSearch = true;
                    _find.Find <PatientRootQueryPatient, Patient>(_server, _query, (p, ds) =>
                    {
                        string id = ds.GetValue <string>(DicomTag.OtherPatientIDs, string.Empty);

                        if (!string.IsNullOrEmpty(id))
                        {
                            Program.OtherPID[p.Id] = id;
                        }

                        SynchronizedInvoke(() => AddPatient(p));
                    });
                    if (_find.Rejected)
                    {
                        SynchronizedInvoke(() =>
                        {
                            TaskDialogHelper.ShowMessageBox(this, "No Records Found", "Association Failed", _find.Reason,
                                                            "Modify options and try again.", TaskDialogStandardButtons.Ok, TaskDialogStandardIcon.Error, TaskDialogStandardIcon.Information);
                        });
                    }
                }
                catch (Exception e)
                {
                    ApplicationUtils.ShowException(this, e);
                }
                SynchronizedInvoke(() => listViewPatients.Sort());
            });

            progress.Cancel = () =>
            {
                if (_find.IsAssociated())
                {
                    _find.AbortRequest(DicomAbortSourceType.User, DicomAbortReasonType.Unexpected);
                }
            };
            progress.ActionThread = thread;
            progress.Title        = "Finding Patients";
            progress.ProgressInfo = "Performing a patient search.";
            progress.ShowDialog(this);
            //listViewPatients.EndUpdate();
        }
Beispiel #27
0
        private async void MainForm_DragDrop(object sender, DragEventArgs e)
        {
            IDataObject dataObject = e.Data;

            if (!dataObject.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            List <string> files    = new List <string>((string[])e.Data.GetData(DataFormats.FileDrop));
            List <string> pdbFiles = null;

            string fileToOpen = null;
            int    i          = 0;

            do
            {
                string ext = Path.GetExtension(files[i]).ToLower();

                // search for xml files to open
                if (FormatFactory.HasExtension(ext))
                {
                    fileToOpen = files[i];
                    files.RemoveAt(i);
                    continue;
                }

                // search for pdb files to attach after open
                if (ext == ".pdb")
                {
                    if (pdbFiles == null)
                    {
                        pdbFiles = new List <string>();
                    }
                    pdbFiles.Add(files[i]);
                }

                i++;
            }while (i < files.Count);

            // open file if found. found pdbs will be attached after open (pdbToAttach)
            if (fileToOpen != null)
            {
                if (TaskDialogHelper.ShowMessageBox(
                        Handle,
                        "Open File",
                        "Open file?",
                        fileToOpen,
                        TaskDialogStandardIcon.Information,
                        TaskDialogStandardButtons.Yes | TaskDialogStandardButtons.No
                        ) !=
                    TaskDialogResult.Yes
                    )
                {
                    return;
                }

                await OpenFile(fileToOpen);

                return;
            }

            if (mapping == null)
            {
                return;
            }

            AttachPDB(pdbFiles, true);
        }
Beispiel #28
0
        private void CopyStudy()
        {
            ReasonDialog dlgReason = new ReasonDialog("Input Reason For Copying Study");

            if (dlgReason.ShowDialog(this) == DialogResult.OK)
            {
                CopyStudy move = new CopyStudy();
                DicomCommandStatusType status   = DicomCommandStatusType.Success;
                ProgressDialog         progress = new ProgressDialog();

                move.PatientId       = textBoxId.Text.Replace(@"\", @"\\").Replace("'", @"''");
                move.OtherPatientIDs = textBoxOtherPid.Text;
                move.Name.Given      = textBoxFirstname.Text.Replace(@"\", @"\\").Replace("'", @"''");
                move.Name.Family     = textBoxLastname.Text.Replace(@"\", @"\\").Replace("'", @"''");
                move.Sex             = comboBoxSex.Text;
                move.PatientToMerge.Add(new MergePatientSequence(_Patient.Id));
                if (dateTimePickerBirth.Checked)
                {
                    move.Birthdate = dateTimePickerBirth.Value;
                }
                else
                {
                    move.Birthdate = null;
                }
                move.StudyInstanceUID = _StudyInstanceUID;
                move.Reason           = dlgReason.Reason;
                move.Operator         = Environment.UserName != string.Empty ? Environment.UserName : Environment.MachineName;
                move.Description      = "Copy Study";

                Thread thread = new Thread(() =>
                {
                    try
                    {
                        status = _naction.SendNActionRequest <CopyStudy>(_scp, move, NActionScu.CopyStudy,
                                                                         NActionScu.PatientUpdateInstance);
                    }
                    catch (Exception e)
                    {
                        ApplicationUtils.ShowException(this, e);
                        status = DicomCommandStatusType.Failure;
                    }
                });

                progress.ActionThread = thread;
                progress.Title        = "Copying Study";
                progress.ProgressInfo = "Performing study copy: " + textBoxFirstname.Text + " " + textBoxLastname.Text + ".";
                progress.ShowDialog(this);

                if (status == DicomCommandStatusType.Success)
                {
                    _Action = ActionType.CopyStudy;
                    TaskDialogHelper.ShowMessageBox(this, "Study Copied", "The study has been successfully copied.", string.Empty,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    string message = "The series was not copied.\r\nError - " + _naction.GetErrorMessage();

                    if (status == DicomCommandStatusType.MissingAttribute)
                    {
                        message = "The series was not copied.\r\nSeries not found on server.";
                    }

                    TaskDialogHelper.ShowMessageBox(this, "Copy Series Error", "The series was not copied.", message,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }