コード例 #1
0
ファイル: MainForm.cs プロジェクト: sakpung/webstudy
        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);
                    }
                }
            }
        }
コード例 #2
0
ファイル: EditPatientDialog.cs プロジェクト: sakpung/webstudy
        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);
                }
            }
        }
コード例 #3
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);
                }
            }
        }