示例#1
0
        protected override void OnReceiveCFindResponse(byte presentationID, int messageID, string affectedClass,
                                                       DicomCommandStatusType status, DicomDataSet dataSet)
        {
            InvokeStatusEvent(StatusType.ReceiveCFindResponse, status);

            switch (status)
            {
            case DicomCommandStatusType.Success:
            case DicomCommandStatusType.Warning:
                Event.Set();
                break;

            case DicomCommandStatusType.Pending:
            case DicomCommandStatusType.PendingWarning:
                AddDS(dataSet);
                break;

            default:
                Event.Set();
                break;
            }

            if (null != dataSet)
            {
                dataSet.Dispose();
            }
        }
示例#2
0
        protected override void OnReceiveNActionResponse
        (
            byte presentationID,
            int messageID,
            string affectedClass,
            string instance,
            DicomCommandStatusType status,
            int action,
            DicomDataSet dataSet
        )
        {
            try
            {
                base.OnReceiveNActionResponse(presentationID, messageID, affectedClass, instance, status, action, dataSet);

                _status = status;
            }
            catch (Exception e)
            {
                Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined, DateTime.Now,
                                  LogType.Information, MessageDirection.None, e.Message, null, null);

                throw;
            }
            finally
            {
                dicomEventResponse.Set();
            }
        }
示例#3
0
        protected override void OnReceiveCMoveResponse(byte presentationID, int messageID, string affectedClass,
                                                       DicomCommandStatusType status, int remaining, int completed, int failed, int warning, DicomDataSet dataSet)
        {
            InvokeStatusEvent(StatusType.ReceiveCMoveResponse, DicomExceptionCode.Success, completed, remaining, status);
            //Event.Set();
            switch (status)
            {
            case DicomCommandStatusType.Success:
            case DicomCommandStatusType.Warning:
                Event.Set();
                break;

            case DicomCommandStatusType.Pending:
                AddDS(dataSet);
                break;

            default:
                Event.Set();
                break;
            }

            if (null != dataSet)
            {
                dataSet.Dispose();
            }
        }
示例#4
0
        private void SendUpdate(AutoUpdateItem item)
        {
            AeInfo[] aes = _AccessAgent.GetRelatedAeTitles(item.SourceAE, UPDATE_RELATION);
            DicomScp scp = null;

            if (aes == null || aes.Length == 0)
            {
                return;
            }

            foreach (AeInfo ae in aes)
            {
                using (UpdateProcessor processor = new UpdateProcessor(Module.Options.UseCustomAE ? Module.Options.AutoUpdateAE : item.ClientAE))
                {
                    try
                    {
                        DicomCommandStatusType status = DicomCommandStatusType.Reserved4;

                        if (processor.Scu.IsConnected())
                        {
                            processor.Scu.CloseForced(true);
                        }
                        scp    = new DicomScp(IPAddress.Parse(ae.Address), ae.AETitle, ae.Port);
                        status = processor.SendUpdate(scp, item.Dicom, item.Action);
                        if (status != DicomCommandStatusType.Success)
                        {
                            if (status != DicomCommandStatusType.MissingAttribute && status != DicomCommandStatusType.AttributeOutOfRange)
                            {
                                AddRetry(scp, item, ae.Address);
                            }
                        }
                    }
                    catch (ClientAssociationException ce)
                    {
                        string message = string.Format("[Auto Update] Failed to establish association with server: {0}.  Adding {1} action to update retry queue.", ce.Reason,
                                                       AutoRetryProcessor.Actions[item.Action]);

                        UpdateProcessor.LogEvent(LogType.Error, MessageDirection.None, message, DicomCommandType.Undefined, null, processor.Scu, null);
                        AddRetry(scp, item, ae.Address);
                    }
                    catch (DicomException de)
                    {
                        string message = string.Format("[Auto Update] Error: {0}. Adding {1} action to update retry queue.", de.Message, AutoRetryProcessor.Actions[item.Action]);

                        UpdateProcessor.LogEvent(LogType.Error, MessageDirection.Input, message, DicomCommandType.Undefined, null, processor.Scu, null);
                        AddRetry(scp, item, ae.Address);
                    }
                    catch (Exception e)
                    {
                        string message = "[Auto Update] " + e.Message;

                        Logger.Global.Log(string.Empty, string.Empty, -1, string.Empty, string.Empty, -1, DicomCommandType.Undefined,
                                          DateTime.Now, LogType.Error, MessageDirection.None, message, null, null);
                    }
                    finally
                    {
                    }
                }
            }
        }
