Ejemplo n.º 1
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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            DeletePatient patient = new DeletePatient();

            patient.Pid = Convert.ToInt32(Text7.Value);
            string msg = client.Delete(patient);

            labelParseMessage.Text = msg.ToString();
        }
Ejemplo n.º 3
0
        public DicomCommandStatusType OnNAction(DicomClient Client, byte PresentationId, int MessageID, string AffectedClass, string Instance, int Action, DicomDataSet Request, DicomDataSet Response)
        {
            ClientSession clientSession             = null;
            INActionClientSessionProxy sessionProxy = null;
            DicomCommand patientUpdateCommand       = null;

            CompositeInstanceDataSet.InstanceRow[] instanceRows = null;

            if (_TemporaryDirectory == null)
            {
                _TemporaryDirectory = Client.Server.TemporaryDirectory;
            }

            if (Instance != PatientUpdaterConstants.UID.PatientUpdateInstance)
            {
                return(DicomCommandStatusType.InvalidObjectInstance);
            }

            if (clientSession != null)
            {
                clientSession.NActionResponse -= clientSession_NActionResponse;
                clientSession = null;
            }

            clientSession = new ClientSession(Client);
            clientSession.NActionResponse += new EventHandler <NActionResponseEventArgs>(clientSession_NActionResponse);
            sessionProxy         = new NActionClientSessionProxy(clientSession, PresentationId, MessageID, AffectedClass, Instance, Action, Response);
            patientUpdateCommand = DicomCommandFactory.GetInstance().CreateNActionCommand(sessionProxy, Request);

            _ClientSession = clientSession;
            _SessionProxy  = sessionProxy;


            //
            // If we are deleting we need to get the instance rows
            //
            List <string> studyInstanceUids;

            instanceRows = GetInstanceRows(Action, Request, out studyInstanceUids);

            ConfigureCommand(patientUpdateCommand as PatientUpdaterCommand);
            _ClientSession.ProcessNActionRequest(PresentationId, MessageID, AffectedClass, Instance, Action, patientUpdateCommand).WaitOne();

            if (_Status == DicomCommandStatusType.Success)
            {
                //
                // We need to delete the dicom files according to the user options
                //
                if (Action == PatientUpdaterConstants.Action.DeletePatient || Action == PatientUpdaterConstants.Action.DeleteSeries)
                {
                    if (instanceRows != null)
                    {
                        DicomFileDeleter deleter = new DicomFileDeleter();

                        try
                        {
                            StorageAddInsConfiguration storageSettings = Module.StorageConfigManager.GetStorageAddInsSettings();

                            deleter.DicomFileDeleted      += new EventHandler <Leadtools.Medical.Winforms.EventBrokerArgs.DicomFileDeletedEventArgs>(deleter_DicomFileDeleted);
                            deleter.DicomFileDeleteFailed += new EventHandler <Leadtools.Medical.Winforms.EventBrokerArgs.DicomFileDeletedEventArgs>(deleter_DicomFileDeleteFailed);
                            if (storageSettings != null)
                            {
                                deleter.DeleteFilesOnDatabaseDelete = storageSettings.StoreAddIn.DeleteFiles;
                                deleter.BackupFilesOnDatabaseDelete = storageSettings.StoreAddIn.BackupFilesOnDelete;
                                deleter.BackupFilesOnDeleteFolder   = storageSettings.StoreAddIn.DeleteBackupLocation;
                            }
                            deleter.Delete(null, instanceRows);
                        }
                        catch (Exception e)
                        {
                            Logger.Global.Error(Module.Source, "[Patient Updater] " + e.Message);
                        }
                        finally
                        {
                            deleter.DicomFileDeleted      -= deleter_DicomFileDeleted;
                            deleter.DicomFileDeleteFailed -= deleter_DicomFileDeleteFailed;
                        }
                    }
                }

                //
                // If auto update is enabled we need to forward this message to associated ae title
                //
                if (Module.Options != null && Module.Options.EnableAutoUpdate && Module.UpdateQueue != null)
                {
                    AutoUpdateItem item = new AutoUpdateItem(Client.AETitle)
                    {
                        Action = Action, ClientAE = Client.Server.AETitle
                    };

                    if (Action == PatientUpdaterConstants.Action.MergePatient && (instanceRows != null))
                    {
                        MergePatient mergePatientData = Request.Get <MergePatient>(null);
                        foreach (string studyInstanceUid in studyInstanceUids)
                        {
                            mergePatientData.ReferencedStudySequence.Add(new StudyInstanceReference(studyInstanceUid));
                        }
                        mergePatientData.PatientToMerge.Clear();
                        Request.Set(mergePatientData);
                    }
                    else if (studyInstanceUids.Count > 0)
                    {
                        DeletePatient deletePatientData = Request.Get <DeletePatient>(null);
                        foreach (string studyInstanceUid in studyInstanceUids)
                        {
                            deletePatientData.ReferencedStudySequence.Add(new StudyInstanceReference(studyInstanceUid));
                        }
                        Request.Set(deletePatientData);
                    }


                    // Request.InsertElementAndSetValue(DicomTag.ReferencedStudySequence)
                    item.Dicom = Request;

                    if (ShouldAutoUpdate(item.Action))
                    {
                        Module.UpdateQueue.AddItem(item);
                    }
                }
            }
            return(_Status);
        }
