// Open selected patient profile from the search result
        private void Search_Result_dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            String temp;
            int ID;
            if (e.ColumnIndex == 0)
            {
                temp = Search_Result_dataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
                ID = Int32.Parse(temp);

                Patient_Profile_Viewer PatientProfile = new Patient_Profile_Viewer(ID);
                PatientProfile.Show();
            }
        }
Beispiel #2
0
        // View Patient Profile
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            String temp;
            int    ID;

            if (e.ColumnIndex == 0)
            {
                temp = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
                ID   = Int32.Parse(temp);

                Patient_Profile_Viewer PatientProfile = new Patient_Profile_Viewer(ID);
                PatientProfile.Show();
            }
        }
        // View Specific Patient Profile
        private void View_Patient_Button_Click(object sender, EventArgs e)
        {
            if (!ValidateData.ValidateIDIsExist(IDtoview_textBox.Text))
            {
                Error.SetError(IDtoview_textBox, "Please Enter Valid ID");
                return;
            }
            Error.Clear();

            int ID = Int32.Parse(IDtoview_textBox.Text);
            Patient_Profile_Viewer ViewProfile = new Patient_Profile_Viewer(ID);

            ViewProfile.Show();

            IDtoview_textBox.Text = "";
        }
Beispiel #4
0
        // Search for specific person
        private void Search_for_Patient_Click(object sender, EventArgs e)
        {
            String Option    = Inv_Search_options_comboBox.Text;
            String SearchKey = indv_Search_key_textBox.Text;
            int    ID;

            if (!ValidateData.ValidateComboBoxItem(Option, new List <String> {
                "ID", "Home Number", "Mobile Number"
            }))
            {
                Error.SetError(Inv_Search_options_comboBox, "Please enter validate search option");
                return;
            }
            Error.Clear();

            if (!ValidateData.ValidateIntSearchKey(SearchKey))
            {
                Error.SetError(indv_Search_key_textBox, "Please enter validate search key");
                return;
            }
            Error.Clear();

            if (Option == "ID")
            {
                ID = Int32.Parse(SearchKey);
            }
            else
            {
                if (CheckIfExist(Option, SearchKey) == false)
                {
                    return;
                }

                ID = GetID(Option, SearchKey);
            }

            Patient_Profile_Viewer ViewPatient = new Patient_Profile_Viewer(ID);

            if (ViewPatient.CheckBoxIfExist())
            {
                ViewPatient.Show();
            }

            Inv_Search_options_comboBox.Text = "";
            indv_Search_key_textBox.Text     = "";
        }
        // Search for specific person
        private void Search_for_Patient_Click(object sender, EventArgs e)
        {
            String Option = Inv_Search_options_comboBox.Text;
            String SearchKey = indv_Search_key_textBox.Text;
            int ID;

            if (!ValidateData.ValidateComboBoxItem(Option, new List<String> { "ID", "Home Number", "Mobile Number" }))
            {
                Error.SetError(Inv_Search_options_comboBox, "Please enter validate search option");
                return;
            }
            Error.Clear();
                
            if (!ValidateData.ValidateIntSearchKey(SearchKey))
            {
                Error.SetError(indv_Search_key_textBox, "Please enter validate search key");
                return;

            }
            Error.Clear();

            if (Option == "ID")
            {
                ID = Int32.Parse(SearchKey);
            }
            else
            {
                if (CheckIfExist(Option, SearchKey) == false)
                    return;

                ID = GetID(Option, SearchKey);
            }

            Patient_Profile_Viewer ViewPatient = new Patient_Profile_Viewer(ID);

            if(ViewPatient.CheckBoxIfExist())
               ViewPatient.Show();

            Inv_Search_options_comboBox.Text = "";
            indv_Search_key_textBox.Text = "";

        }
        // Main Function
        private void AddnewPatient_saveAndConfirm_button_Click(object sender, EventArgs e)
        {
            // re-validate
            if (!DataValidation())
                return;

            List<Control> ChangedControls = _dirtyTracker.GetListOfDirtyControls();
           
            Patient = DataUpdater.Patient_info.Where(i => i.Patient_ID == EPatient_ID).FirstOrDefault();

            

            #region Basic info 

            if (ChangedControls.Contains(Patient_ID_textBox))
            {
              ID = Int32.Parse(Patient_ID_textBox.Text);
              Patient.Patient_ID = ID;
            }

            if (ChangedControls.Contains(Age_textBox))
            {
                int Age;
                Age = Int32.Parse(Age_textBox.Text); 
                Patient.Age = Age;
            }
 
            if (ChangedControls.Contains(Sex_Combobox))
            {
                Patient.Sex = Sex_Combobox.Text;
            }


            if (ChangedControls.Contains(DateOfBirth_textBox))
            {
                DateTime BD = DateTime.Parse(DateOfBirth_textBox.Text);
                Patient.Birth_date = BD;
            }
           

            if (ChangedControls.Contains(Visit_date_textBox))
            {
                DateTime VD = DateTime.Parse(Visit_date_textBox.Text);
                Patient.Visit_date = VD;
            }
           

            if (ChangedControls.Contains(Patient_name_textBox))
            {
                Patient.Patient_name = Patient_name_textBox.Text;
            }

            if (ChangedControls.Contains(Homenum_textBox))
            {
                Patient.Home_number = Homenum_textBox.Text;
            }

            if (ChangedControls.Contains(Mobile_textBox))
            {
                Patient.Phone_number = Mobile_textBox.Text;
            }

            if (ChangedControls.Contains(Realative_Marriage_comboBox))
            {
                Patient.Relative_marriage = Realative_Marriage_comboBox.Text;
            }

            if (ChangedControls.Contains(Address_textBox))
            {
                Patient.Address = Address_textBox.Text;
            }

            if (ChangedControls.Contains(Chief_Complaint_textBox))
            {
                Patient.Cheif_complaint = Chief_Complaint_textBox.Text;
            }

            if (ChangedControls.Contains(Medical_alert_textBox))
            {
                Patient.Medical_alert = Medical_alert_textBox.Text;
            }

            if (Profile_Picture != null)
            {
                Patient.Patient_image = imageToByteArray(Profile_Picture) ;
            }

            if (AddnewXrayImagesIsPressed)
            {
                // Patinet's X-ray images
                ////////////////////////////////////////
                // Byte[] XrayImage;

                MemoryStream ms;
                int ix = 0;
                var Xcount = (from o in DataUpdater.X_ray_images select o).Count();
                int Xtemp = Xcount + 1;
                foreach (Bitmap img in Patient_Xray_images)
                {

                    var XrayimageObject = new X_ray_images();
                    ms = new MemoryStream();
                    img.Save(ms, img.RawFormat);
                    XrayimageObject.Patient_ID = ID;
                    XrayimageObject.Xray_image = ms.ToArray();
                    XrayimageObject.Image_name = XrayImagesNames[ix];
                    XrayimageObject.Xray_images_ID = Xtemp;
                    DataUpdater.X_ray_images.Add(XrayimageObject);
                    ix++;
                    Xtemp++;
                }
            }

            if (ChangedControls.Contains(DMF_D_textBox))
            {
                Patient.D_DMF = D;
            }

            if (ChangedControls.Contains(DMF_M_textbox))
            {
                Patient.M_DMF = M;
            }

            if (ChangedControls.Contains(DMF_F_textBox))
            {
                Patient.F_DMF = F;
            }

            if (ChangedControls.Contains(DMF_D_textBox) || ChangedControls.Contains(DMF_M_textbox) || ChangedControls.Contains(DMF_F_textBox))
            {
                Patient.DMF = DMF; 
            }

            if (ChangedControls.Contains(_dmf_d_textBox))
            {
                Patient.dd_dmf = d;
            }

            if (ChangedControls.Contains(_dmf_m_textBox))
            {
                Patient.mm_dmf = m;
            }

            if (ChangedControls.Contains(_dmf_f_textBox))
            {
                Patient.ff_dmf = f;
            }

            if (ChangedControls.Contains(_dmf_d_textBox) || ChangedControls.Contains(_dmf_m_textBox) || ChangedControls.Contains(_dmf_f_textBox))
            {
                Patient.C_dmf = _dmf;
            }

            if (ChangedControls.Contains(DEF_D_textBox))
            {
                Patient.D_DEF = _D;
            }

            if (ChangedControls.Contains(DEF_E_textBox))
            {
                Patient.E_DEF = E;
            }

            if (ChangedControls.Contains(DEF_F_textbox))
            {
                Patient.F_DEF = _F;
            }

            if (ChangedControls.Contains(DEF_D_textBox) || ChangedControls.Contains(DEF_E_textBox) || ChangedControls.Contains(DEF_F_textbox))
            {
                Patient.DEF = DEF;
            }

            #endregion
            ////////////////////////////////////////////////////////////////

            #region Diagnosis And Treatment Plans

            if (DiagnosisAndTPsIsChanged && DiagnosisAndTPsIsPressed)
            {
                int index = 0;
                var Query = from P in DataUpdater.Diagnoses.Where(P => P.Patient_ID == ID) select P;
                if (Updated_DiagnosisAndTPs_table.Count == EDiagnosisAndTPs_table.Count)
                {
                    // Update
                    foreach (var item in Query)
                    {
                        List<String> row = Updated_DiagnosisAndTPs_table[index];
                        item.Diagnose = row[0];
                        item.Treatment_Plan = row[1];
                        index++;
                    }
                }

                // increase
                if (Updated_DiagnosisAndTPs_table.Count > EDiagnosisAndTPs_table.Count)
                {
                    //update
                    foreach (var item in Query)
                    {
                        List<String> row = Updated_DiagnosisAndTPs_table[index];
                        item.Diagnose = row[0];
                        item.Treatment_Plan = row[1];
                        index++;
                    }

                    // create
                    var Dcount = (from o in DataUpdater.Diagnoses select o).Count();
                    int Dtemp = Dcount + 1;
                    for (int i = index; i < Updated_DiagnosisAndTPs_table.Count; i++)
                    {
                        List<String> row = Updated_DiagnosisAndTPs_table[i];
                        var DiagnosisObject = new Diagnosis();

                        DiagnosisObject.Patient_ID = ID;
                        DiagnosisObject.Diagnose_ID = Dtemp;
                        DiagnosisObject.Diagnose = row[0];
                        DiagnosisObject.Treatment_Plan = row[1];

                        DataUpdater.Diagnoses.Add(DiagnosisObject);
                        Dtemp++;
                    }
                }

                // decrease
                if (Updated_DiagnosisAndTPs_table.Count < EDiagnosisAndTPs_table.Count)
                {
                    // update
                    foreach (var item in Query)
                    {
                        
                        if (index < Updated_DiagnosisAndTPs_table.Count)
                        {
                            var checkItem = DataUpdater.Diagnoses.Create();
                            List<String> row = Updated_DiagnosisAndTPs_table[index];
                            checkItem.Diagnose = row[0];
                            checkItem.Treatment_Plan = row[2];

                            if (item.Diagnose == checkItem.Diagnose && item.Treatment_Plan == checkItem.Treatment_Plan)               
                            {
                                index++;
                                continue;
                            }
                            else 
                            {
                                item.Diagnose = row[0];
                                item.Treatment_Plan = row[1];
                            }
                        }
                        else
                        {
                            // delete
                            DataUpdater.Diagnoses.Remove(item);
                        }
                        index++;
                    }
                }
            }

            #endregion

            ////////////////////////////////////////////////////////////////
            #region Dates And Procedures
            if (DatesAndProceduresIsChanged && DatesAndProceduresIsPressed)
            {
                int index = 0;
                var Query = from P in DataUpdater.Dates.Where(P => P.Patient_ID == ID) select P;
                if (Updated_DatesAndProc_table.Count == EDatesAndProc_table.Count)
                {
                    foreach (var item in Query)
                    {
                        List<String> row = Updated_DatesAndProc_table[index];
                        item.Date1 = DateTime.Parse(row[0]);
                        item.Doctor_name = row[1];
                        item.Procedures = row[2];
                        item.Procedure_Comment = row[3];
                        if (row[4].Length != 0)
                            item.Medication = row[4];
                        item.Supervisor_signature = row[5];
                        index++;
                    }
                }

                if (Updated_DatesAndProc_table.Count > EDatesAndProc_table.Count)
                {
                    foreach (var item in Query)
                    {
                        List<String> row = Updated_DatesAndProc_table[index];
                        item.Date1 = DateTime.Parse(row[0]);
                        item.Doctor_name = row[1];
                        item.Procedures = row[2];
                        item.Procedure_Comment = row[3];
                        if (row[4].Length != 0)
                            item.Medication = row[4];
                        item.Supervisor_signature = row[5];
                        index++;
                    }


                    var Dcount = (from o in DataUpdater.Dates select o).Count();
                    int Dtemp = Dcount + 1;
                    for (int i = index; i < Updated_DatesAndProc_table.Count; i++)
                    {
                        List<String> row = Updated_DatesAndProc_table[i];
                        var DatesObject = new Date();

                        DatesObject.Patient_ID = ID;
                        DatesObject.Dates_ID = Dtemp;
                        DatesObject.Date1 = Convert.ToDateTime(row[0]);
                        DatesObject.Doctor_name = row[1];
                        DatesObject.Procedures = row[2];
                        DatesObject.Procedure_Comment = row[3];
                        if (row[4].Length != 0)
                            DatesObject.Medication = row[4];
                        DatesObject.Supervisor_signature = row[5];

                        DataUpdater.Dates.Add(DatesObject);
                        Dtemp++;
                    }
                }

                if (Updated_DatesAndProc_table.Count < EDatesAndProc_table.Count)
                {
                    // update
                    foreach (var item in Query)
                    {
                        if (index < Updated_DatesAndProc_table.Count)
                        {
                            var checkItem = DataUpdater.Dates.Create();
                            List<String> row = Updated_DatesAndProc_table[index];
                            checkItem.Date1 = DateTime.Parse(row[0]);
                            checkItem.Doctor_name = row[1];
                            checkItem.Procedures = row[2];
                            checkItem.Procedure_Comment = row[3];
                            if (row[4].Length != 0)
                                checkItem.Medication = row[4];
                            checkItem.Supervisor_signature = row[5];

                            if (item.Date1 == checkItem.Date1 && item.Doctor_name == checkItem.Doctor_name &&
                                item.Procedures == checkItem.Procedures && item.Procedure_Comment == checkItem.Procedure_Comment
                                && item.Medication == checkItem.Medication && item.Supervisor_signature == checkItem.Supervisor_signature)
                                
                            {
                                 index++;
                                 continue;
                            }
                            else
                            {
                                item.Date1 = DateTime.Parse(row[0]);
                                item.Doctor_name = row[1];
                                item.Procedures = row[2];
                                item.Procedure_Comment = row[3];
                                if (row[4].Length != 0)
                                    item.Medication = row[4];
                                item.Supervisor_signature = row[5];
                            }
                        }
                        else
                        {
                            // delete
                            DataUpdater.Dates.Remove(item);
                        }
                        index++;
                    }
                }
            }
            #endregion

            try
            {
                DataUpdater.SaveChanges();
            }
            catch (Exception ex)
            {
                Exception see = ex;
                MessageBox.Show("There was a problem while saving in the DBcontext\n" + ex.Message);
                return;
            }

            AddNewPatientSaveAndConfirmIsPressed = true;
            MessageBox.Show("The Patient was edited successfully");

            EditedPatient = new Patient_Profile_Viewer(Int32.Parse(Patient_ID_textBox.Text));
            this.Close();
            EditedPatient.Show();

        }
        // Edit form close event
        private void Edit_Patient_FormClosing(object sender, FormClosingEventArgs e)
        {
            // simulate closing the window; if the form is "dirty" (changed since the last save)
            // then prompt the user to save.

            string message = "Would you like to save changes before closing?";
            string caption = "Warning";
            MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel;
            DialogResult result;

            // Displays the MessageBox.


            if (_dirtyTracker.IsDirty && !AddNewPatientSaveAndConfirmIsPressed)
            {
                result = MessageBox.Show(message, caption, buttons);
                if (result == DialogResult.Yes)
                {
                    _dirtyTracker.MarkAsClean();
                    MessageBox.Show("Please Check Data and Press Save and Confirm Button"
                        , "Instruction", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    e.Cancel = true;
                }
                else if (result == DialogResult.No)
                {
                    e.Cancel = false;
                    EditedPatient = new Patient_Profile_Viewer(ID);
                    EditedPatient.Show();
                }
                else
                    e.Cancel = true;
            }
            else
            {
                EditedPatient = new Patient_Profile_Viewer(ID);
                EditedPatient.Show();
            }

        }
        // View Specific Patient Profile
        private void View_Patient_Button_Click(object sender, EventArgs e)
        {
            if (!ValidateData.ValidateIDIsExist(IDtoview_textBox.Text))
            {
                Error.SetError(IDtoview_textBox, "Please Enter Valid ID"); 
                return;
            }
            Error.Clear();
                
            int ID = Int32.Parse(IDtoview_textBox.Text);
            Patient_Profile_Viewer ViewProfile = new Patient_Profile_Viewer(ID);
            ViewProfile.Show();

            IDtoview_textBox.Text = "";  
        }