示例#5
0
        public WebAddin()
        {
            _status = DicomCommandStatusType.Success;

            this.AfterConnect          += new AfterConnectDelegate(WebAddin_AfterConnect);
            this.AfterAssociateRequest += new AfterAssociateRequestDelegate(WebAddin_AfterAssociateRequest);
        }
示例#6
0
        public DicomCommandStatusType SendUpdate(DicomScp scp, DicomDataSet ds, int action)
        {
            DicomCommandStatusType status = DicomCommandStatusType.Reserved4;

            status = _Scu.SendUpdate(scp, ds, action, PatientUpdaterConstants.UID.PatientUpdateInstance);
            return(status);
        }
示例#7
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);
                }
            }
        }
示例#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);
                    }
                }
            }
        }
示例#9
0
        private void DoStoreRequest( )
        {
            DicomCommandStatusType status = DicomCommandStatusType.ProcessingFailure;
            string       msg = "Error saving dataset received from: " + AETitle;
            DicomElement element;

            if (!IsActionSupported())
            {
                string name = GetUIDName();

                server.mf.Log("C-STORE-REQUEST", "Abstract syntax (" + name + ") not supported by association");
                client.SendCStoreResponse(_PresentationID, _MessageID, _Class, _Instance,
                                          DicomCommandStatusType.ClassNotSupported);
                return;
            }

            element = ds.FindFirstElement(null, DemoDicomTags.SOPInstanceUID, true);
            if (element != null)
            {
                string       value = ds.GetConvertValue(element);
                string       file;
                InsertReturn ret;

                file = server.ImageDir + value + ".dcm";
                ret  = server.mf.DicomData.Insert(ds, file);
                switch (ret)
                {
                case InsertReturn.Success:
                    DicomExceptionCode dret = SaveDataSet(file);
                    if (dret == DicomExceptionCode.Success)
                    {
                        status = DicomCommandStatusType.Success;
                    }
                    else
                    {
                        msg = "Error saving dicom file: " + dret.ToString();
                    }
                    server.mf.Log("C-STORE-REQUEST", "New file imported: " + file);
                    break;

                case InsertReturn.Exists:
                    msg = "File (" + file + ") not imported. Record already exists in database";
                    break;

                case InsertReturn.Error:
                    msg = "Error importing file: " + file;
                    break;
                }
            }

            if (status != DicomCommandStatusType.Success)
            {
                server.mf.Log("C-STORE-REQUEST", msg);
            }

            client.SendCStoreResponse(_PresentationID, _MessageID, _Class, _Instance, status);
            server.mf.Log("C-STORE-RESPONSE", "Response sent to " + AETitle);
        }
 public void SendNActionResponse
 (
     DicomCommandStatusType status,
     DicomDataSet responseDataset,
     string descriptionMessage
 )
 {
     Status             = status;
     DescriptionMessage = descriptionMessage;
 }
示例#11
0
        public void SendCFindResponse(DicomCommandStatusType status, DicomDataSet responseDataset, string descriptionMessage)
        {
            Status        = status;
            StatusMessage = descriptionMessage;

            if (null != responseDataset)
            {
                ResponseDS.Add(responseDataset);
            }
        }
示例#12
0
文件: Base.cs 项目: sakpung/webstudy
        public void InvokeStatusEvent(StatusType sType, DicomCommandStatusType status)
        {
            StatusEventArgs se = new StatusEventArgs();

            se._Error  = (status == DicomCommandStatusType.Success) ? DicomExceptionCode.Success : DicomExceptionCode.NetFailure;
            se._Status = status;
            se._Type   = sType;

            OnStatus(se);
        }
