public PatientMain(string PtID)
        {
            InitializeComponent();
            pt1 = new patient(PtID, false);
            this.dgvExams.Font = new Font(dgvExams.Font.Name, 12);

            if (pt1.ptExist)
            {
                if (uckyFunctions.canEdit("patient", "pt_id", "LIKE", "'" + PtID + "'"))
                {
                    pCanEdit = true;
                    uckyFunctions.updateLockTimeIP("patient", "pt_id", "LIKE", "'" + pt1.ptID + "'");
                    btEditPtData.Visible = true;
                    tbPtInfo.ReadOnly = false;
                    btConfirm.Visible = true;
                }
                else
                {
                    MessageBox.Show(Properties.Resources.ReadOnlyMode, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    pCanEdit = false;
                    btEditPtData.Visible = false;
                    tbPtInfo.ReadOnly = true;
                    btConfirm.Visible = false;
                }

                readPtData();
                readExams();
                //以下、タイマー処理
                timer.Interval = 30000;  //単位はmsec。
                timer.Tick += new EventHandler(timer_Tick);
                timer.Start();
            }
            else
            { MessageBox.Show(Properties.Resources.NoPatient, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
        public EditPt(string PtID, Boolean newPt, Boolean ID_editable)
        {
            InitializeComponent();

            pt1 = new patient(PtID, newPt);
            pNewPt = newPt;
            if (newPt)
            { this.tbPtID.Text = pt1.ptID; }
            else
            {
                if (patient.numberOfPatients(PtID) == 1)
                { readPtData(); }
                else
                { MessageBox.Show(Properties.Resources.NoPatient, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
            }

            if (ID_editable)
            { tbPtID.Enabled = true; }
            else
            { tbPtID.Enabled = false; }
        }
        private void ptLoad()
        {
            if (this.tbPtId.Text.Length == 0)
            {
                MessageBox.Show(Properties.Resources.NoID, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            switch (patient.numberOfPatients(this.tbPtId.Text))
            {
                case 0:
                    if (Settings.ptInfoPlugin != "")
                    {
                        #region Get patient's information with plug-in
                        string command = Settings.ptInfoPlugin;

                        ProcessStartInfo psInfo = new ProcessStartInfo();

                        psInfo.FileName = command;
                        psInfo.Arguments = tbPtId.Text;
                        psInfo.CreateNoWindow = true; // Do not open console window
                        psInfo.UseShellExecute = false; // Do not use shell

                        psInfo.RedirectStandardOutput = true;

                        Process p = Process.Start(psInfo);
                        string output = p.StandardOutput.ReadToEnd();

                        output = output.Replace("\r\r\n", "\n"); // Replace new line code
                        #endregion

                        if (MessageBox.Show(output, "Information", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
                        {
                            #region Make new patient data
                            pt1 = new patient(this.tbPtId.Text, true);
                            string ptName = file_control.readItemSettingFromText(output, "Patient Name:");
                            if (ptName != "")
                            {
                                pt1.ptName = file_control.readItemSettingFromText(output, "Patient Name:");
                                this.Pt_name.Text = pt1.ptName;

                                #region Patient's birthdate
                                string ptBirthDay = file_control.readItemSettingFromText(output, "Birth date:");

                                if (ptBirthDay != "")
                                { pt1.ptBirthday = DateTime.Parse(ptBirthDay); }
                                else
                                { pt1.ptBirthday = DateTime.Now; }

                                this.Pt_birthday.Text = pt1.ptBirthday.ToShortDateString();
                                this.Pt_age.Text = pt1.getPtAge().ToString();
                                #endregion

                                #region Gender
                                string ptGender = file_control.readItemSettingFromText(output, "Gender:");
                                switch (ptGender)
                                {
                                    case "0":
                                        pt1.ptGender = patient.gender.female;
                                        this.Pt_gender.Text = Properties.Resources.Female;
                                        break;
                                    case "1":
                                        pt1.ptGender = patient.gender.male;
                                        this.Pt_gender.Text = Properties.Resources.Male;
                                        break;
                                    default:
                                        pt1.ptGender = patient.gender.male;
                                        this.Pt_gender.Text = Properties.Resources.Male;
                                        break;
                                }
                                #endregion

                                #region Save patient's information
                                uckyFunctions.functionResult save_res = pt1.writePtAllData(pt1);
                                if (save_res == uckyFunctions.functionResult.success)
                                { break; }
                                else if (save_res == uckyFunctions.functionResult.failed)
                                { MessageBox.Show(Properties.Resources.DataBaseError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                                else if (save_res == uckyFunctions.functionResult.connectionError)
                                { MessageBox.Show(Properties.Resources.ConnectFailed, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                                #endregion
                            }
                            else if (ptName == "")
                            { MessageBox.Show(Properties.Resources.PluginCouldntGetPtName, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
                            #endregion
                        }
                        else
                        { MessageBox.Show(Properties.Resources.ProcedureCancelled); }
                    }

                    // If plug-in procedure was canseled, or plug-in not exist, codes below will be run
                    MessageBox.Show(Properties.Resources.NoPatient, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    EditPt ep = new EditPt(this.tbPtId.Text, true, false);
                    ep.ShowDialog(this);
                    if (patient.numberOfPatients(this.tbPtId.Text) == 1)
                        ptLoad();
                    break;
                case 1:
                    pt1 = new patient(this.tbPtId.Text, false);
                    pt1.readPtData(pt1.ptID);
                    this.Pt_name.Text = pt1.ptName;
                    if (pt1.ptGender == patient.gender.female)
                    { this.Pt_gender.Text = Properties.Resources.Female; }
                    else
                    { this.Pt_gender.Text = Properties.Resources.Male; }
                    this.Pt_birthday.Text = pt1.ptBirthday.ToShortDateString();
                    this.Pt_age.Text = pt1.getPtAge().ToString();
                    break;
                default:
                    MessageBox.Show(Properties.Resources.DataBaseError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
            }
        }
 private void btEditPtData_Click(object sender, EventArgs e)
 {
     EditPt ep = new EditPt(Pt_ID.Text, false, true);
     ep.ShowDialog(this);
     //Show new data.
     pt1 = new patient(Pt_ID.Text, false);
     readPtData();
 }
Beispiel #5
0
 public void writePtInfo(patient pt_source)
 {
     string SQL = "UPDATE patient SET pt_memo=:p0 WHERE pt_id=:p1;";
     if (uckyFunctions.ExeNonQuery(SQL, pt_source.ptInfo, pt_source.ptID) == uckyFunctions.functionResult.success)
     { MessageBox.Show(Properties.Resources.UpdateDone, "Successfully updated", MessageBoxButtons.OK, MessageBoxIcon.Information); }
     else
     { MessageBox.Show(Properties.Resources.UpdateFailed, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
 }
Beispiel #6
0
        public uckyFunctions.functionResult writePtAllData(patient pt_source)
        {
            string SQL;
            short gender;
            if (pt_source.ptGender == patient.gender.female)
            { gender = 0; }
            else
            { gender = 1; }

            if (this.newPt == true)
            {
                SQL = "INSERT INTO patient(pt_ID,pt_name,gender,birthday)"
                    + "VALUES(:p0, :p1, :p2, :p3);";

                return uckyFunctions.ExeNonQuery(SQL, pt_source.ptID, pt_source.ptName, gender.ToString(), pt_source.ptBirthday.ToString());
            }
            else
            {
                SQL = "UPDATE patient SET pt_name=:p0, gender=:p1, birthday=:p2, "
                     + "pt_memo=:p3 WHERE pt_id=:p4;";

                return uckyFunctions.ExeNonQuery(SQL, pt_source.ptName, gender.ToString(), pt_source.ptBirthday.ToString(),
                    pt_source.ptInfo, pt_source.ptID);
            }
        }
Beispiel #7
0
        public uckyFunctions.functionResult writePtAllData(patient pt_source)
        {
            string SQL;
            short  gender;

            if (pt_source.ptGender == patient.gender.female)
            {
                gender = 0;
            }
            else
            {
                gender = 1;
            }

            if (newPt == true)
            {
                try
                {
                    using (var conn = new NpgsqlConnection(Settings.retConnStr()))
                    {
                        conn.Open();

                        using (var cmd = new NpgsqlCommand())
                        {
                            cmd.Connection  = conn;
                            cmd.CommandText = "INSERT INTO patient(pt_id, pt_name, gender, birthday) VALUES(@p_id, @p_name, @p_gender, @p_birthday);";
                            cmd.Parameters.AddWithValue("p_id", pt_source.ptID);
                            cmd.Parameters.AddWithValue("p_name", pt_source.ptName);
                            cmd.Parameters.AddWithValue("p_gender", gender);
                            cmd.Parameters.AddWithValue("p_birthday", pt_source.ptBirthday);

                            cmd.ExecuteNonQuery();
                        }
                        conn.Close();
                    }
                }
                catch (NpgsqlException ex)
                {
                    MessageBox.Show("[Npgsql]" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(uckyFunctions.functionResult.failed);
                }
                catch (InvalidOperationException ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(uckyFunctions.functionResult.failed);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(uckyFunctions.functionResult.failed);
                }

                return(uckyFunctions.functionResult.success);
            }
            else
            {
                SQL = "UPDATE patient SET pt_name=:p0, gender=:p1, birthday=:p2, "
                      + "pt_memo=:p3 WHERE pt_id=:p4;";

                return(uckyFunctions.ExeNonQuery(SQL, pt_source.ptName, gender.ToString(), pt_source.ptBirthday.ToString(),
                                                 pt_source.ptInfo, pt_source.ptID));
            }
        }
        private void ptView()
        {
            if (string.IsNullOrWhiteSpace(tbPtID.Text))
            {
                MessageBox.Show(Properties.Resources.NoID, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            patient pt1 = new patient(this.tbPtID.Text, false);
            if (pt1.ptExist)
            {
                PatientMain pm = new PatientMain(this.tbPtID.Text);
                pm.ShowDialog(this);
            }
            else
            { MessageBox.Show(Properties.Resources.OpenFormFailed, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }