Exemple #1
0
        public bool UpdatePatient(string authenticationCookie, PatientInfo_Json info, DataContracts.ExtraOptions extraOptions)
        {
            string userName;


            try
            {
                userName = ServiceUtils.Authorize(authenticationCookie, PermissionsTable.Instance.CanQuery);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            QueryOptions queryOptions = new QueryOptions();

            queryOptions.PatientsOptions           = new PatientsQueryOptions();
            queryOptions.PatientsOptions.PatientID = info.PatientId;

            PatientData[] patientData = _queryAddin.FindPatients(userName, queryOptions);
            if (patientData == null || patientData.Length == 0)
            {
                throw new Exception("PatientID does not exist: " + info.PatientId);
                // return false;
            }

            using (DicomDataSet ds = new DicomDataSet())
            {
                ChangePatient c       = new ChangePatient();
                const string  notUsed = "NotUsed";

                c.OriginalPatientId = info.PatientId;
                c.PatientId         = info.PatientId;
                c.Name = new PersonName(info.Name);
                c.Sex  = info.Sex;
#if LEADTOOLS_V19_OR_LATER
                c.PatientComments = info.Comments;
                c.EthnicGroup     = info.EthnicGroup;
#endif

                if (info.BirthDate != null)
                {
                    c.Birthdate = DateTime.Parse(info.BirthDate);
                }

                c.Description   = notUsed;
                c.Reason        = notUsed;
                c.Operator      = notUsed;
                c.Station       = notUsed;
                c.Date          = DateTime.Now;
                c.Time          = c.Date;
                c.TransactionID = notUsed;

                ds.Set(c);

                _storeAddin.UpdatePatient(ds);
            }

            return(true);
        }
Exemple #2
0
        public string MyPatID   = string.Empty; //用于存PATID
        /// <summary>
        /// 切换病人
        /// edit by ywk 2012年5月29日 13:22:03
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void linkchangePat_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            ChangePatient chageP = new ChangePatient(MethodSet.App, MethodSet.App.User);

            chageP.StartPosition = FormStartPosition.CenterParent;//弹出窗体在父窗体中间
            InputDate            = dateEdit.DateTime.Date.ToString("yyyy-MM-dd");
            if (chageP.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                IsChagedPat = true;
                NoOfInpat   = chageP.NOOfINPAT;
                //MessageBox.Show(chageP.NOOfINPAT);
                NursingRecord_Load(null, null);
                dateEdit_DateTimeChanged(null, null);
            }
        }
        private void ChangePatient()
        {
            //
            // If the patient ID has changed then we need to see if a patient with that id already exists
            //
            if (_Patient.Id != textBoxId.Text)
            {
                PatientRootQueryPatient query    = new PatientRootQueryPatient();
                List <Patient>          patients = new List <Patient>();

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

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

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

            bool isError = VerifyPatientSettings();

            if (isError)
            {
                return;
            }

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

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

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

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

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

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

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

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

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

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

                    TaskDialogHelper.ShowMessageBox(this, "Change Patient Error", "The patient was not changed.", message,
                                                    string.Empty, TaskDialogStandardButtons.Close, TaskDialogStandardIcon.Information,
                                                    null);
                }
            }
        }
        private 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);
        }