示例#13
0
        public DicomCommandStatusType SendNActionRequest <TQuery>(DicomScp Scp, TQuery Query, int action, string instance)
        {
            DicomDataSet ds = null;

            if (Scp == null)
            {
                throw new ArgumentNullException("Scp");
            }

            if (Query == null)
            {
                throw new ArgumentNullException("Query");
            }

            _ErrorMessage = string.Empty;
            try
            {
                _CurrentInstance = GetFindAttribute(Query);
                if (_CurrentInstance == null)
                {
                    throw new InvalidOperationException();
                }

                ds = GetDataset(Query, null);
                Connect(Scp);
                if (parameters.Result == null)
                {
                    SendNAction(ds, action, instance);
                }
                else
                {
                    throw new ClientAssociationException(parameters.Reason);
                }
            }
            catch (Exception e)
            {
                _ErrorMessage = e.Message;
                _Status       = DicomCommandStatusType.Failure;
            }
            finally
            {
                if (IsConnected())
                {
                    Close();
                }
                if (ds != null)
                {
                    ds.Dispose();
                    ds = null;
                }
            }

            return(_Status);
        }
示例#14
0
        public void InvokeStatusEvent(StatusType sType, DicomExceptionCode error, int completed, int remaining,
                                      DicomCommandStatusType status)
        {
            StatusEventArgs se = new StatusEventArgs();

            se._Type            = sType;
            se._Error           = error;
            se._NumberCompleted = completed;
            se._NumberRemaining = remaining;
            se._Status          = status;
            OnStatus(se);
        }
示例#15
0
文件: Base.cs 项目: sakpung/webstudy
        public void InvokeStatusEvent(StatusType sType, DicomCommandStatusType status, byte presentationID, int messageID, string affectedClass)
        {
            StatusEventArgs se = new StatusEventArgs();

            se._Error          = (status == DicomCommandStatusType.Success) ? DicomExceptionCode.Success : DicomExceptionCode.NetFailure;
            se._Status         = status;
            se._Type           = sType;
            se._PresentationID = presentationID;
            se._MessageID      = messageID;
            se._AffectedClass  = affectedClass;

            OnStatus(se);
        }
示例#16
0
 protected override void OnReceiveCEchoResponse(byte presentationID, int messageID, string affectedClass,
                                                DicomCommandStatusType status)
 {
     try
     {
         var se = new StatusEventArgs();
         InvokeStatusEvent(StatusType.ReceiveCEchoResponse, status, presentationID, messageID, affectedClass);
         Continue = true;
         Event.Set();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#17
0
        public static DicomCommandStatusType Insert(DateTime receive, ServerInfo info, string AETitle, DicomDataSet dataset)
        {
            string sop = dataset.GetValue <string>(DicomTag.SOPInstanceUID, string.Empty);
            DicomCommandStatusType status = DicomCommandStatusType.Success;

            if (!string.IsNullOrEmpty(sop))
            {
                //string filename = info.ImageDirectory + sop + ".dcm";
                string pid            = string.Empty;
                string studyInstance  = string.Empty;
                string seriesInstance = string.Empty;
                string sopInstance    = string.Empty;

                pid            = AddPatient(info.ConnectionString, AETitle, dataset);
                studyInstance  = AddStudy(receive, pid, info.ConnectionString, AETitle, dataset);
                seriesInstance = AddSeries(receive, studyInstance, info.ConnectionString, AETitle, dataset);
                status         = AddImage(receive, sop, studyInstance, seriesInstance, info.ConnectionString, AETitle, dataset, info.ImageDirectory + pid + @"\");
                if (status == DicomCommandStatusType.Failure)
                {
                    // remove patient, study, series, image information added to database
                    if (_newImage)
                    {
                        DeleteImage(sop, info.ConnectionString);
                    }

                    if (_newSeries)
                    {
                        DeleteSeries(seriesInstance, info.ConnectionString);
                    }

                    if (_newStudy)
                    {
                        DeleteStudy(studyInstance, info.ConnectionString);
                    }

                    if (_newPatient)
                    {
                        DeletePatient(pid, info.ConnectionString);
                    }
                }
            }
            else
            {
                throw new ArgumentException("Missing dicom tag", "SOP Instance UID");
            }

            return(status);
        }
        public static DicomCommandStatusType Insert(DateTime receive, string ConnectionString, string ImageDirectory, string AETitle, DicomDataSet dataset)
        {
            string sop = dataset.GetValue <string>(DicomTag.SOPInstanceUID, string.Empty);
            DicomCommandStatusType status = DicomCommandStatusType.Success;

            if (!string.IsNullOrEmpty(sop))
            {
                //string filename = info.ImageDirectory + sop + ".dcm";
                string pid            = string.Empty;
                string studyInstance  = string.Empty;
                string seriesInstance = string.Empty;
                string sopInstance    = string.Empty;

                pid            = AddPatient(ConnectionString, AETitle, dataset);
                studyInstance  = AddStudy(receive, pid, ConnectionString, AETitle, dataset);
                seriesInstance = AddSeries(receive, studyInstance, ConnectionString, AETitle, dataset);
                status         = AddImage(receive, sop, studyInstance, seriesInstance, ConnectionString, AETitle, dataset, ImageDirectory + pid + @"\");
            }

            return(status);
        }
示例#19
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);
                    }
                }
            }
        }
