//Populates patient details in textboxes private void Dropdown_1_SelectionChangeCommitted(object sender, EventArgs e) { Patient_Database.patientSelectedGenerateLetter(Dropdown_1, Input_1, Input_2, Input_3, Input_4, Input_5, GP_Letter); //Gets all initial consultations of patient DataTable initialConsultations = Consultation_Database.CheckInitialConsultations(Dropdown_1); int consCount = initialConsultations.Rows.Count; //Depending on how many initial consultations will depend on the text displayed if (consCount == 0) { Input_6.Text = "No Initial Consultation"; } else if (consCount == 1) { Input_6.Text = Convert.ToString(initialConsultations.Rows[0]["Display Text"]); } else if (consCount > 1) { Input_6.Text = "More than one Initial Consultation"; } //Enables controls to generate letters Initial_Letter.Enabled = true; Initial_Letter_MHLP.Enabled = true; No_Contact_Letter.Enabled = true; GP_Letter.Enabled = true; }
//No contant letter is based on the initial consultation. If thre is more than 1 initial consultation then //furethr validation is required private void No_Contact_Letter_Click(object sender, EventArgs e) { //Gets all initial Consultations from patient and stores the id and date in a dictionary DataTable initialConsultations = Consultation_Database.CheckInitialConsultations(Dropdown_1); if (initialConsultations.Rows.Count == 0) { MessageBox.Show("There is no initial consultations for This patient. Please add a new initial " + "consultation to generate this letter", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //If only one consultation then generate letter else if (initialConsultations.Rows.Count == 1) { consultationDate = Convert.ToString(initialConsultations.Rows[0]["Date"]); WriteLetter("No Contact.dat"); } //Changing the form to allow user to choose which consultation will be in the letter else if (initialConsultations.Rows.Count > 1) { //Sets trigger so other events know we are choosing the initial consultation ChooseInitialConsultation = true; //Adjusting form height and setting unwanted objects to visible = false this.Height = 190; this.Width = 352; Sort_Lists.Visible = false; label2.Visible = false; label4.Visible = false; label5.Visible = false; Input_1.Visible = false; Input_2.Visible = false; Input_3.Visible = false; //Changes the header label label1.Visible = false; label3.Visible = true; label6.Visible = true; //Centering the dropdown and moving the back button into view Dropdown_1.Visible = false; Dropdown_2.Visible = true; UserLabel.Location = new Point(20, 133); Back.Location = new Point(239, 122); //Making visible the accept consultation button and cancel button Accept_Consultation.Visible = true; Cancel.Visible = true; //Changes the datasource of the dropdown2 Dropdown_2.DataSource = null; Dropdown_2.DataSource = initialConsultations; Dropdown_2.DisplayMember = "Display Text"; Dropdown_2.ValueMember = "Date"; } }
//When a user clicks a selection from the dropdown box all the values of the selected patient will //populate the fields. private void Dropdown_1_SelectionChangeCommitted(object sender, EventArgs e) { Patient_Database.PatientSelectedConsultation1(Dropdown_1, Input_1, Input_2, Input_3, Input_4, Input_5); Consultation_Database.PopulateConsultationDataGridView(Dropdown_1, Existing_Consultations); //Poplulates existing consultations if any Dropdown_2.Enabled = true; //Allows user to choose time period if (Dropdown_2.SelectedIndex != -1) { Add_Consultation.Enabled = true; } }
//Deletes selected consultation private void Delete_Click(object sender, EventArgs e) { bool deleteSuccessful = Consultation_Database.DeleteConsultation(Dropdown_1, Existing_Consultations); //Deletes Consultation //If user chooses to cancel delete or there is no consultations to delete it stops the method if (deleteSuccessful == false) { return; } Consultation_Database.PopulateConsultationDataGridView(Dropdown_1, Existing_Consultations); //Refreshes existing consultations }
//DDL for Consultation // "CREATE TABLE [CONSULTATION]" + // "(CONS_ID_Number TEXT NOT NULL PRIMARY KEY UNIQUE," + // "PAT_ID_Number INT NOT NULL," + // "CONS_Consultant TEXT NOT NULL," + // "CONS_Time_Period TEXT NOT NULL," + // "CONS_Date DATE NOT NULL," + // "CONS_Health_Rating TEXT," + // "CONS_Smoking_Status TEXT," + // "CONS_Alcohol_Days NUMERIC," + // "CONS_Alcohol_Drinks NUMERIC," + // "CONS_Height NUMERIC," + // "CONS_Weight NUMERIC," + // "CONS_BMI NUMERIC," + // "CONS_Waist NUMERIC," + // "CONS_SBP NUMERIC," + // "CONS_DBP NUMERIC," + // "CONS_Body_Fat_Percentage NUMERIC," + // "CONS_LBM NUMERIC," + // "CONS_Visceral_Fat_Rating NUMERIC," + // "CONS_CHO_TC NUMERIC," + // "CONS_CHO_LDL NUMERIC," + // "CONS_CHO_HDL NUMERIC," + // "CONS_CHO_TG NUMERIC," + // "CONS_Fasting_Glucose NUMERIC," + // "CONS_HbA1c NUMERIC," + // "CONS_Resistance INTEGER," + // "CONS_Cardio INTEGER," + // "CONS_Brisk_Walk INTEGER," + // "CONS_Light_Activity INTEGER," + // "CONS_Fruit_Serves NUMERIC," + // "CONS_Fruit_Greater_2_Serves NUMERIC," + // "CONS_Vegetable_Serves NUMERIC," + // "CONS_Vegetable_Greater_5_Serves NUMERIC," + // "CONS_Commercial_Meals INTEGER," + // "CONS_Sweets INTEGER," + // "CONS_Soft_Drinks INTEGER," + // "CONS_Skip_Main_Meals INTEGER," + // "CONS_Keep_Track_Of_Food INTEGER," + // "CONS_Limit_Portions INTEGER," + // "CONS_Eat_When_Upset INTEGER," + // "CONS_Eat_In_Front_Of_TV INTEGER," + // "CONS_Choose_Healthier_Foods INTEGER," + // "CONS_Notes TEXT);"; //********************Class Constructor******************** public Add_Edit_Consultation_2() { InitializeComponent(); Global.testConnection(this); //Tests database connection Date_1.Value = DateTime.Now; //Sets Date to today UserLabel.Text = "Current User: "******" " + Global.userLastName; //Sets user label //Shows existing consultations in the DGV Consultation_Database.PopulateConsultationDataGridView(Exisiting_Consultations); FillPatientDetails(); //Sets pre fill details }
//********************Non Event Methods******************** //If new consultation then Patient details and time period is populated //If edit session then all fields are populated private void FillPatientDetails() { Patient_Details.Text = "ID: " + Global.consPatientID.ToString() + " *** " + Global.consPatientName; Input_2.Text = Global.consTimePeriod; //Popultaes existing data if in edit session if (Global.editingExistingConsulation == true) { Input_1.Text = Global.consID; Date_1.Value = Global.consDate; AddOrEditFields(true); Consultation_Database.EditConsultation(Input_1, Input_3, Input_4, Input_5, Input_6, Input_7, Input_8, Input_9, Input_10, Input_11, Input_12, Input_13, Input_14, Input_15, Input_16, Input_17, Input_18, Input_19, Input_20, Input_21, Input_22, Input_23, Input_24, Input_25, Input_26, Input_27, Input_28, Input_29, Input_30, Input_31, Input_32, Input_33, Input_34, Input_35, Input_36, Input_37, Input_38, Date_1, Dropdown_1, Dropdown_2); } }
//********************Database Event Methods******************** //Saves changes to new patient or existing patient private void Save_Click(object sender, EventArgs e) { //All input boxes are read only when they can't be saved. //This will stop users from clicking save when not in edit mode if (Input_3.ReadOnly == true) { MessageBox.Show("Please click 'Edit Current' button to save changes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Consultant must be chosen if (Dropdown_2.SelectedIndex == -1) { MessageBox.Show("Please choose a consultant", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Testing if only numbers were input if (TestNumbers() == false) { MessageBox.Show("All fields need to be numbers except for:\nHeath Rating,\nSmoking Status and\nNotes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Saves Consultation to Database bool saveSuccessful = Consultation_Database.SaveConsultation(Input_1, Input_2, Input_3, Input_4, Input_5, Input_6, Input_7, Input_8, Input_9, Input_10, Input_11, Input_12, Input_13, Input_14, Input_15, Input_16, Input_17, Input_18, Input_19, Input_20, Input_21, Input_22, Input_23, Input_24, Input_25, Input_26, Input_27, Input_28, Input_29, Input_30, Input_31, Input_32, Input_33, Input_34, Input_35, Input_36, Input_37, Input_38, Date_1, Dropdown_1, Dropdown_2); //Triggered if user is promted that a record exists with the same time period and the user clicks cancel if (saveSuccessful == false) { return; } //Once consultation is saved the DGV is updated Consultation_Database.PopulateConsultationDataGridView(Exisiting_Consultations); AddOrEditFields(false); //Changes all fields to read only Edit_Consultation.Visible = true; //Allows user to make edits if necessary }
//Views all of the records determined by the dropdown1 selection private void View_All_Click(object sender, EventArgs e) { switch (Global.view) { case "View Patients": Patient_Database.ViewAllRecords(Dropdown_1, Records_Gridview); break; case "View Consultations": Consultation_Database.ViewAllRecords(Dropdown_1, Records_Gridview); break; case "View Reffering GPs": Reffering_GP_Database.ViewAllRecords(Records_Gridview); break; case "View Practices": Practice_Database.ViewAllRecords(Records_Gridview); break; } Total_Records.Text = Records_Gridview.Rows.Count.ToString(); }
private void Search_Click(object sender, EventArgs e) { switch (Global.view) { case "View Patients": Patient_Database.ViewSearchedRecords(Records_Gridview, Input_1, Dropdown_1, Dropdown_2, Dropdown_3, Date_1, Date_2); break; case "View Consultations": Consultation_Database.ViewSearchedRecords(Records_Gridview, Input_1, Dropdown_1, Dropdown_2, Dropdown_3, Date_1, Date_2); break; case "View Reffering GPs": Reffering_GP_Database.ViewSearchedRecords(Records_Gridview, Input_1, Dropdown_2); break; case "View Practices": Practice_Database.ViewSearchedRecords(Records_Gridview, Input_1, Dropdown_2); break; } Total_Records.Text = Records_Gridview.Rows.Count.ToString(); }
//Sets the search input box and labels private void Dropdown_2_SelectionChangeCommitted(object sender, EventArgs e) { Search.Enabled = true; //Allows user to search once a selection is made switch (Global.view) { case "View Patients": Patient_Database.Show_HideSearchOptions(Dropdown_2, Dropdown_3, Input_1, Date_1, Date_2, Search_Label, Search_Label2); break; case "View Consultations": Consultation_Database.Show_HideSearchOptions(Dropdown_2, Dropdown_3, Input_1, Date_1, Date_2, Search_Label, Search_Label2); break; case "View Reffering GPs": Reffering_GP_Database.Show_HideSearchOptions(Dropdown_2, Input_1, Search_Label); break; case "View Practices": Practice_Database.Show_HideSearchOptions(Dropdown_2, Input_1, Search_Label); break; } }