Ejemplo n.º 4
0
        private static CompositeInstanceDataSet.InstanceRow[] GetInstanceRows(int action, DicomDataSet request, out List <string> studyInstanceUids)
        {
            CompositeInstanceDataSet.InstanceRow[] rows = null;
            CompositeInstanceDataSet    ds  = null;
            MatchingParameterCollection mpc = new MatchingParameterCollection();
            MatchingParameterList       mpl = new MatchingParameterList();

            studyInstanceUids = new List <string>();

            if (request == null)
            {
                return(null);
            }

            if (Module.StorageAgent == null)
            {
                return(null);
            }

            switch (action)
            {
            case PatientUpdaterConstants.Action.MergePatient:
                MergePatient mergePatient = request.Get <MergePatient>();
                if (mergePatient.PatientToMerge != null && mergePatient.PatientToMerge.Count > 0)
                {
                    mpl.Add(new Patient()
                    {
                        PatientID = mergePatient.PatientToMerge[0].PatientId
                    });
                    mpc.Add(mpl);
                }
                break;

            case PatientUpdaterConstants.Action.DeletePatient:
                DeletePatient delPatient = request.Get <DeletePatient>();

                mpl.Add(new Patient()
                {
                    PatientID = delPatient.PatientId
                });
                foreach (StudyInstanceReference studyInstanceReference in delPatient.ReferencedStudySequence)
                {
                    mpl.Add(new Study()
                    {
                        StudyInstanceUID = studyInstanceReference.StudyInstanceUID
                    });
                }
                mpc.Add(mpl);
                break;

            case PatientUpdaterConstants.Action.DeleteSeries:
                DeleteSeries delSeries = request.Get <DeleteSeries>();

                mpl.Add(new Series()
                {
                    SeriesInstanceUID = delSeries.SeriesInstanceUID
                });
                mpc.Add(mpl);
                break;

            case PatientUpdaterConstants.Action.ChangePatient:
                ChangePatient changePatient = request.Get <ChangePatient>();
                mpl.Add(new Patient()
                {
                    PatientID = changePatient.OriginalPatientId
                });
                mpc.Add(mpl);
                break;

            default:
                return(null);
            }

            ds = Module.StorageAgent.QueryCompositeInstances(mpc).ToCompositeInstanceDataSet();

            CompositeInstanceDataSet.StudyRow[] studyRows = ds.Study.Rows.OfType <CompositeInstanceDataSet.StudyRow>().ToArray();
            foreach (CompositeInstanceDataSet.StudyRow studyRow in studyRows)
            {
                studyInstanceUids.Add(studyRow.StudyInstanceUID);
            }

            rows = ds.Instance.Rows.OfType <CompositeInstanceDataSet.InstanceRow>().ToArray();

            return(rows);
        }
Ejemplo n.º 5
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            DeletePatient deletePatient = new DeletePatient();

            deletePatient.Show();
        }