示例#20
0
        private bool LoadDicomFile(string file)
        {
            bool ret = true;

            try
            {
                using (DicomDataSet ds = new DicomDataSet())
                {
                    ds.Load(file, DicomDataSetLoadFlags.None);
                    DicomCommandStatusType status = DB.Insert(DateTime.Now, Module.ServerInfo, "TEST_AE", ds);
                    if (status != DicomCommandStatusType.Success)
                    {
                        ret = false;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ret = false;
            }
            return(ret);
        }
示例#21
0
        internal DicomCommandStatusType DoCStores(DicomClient Client, byte PresentationId, int MessageId, string AffectedClass, DicomCommandPriorityType Priority, DicomDataSet Request)
        {
            if (Request == null)
            {
                return(DicomCommandStatusType.InvalidArgumentValue);
            }

            try
            {
                string level = Request.GetValue <string> (DicomTag.QueryRetrieveLevel, string.Empty);
                DicomCommandStatusType status = Module.GetAttributeStatus(level, AffectedClass, Request);

                if (status != DicomCommandStatusType.Success)
                {
                    return(status);
                }

                switch (level.ToUpper( ))
                {
                case "PATIENT":
                case "STUDY":
                case "SERIES":
                case "IMAGE":
                    status = DB.MoveImages(this, level, AffectedClass, Module.ConnectionString, Request);
                    break;

                default:
                    return(DicomCommandStatusType.InvalidAttributeValue);
                }
                return(status);
            }
            catch
            {
                return(DicomCommandStatusType.ProcessingFailure);
            }
        }
示例#22
0
        public override void OnSendCMoveResponse(DicomClient Client, byte presentationID, int messageID, string affectedClass,
                                                 DicomCommandStatusType status, int remaining, int completed, int failed,
                                                 int warning, DicomDataSet dataset)
        {
            if (!Module.Options.EnableAutoCopy)
            {
                return;
            }

            //
            // Only do auto copy if the move command was successfull
            //
            if (status == DicomCommandStatusType.Success)
            {
                string key = Client.HostAddress + Client.HostPort.ToString();

                if (AutoCopyEngine.MoveRequests.ContainsKey(key))
                {
                    string ae = AutoCopyEngine.MoveRequests[key];

                    AutoCopyEngine.QueueDatasets(ae);
                }
            }
        }
示例#23
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);
                }
            }
        }
示例#24
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);
                }
            }
        }
示例#25
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);
                }
            }
        }
示例#26
0
 public override void OnBeforeSendCGetResponse(DicomClient Client, byte presentationID, int messageID, string affectedClass, DicomCommandStatusType status, int remaining, int completed, int failed, int warning, DicomDataSet dataset)
 {
     // View or change parameters
     base.OnBeforeSendCGetResponse(Client, presentationID, messageID, affectedClass, status, remaining, completed, failed, warning, dataset);
 }
示例#27
0
 public override void OnBeforeSendCFindResponse(DicomClient Client, byte presentationID, int messageID, string affectedClass, DicomCommandStatusType status, DicomDataSet dataset)
 {
     // View or change parameters
     base.OnBeforeSendCFindResponse(Client, presentationID, messageID, affectedClass, status, dataset);
 }
示例#28
0
 public override void OnBeforeSendNDeleteResponse(DicomClient Client, byte presentationID, int messageID, string affectedClass, string instance, DicomCommandStatusType status)
 {
     // View or change parameters
     base.OnBeforeSendNDeleteResponse(Client, presentationID, messageID, affectedClass, instance, status);
 }
