示例#1
0
        public static Patient FindPatient(Control owner, QueryRetrieveScu find, DicomScp scp, string pid)
        {
            PatientRootQueryPatient query = new PatientRootQueryPatient();
            Patient        patient        = null;
            ProgressDialog progress       = new ProgressDialog();

            query.PatientQuery.PatientId = pid;
            Thread thread = new Thread(() =>
            {
                try
                {
                    find.Find <PatientRootQueryPatient, Patient>(scp, query, (p, ds) => patient = p);
                }
                catch (Exception e)
                {
                    ApplicationUtils.ShowException(owner, e);
                }
            });

            progress.ActionThread = thread;
            progress.Title        = "Searching For Patient";
            progress.ProgressInfo = "Looking for patient to merge with.";
            progress.ShowDialog(owner);
            return(patient);
        }
示例#2
0
        public T[] DoFind(DicomDataSet query)
        {
            using (QueryRetrieveScu find = CreateQueryRetrieveClient())
            {
                __CurrentFind = find;

                RegisterEvents(find);

                try
                {
                    DicomScp scp = new DicomScp( );

                    scp.AETitle     = ScpInfo.AETitle;
                    scp.Port        = ScpInfo.Port;
                    scp.PeerAddress = IPAddress.Parse(ScpInfo.Address);

                    Matches = new List <T>();

                    find.EnableDebugLog = false;

                    find.Find(scp, query);

                    return(Matches.ToArray( ));
                }
                catch (Exception exception)
                {
                    System.Diagnostics.Debug.Assert(false, exception.Message);

                    throw;
                }
                finally
                {
                    __CurrentFind = null;

                    UnregisterEvents(find);
                }
            }
        }
示例#3
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);
                }
            }
        }
示例#4
0
        public PatientData[] DoFindPatient(PatientsQueryOptions query)
        {
            using (QueryRetrieveScu find = CreateQueryRetrieveClient())
            {
                __CurrentFind = find;

                RegisterEvents(find);

                try
                {
                    DicomScp scp = new DicomScp( );

                    scp.AETitle     = ScpInfo.AETitle;
                    scp.Port        = ScpInfo.Port;
                    scp.PeerAddress = IPAddress.Parse(ScpInfo.Address);

                    Patients = new List <PatientData>();

                    find.EnableDebugLog = false;

                    PatientRootQueryPatient patientRootQuery = new PatientRootQueryPatient( );

                    if (query != null)
                    {
                        if (!string.IsNullOrEmpty(query.BirthDate))
                        {
#if LEADTOOLS_V19_OR_LATER
                            DateRange dr = new DateRange();
                            DateTime  dt = DateTime.Parse(query.BirthDate);
                            dr.StartDate = dt;
                            dr.EndDate   = dt;
                            patientRootQuery.PatientQuery.PatientBirthDate = dr;//DateTime.Parse ( query.BirthDate ) ;
#else
                            patientRootQuery.PatientQuery.PatientBirthDate = DateTime.Parse(query.BirthDate);
#endif
                        }

                        patientRootQuery.PatientQuery.PatientId       = query.PatientID;
                        patientRootQuery.PatientQuery.PatientName     = query.PatientName;
                        patientRootQuery.PatientQuery.PatientSex      = query.Sex;
                        patientRootQuery.PatientQuery.PatientComments = query.Comments;
                        // patientRootQuery.PatientQuery.EthnicGroup = query.EthnicGroup;
                    }

                    find.Find <PatientRootQueryPatient, PatientQuery> (scp, patientRootQuery, PatientMatchDelegate);

                    return(Patients.ToArray( ));
                }
                catch (Exception exception)
                {
                    System.Diagnostics.Debug.Assert(false, exception.Message);

                    throw;
                }
                finally
                {
                    __CurrentFind = null;

                    UnregisterEvents(find);
                }
            }
        }