示例#29
0
        public void InternalRunThread(DicomScp scp, IForwardDataAccessAgent forwardAgent)
        {
            lock (forwardLock)
            {
                if (_serviceShuttingDown)
                {
                    return;
                }

                ForwardInstance[] instances;
                try
                {
                    instances = forwardAgent.GetForwardList();
                }
                catch (Exception ex)
                {
                    Logger.Global.SystemMessage(LogType.Error, ex.ToString(), _ServerAE);
                    // throw;
                    instances = new ForwardInstance[0];
                }

                string message = string.Format("[Forwarder] {0} {1} found to forward", instances.Length, instances.Length == 1 ? "dataset" : "datasets");

                Logger.Global.SystemMessage(LogType.Debug, message, _ServerAE);
                if (instances.Length > 0 && _Options.Verify)
                {
                    message = string.Format("[Forwarder] {0} {1} will be verified after forwarding", instances.Length, instances.Length == 1 ? "instance" : "instances");
                    Logger.Global.SystemMessage(LogType.Warning, message, _ServerAE);
                }
                foreach (ForwardInstance instance in instances)
                {
#if LEADTOOLS_V18_OR_LATER
                    if (_cancelForward)
                    {
                        _cancelForward = false;
                        Logger.Global.SystemMessage(LogType.Information, string.Format("Cancelling Forward Process"), _ServerAE);
                        break;
                    }

                    if (_serviceShuttingDown)
                    {
                        break;
                    }
#endif // #if LEADTOOLS_V18_OR_LATER

                    try
                    {
                        if (!File.Exists(instance.ReferencedFile))
                        {
                            message = string.Format("[Forwarder] Referenced file doesn't exist.  Instance ({0}) will be removed from forwarding queue. [{1}]", instance.SOPInstanceUID, instance.ReferencedFile);
                            Logger.Global.SystemMessage(LogType.Warning, message, _ServerAE);
                            forwardAgent.SetInstanceForwarded(instance.SOPInstanceUID, DateTime.Now, null);
                            continue;
                        }

                        // SendInstance can fail because DicomEngine may be locked
                        DicomCommandStatusType status = DicomCommandStatusType.Success;
                        try
                        {
                            status = SendInstance(scp, instance);
                        }
                        catch (Exception)
                        {
                            // Console.WriteLine(ex.Message);
                            throw;
                        }

                        if (status == DicomCommandStatusType.Success || status == DicomCommandStatusType.DuplicateInstance)
                        {
                            DateTime?expires     = null;
                            DateTime forwardDate = DateTime.Now;

                            if (_Options.ImageHold != null && _Options.ImageHold != 0)
                            {
                                switch (_Options.HoldInterval)
                                {
                                case HoldInterval.Days:
                                    expires = forwardDate.AddDays(_Options.ImageHold.Value);
                                    break;

                                case HoldInterval.Months:
                                    expires = forwardDate.AddMonths(_Options.ImageHold.Value);
                                    break;

                                default:
                                    expires = forwardDate.AddYears(_Options.ImageHold.Value);
                                    break;
                                }
                            }
                            if (!_Options.Verify || VerifyInstance(scp, instance.SOPInstanceUID) == DicomCommandStatusType.Success)
                            {
                                if (_Options.Verify)
                                {
                                    message = string.Format("[Forwarder] SOP instance successfully verified: {0}", instance.SOPInstanceUID);
                                    Logger.Global.SystemMessage(LogType.Debug, message, _ServerAE);
                                }
                                forwardAgent.SetInstanceForwarded(instance.SOPInstanceUID, forwardDate, expires);
                            }
                            else
                            {
                                message = string.Format("[Forwarder] Failed to verify SOP instance: {0}. Instance not marked as forwarded.", instance.SOPInstanceUID);
                                Logger.Global.SystemMessage(LogType.Error, message, _ServerAE);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Global.SystemMessage(LogType.Error, "[Forwarder] " + e.Message, _ServerAE);
                    }
                }
            }
        }
示例#30
0
        protected override void OnReceiveCFindResponse(byte presentationID, int messageID, string affectedClass, DicomCommandStatusType status, DicomDataSet dataSet)
        {
            string message = string.Format(ForwardProcess.CFIND_RESPONSE_RECEIVED, messageID, presentationID, affectedClass, status);

            ForwardProcess.LogEvent(LogType.Information, MessageDirection.Input, message, DicomCommandType.CFind, dataSet, this, null);
            base.OnReceiveCFindResponse(presentationID, messageID, affectedClass, status, dataSet);
        }