private void registerPatient() { if (!IsValidInput()) { MessageBox.Show("Please fill-up all input"); return; } Classes.Patient patient = new Classes.Patient { id = DateTime.Now.ToString("ssmmMMddyyyy"), firstname = txtFirstname.Text, middlename = txtMiddleName.Text, lastname = txtLastname.Text, gender = char.Parse(cmbGender.SelectedItem.ToString()), birthdate = dtpBirthdate.Value, birthplace = txtBirthplace.Text, contact = txtContact.Text, emergency_contact = txtEmergencyContact.Text, address = txtStreet.Text + "/" + txtBaranggay.Text + "/" + txtCity.Text, occupation = txtOccupation.Text, citizenship = txtCitizenship.Text, religion = txtReligion.Text, isRegistered = 0 }; Firebase.Firebase firebase = new Firebase.Firebase(); firebase.InsertPatientMember(patient); Classes.PatientHelper.register(patient); this.DialogResult = System.Windows.Forms.DialogResult.OK; }
public CheckUP(Classes.Patient patient) { InitializeComponent(); this.patient = patient; Initialize(); timer1.Start(); }
/// <summary> /// Checks if the patient exists within the indexer /// If it exists, then set the session variable "SelectedPatient" as the Patient object retrieved /// </summary> private void SetSelectedPatient(int index) { Classes.Patient selectedPatient = this.indexer[index]; if (selectedPatient != null) { Session["SelectedPatient"] = selectedPatient; Server.Transfer("Patient.aspx"); } }
/// <summary> /// Add new patient to the database /// </summary> private void AddNewPatient(Classes.Patient patient) { string conString = "server=(local);database=Caregiver;Integrated Security=SSPI;"; using (SqlConnection conn = new SqlConnection(conString)) { try { using (SqlCommand cmd = new SqlCommand()) { conn.Open(); cmd.Connection = conn; // Insert new patient record to Patient table cmd.CommandText = "INSERT INTO Patient (FirstName,LastName,Sex,Birthday," + "Address,City,Province,PostalCode,PhoneNum)" + "VALUES(@FirstName,@LastName,@Sex,@Birthday," + "@Address,@City,@Province,@PostalCode,@PhoneNum);" + "SELECT SCOPE_IDENTITY()"; cmd.Parameters.AddWithValue("@FirstName", patient.FirstName); cmd.Parameters.AddWithValue("@LastName", patient.LastName); cmd.Parameters.AddWithValue("@Sex", patient.Sex); cmd.Parameters.AddWithValue("@Birthday", patient.Dob); cmd.Parameters.AddWithValue("@Address", patient.Address); cmd.Parameters.AddWithValue("@City", patient.City); cmd.Parameters.AddWithValue("@Province", patient.Province); cmd.Parameters.AddWithValue("@PostalCode", patient.PostalCode.ToUpper()); cmd.Parameters.AddWithValue("@PhoneNum", patient.PhoneNum); // Since it's an auto-incremented primary key, we want to get its primary key to insert the symptoms + history int patientID = Convert.ToInt32(cmd.ExecuteScalar()); // Insert into PatientHistory table based on the PatientId above foreach (string item in patient.History) { cmd.CommandText = "INSERT INTO PatientHistory VALUES(@PatientID,@HistoryId)"; cmd.Parameters.AddWithValue("@PatientId", patientID); cmd.Parameters.AddWithValue("@HistoryId", item); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); } // Insert into PatientSymptom table based on the PatientId above foreach (string item in patient.Symptoms) { cmd.CommandText = "INSERT INTO PatientSymptom VALUES(@PatientID,@SymptomId)"; cmd.Parameters.AddWithValue("@PatientId", patientID); cmd.Parameters.AddWithValue("@SymptomId", item); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); } } } catch (SqlException ex) { Response.Write("<script>alert('An error has occured with the database');</script>"); } } }
/// <summary> /// The form values are filled with the patients data from the database /// </summary> private void SetPatient() { Classes.Patient patient = (Classes.Patient)Session["SelectedPatient"]; tbFirstName.Text = patient.FirstName; tbLastName.Text = patient.LastName; if (patient.Sex == 'M') { rdbSex.SelectedIndex = 0; imgUser.ImageUrl = "/Images/Male.png"; } else { rdbSex.SelectedIndex = 1; imgUser.ImageUrl = "/Images/Female.png"; } tbDob.Text = patient.Dob; tbAddress.Text = patient.Address; tbCity.Text = patient.City; for (int i = 0; i < ddlProvince.Items.Count; i++) { if (ddlProvince.Items[i].Text == patient.Province) { ddlProvince.SelectedIndex = i; } } tbPostalCode.Text = patient.PostalCode; tbPhoneNum.Text = patient.PhoneNum; for (int i = 0; i < cblHistory.Items.Count; i++) { for (int j = 0; j < patient.History.Count; j++) { if (cblHistory.Items[i].Text == patient.History[j]) { cblHistory.Items[i].Selected = true; } } } for (int i = 0; i < cblSymptom.Items.Count; i++) { for (int j = 0; j < patient.Symptoms.Count; j++) { if (cblSymptom.Items[i].Text == patient.Symptoms[j]) { cblSymptom.Items[i].Selected = true; } } } }
/// <summary> /// Creates new patient based on user input /// </summary> protected void lbAdd_Click(object sender, EventArgs e) { // All inputs must be filled in before creating patient if (tbFirstName.Text == "" || tbLastName.Text == "" || tbDob.Text == "" || tbPhoneNum.Text == "" || tbAddress.Text == "" || tbCity.Text == "" || tbPostalCode.Text == "") { warningMessage.Style.Add("display", "inline"); warningMessage.InnerHtml = "You must fill in all text boxes!"; } else { // Set patient's information string fName = tbFirstName.Text; string lName = tbLastName.Text; char sex = rdbSex.SelectedIndex == 0 ? 'M' : 'F'; string dob = tbDob.Text; string address = tbAddress.Text; string city = tbCity.Text; string province = ddlProvince.SelectedValue; string postalCode = tbPostalCode.Text.ToUpper(); string phoneNum = tbPhoneNum.Text; // Sets patient's history (only selected checkboxes) List <string> history = new List <string>(); foreach (ListItem item in cblHistory.Items) { if (item.Selected) { history.Add(item.Value); } } // Sets patient's symptoms (only selected checkboxes) List <string> symptoms = new List <string>(); foreach (ListItem item in cblSymptom.Items) { if (item.Selected) { symptoms.Add(item.Value); } } // Create new Patient object Classes.Patient patient = new Classes.Patient(fName, lName, sex, dob); patient.SetLocation(address, city, province, postalCode, phoneNum); patient.History = history; patient.Symptoms = symptoms; AddNewPatient(patient); Server.Transfer("Home.aspx"); } }
public CheckUP(Classes.Checkup checkup) { InitializeComponent(); id = checkup.id; doctorID = checkup.user.id; this.checkup = checkup; currentPatient = checkup.patient; txtFullname.Text = checkup.patient.firstname + " " + checkup.patient.lastname; txtGender.Text = checkup.patient.gender.ToString(); txtAge.Text = (DateTime.Now.Year - checkup.patient.birthdate.Year).ToString(); txtBP.Text = checkup.blood_pressure; txtPR.Text = checkup.pulse_rate; txto2sat.Text = checkup.o2sat; txtrr.Text = checkup.respiratory_rate; txtGCS.Text = checkup.gcs; cc = checkup.cc; txtTemp.Text = checkup.temperature + "°C"; InitListView(); InitListView2(); PopulateList(checkup.patientID); }
public PatientRegistrationPayment(Classes.Patient patient) { InitializeComponent(); this.patient = patient; DisplayingPatientInfo(); }
/// <summary> /// Saves the new information to the database & the Patient object /// </summary> protected void btnSave_Click(object sender, EventArgs e) { btnEdit.Style.Add("display", "inline"); btnSave.Style.Add("display", "none"); btnDiagnose.Style.Add("display", "inline"); diagnosisMessage.Style.Add("display", "none"); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = "server=(local);database=Caregiver;Integrated Security=SSPI"; try { using (SqlCommand cmd = new SqlCommand()) { conn.Open(); cmd.Connection = conn; Classes.Patient patient = (Classes.Patient)Session["SelectedPatient"]; cmd.CommandText = "DELETE FROM PatientHistory WHERE PatientId=@id;" + "DELETE FROM PatientSymptom WHERE PatientId=@id"; cmd.Parameters.AddWithValue("@id", patient.Id); cmd.ExecuteNonQuery(); cmd.CommandText = "UPDATE Patient SET FirstName=@FirstName,LastName=@LastName,Sex=@Sex,Birthday=@Birthday," + " Address=@Address,City=@City,Province=@Province,PostalCode=@PostalCode,PhoneNum=@PhoneNum" + " WHERE PatientId = @id2;"; cmd.Parameters.AddWithValue("@FirstName", tbFirstName.Text); cmd.Parameters.AddWithValue("@LastName", tbLastName.Text); cmd.Parameters.AddWithValue("@Sex", rdbSex.SelectedValue); cmd.Parameters.AddWithValue("@Birthday", Convert.ToDateTime(tbDob.Text)); cmd.Parameters.AddWithValue("@Address", tbAddress.Text); cmd.Parameters.AddWithValue("@City", tbCity.Text); cmd.Parameters.AddWithValue("@Province", ddlProvince.SelectedItem.Value); cmd.Parameters.AddWithValue("@PostalCode", tbPostalCode.Text.ToUpper()); cmd.Parameters.AddWithValue("@PhoneNum", tbPhoneNum.Text); cmd.Parameters.AddWithValue("@id2", patient.Id); cmd.ExecuteNonQuery(); patient.FirstName = tbFirstName.Text; patient.LastName = tbLastName.Text; patient.Sex = rdbSex.SelectedValue[0]; patient.Dob = tbDob.Text; patient.Address = tbAddress.Text; patient.City = tbCity.Text; patient.Province = ddlProvince.SelectedItem.Value; patient.PostalCode = tbPostalCode.Text.ToUpper(); patient.PhoneNum = tbPhoneNum.Text; List <string> history = new List <string>(); patient.History.Clear(); foreach (ListItem item in cblHistory.Items) { if (item.Selected) { history.Add(item.Value); patient.History.Add(item.Text); } } List <string> symptoms = new List <string>(); patient.Symptoms.Clear(); foreach (ListItem item in cblSymptom.Items) { if (item.Selected) { symptoms.Add(item.Value); patient.Symptoms.Add(item.Text); } } foreach (string item in history) { cmd.CommandText = "INSERT INTO PatientHistory VALUES(@PatientID,@HistoryId)"; cmd.Parameters.AddWithValue("@PatientId", patient.Id); cmd.Parameters.AddWithValue("@HistoryId", item); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); } foreach (string item in symptoms) { cmd.CommandText = "INSERT INTO PatientSymptom VALUES(@PatientID,@SymptomId)"; cmd.Parameters.AddWithValue("@PatientId", patient.Id); cmd.Parameters.AddWithValue("@SymptomId", item); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); } editMessage.Style.Add("display", "block"); Session["SelectedPatient"] = patient; conn.Close(); } } catch (SqlException ex) { Response.Write("<script>alert('An error has occured with the database');</script>"); } } }
/// <summary> /// This function is for calculating the diagnosis of the patient by checking what symptoms the patient has /// Displays the diagnosis in the alert box on the top /// </summary> protected void btn_Diagnose(object sender, EventArgs e) { string result = ""; SetPatient(); Classes.Patient patient = (Classes.Patient)Session["SelectedPatient"]; // Calculate disease chances int coronaryArteryDiseaseChance = patient.CalculateCoronaryArteryChance(); int strokeChance = patient.CalculateStrokeChance(); int fluChance = patient.CalculateFluChance(); int kidneyDiseaseChance = patient.CalculateKidneyDiseaseChance(); if (cblSymptom.SelectedIndex == -1) { result = "No diagnosis."; } else { // check if all chances are equal if (coronaryArteryDiseaseChance == strokeChance && coronaryArteryDiseaseChance == fluChance && coronaryArteryDiseaseChance == kidneyDiseaseChance) { result = "Probable chance of Flu(Influenza)"; } // check if coronaryArteryDiseaseChance is greater than all the others // if one chance is greater than the others if (coronaryArteryDiseaseChance > strokeChance && coronaryArteryDiseaseChance > fluChance && coronaryArteryDiseaseChance > kidneyDiseaseChance) { result = "Probable chance of Coronary Artery Disease"; }// check if strokeChance is greater than all the others else if (strokeChance > coronaryArteryDiseaseChance && strokeChance > fluChance && strokeChance > kidneyDiseaseChance) { result = "Probable chance of Stroke"; }// check if fluChance is greater than all the others else if (fluChance > coronaryArteryDiseaseChance && fluChance > strokeChance && fluChance > kidneyDiseaseChance) { result = "Probable chance of Flu (Influenza)"; } // check if kidneyDiseaseChance is greater than all the others else if (kidneyDiseaseChance > coronaryArteryDiseaseChance && kidneyDiseaseChance > fluChance && kidneyDiseaseChance > strokeChance) { result = "Probable chance of Kidney Disease"; } // check if any 2 are equal and greater than the other 2 -- if if (coronaryArteryDiseaseChance == strokeChance && strokeChance > fluChance && strokeChance > kidneyDiseaseChance) { result = "Probable chance of Stroke"; } else if (coronaryArteryDiseaseChance == fluChance && fluChance > strokeChance && fluChance > kidneyDiseaseChance) { result = "Probable chance of Flu (Influenza)"; } else if (coronaryArteryDiseaseChance == kidneyDiseaseChance && kidneyDiseaseChance > fluChance && kidneyDiseaseChance > strokeChance) { result = "Probable chance of Kidney Disease"; } else if (strokeChance == fluChance && fluChance > coronaryArteryDiseaseChance && fluChance > kidneyDiseaseChance) { result = "Probable chance of Flu (Influenza)"; } else if (strokeChance == kidneyDiseaseChance && strokeChance > coronaryArteryDiseaseChance && strokeChance > fluChance) { result = "Probable chance of Stroke"; } else if (fluChance == kidneyDiseaseChance && fluChance > coronaryArteryDiseaseChance && fluChance > strokeChance) { result = "Probable chance of Flu (Influenza)"; } // check if any 3 are equal && greater than the other one -- if if (coronaryArteryDiseaseChance == strokeChance && coronaryArteryDiseaseChance == fluChance && fluChance > kidneyDiseaseChance) { result = "Probable chance of Flu (Influenza)"; } else if (coronaryArteryDiseaseChance == strokeChance && coronaryArteryDiseaseChance == kidneyDiseaseChance && strokeChance > fluChance) { result = "Probable chance of Stroke"; } else if (coronaryArteryDiseaseChance == fluChance && coronaryArteryDiseaseChance == kidneyDiseaseChance && fluChance > strokeChance) { result = "Probable chance of Flu (Influenza)"; } else if (strokeChance == fluChance && strokeChance == kidneyDiseaseChance && strokeChance > coronaryArteryDiseaseChance) { result = "Probable chance of Flu (Influenza)"; } } // Displays message box with diagnosis editMessage.Style.Add("display", "none"); diagnosisMessage.InnerHtml = result; diagnosisMessage.Style.Add("display", "block"); }
/// <summary> /// Initializes the Indexer and fills it will Patient objects for each database record /// </summary> private void SetIndexer() { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = "server=(local);database=Caregiver;integrated security=SSPI;"; using (SqlCommand cmd = new SqlCommand()) { conn.Open(); cmd.Connection = conn; cmd.CommandText = "SELECT * FROM Patient"; SqlDataReader reader = cmd.ExecuteReader(); // Get all of the patient's information while (reader.Read()) { Classes.Patient patient = new Classes.Patient(); patient.Id = Convert.ToInt32(reader[0]); patient.FirstName = (string)reader[1]; patient.LastName = (string)reader[2]; patient.Sex = Convert.ToChar(reader[3]); patient.Dob = reader[4].ToString(); patient.Address = (string)reader[5]; patient.City = (string)reader[6]; patient.Province = (string)reader[7]; patient.PostalCode = (string)reader[8]; patient.PhoneNum = (string)reader[9]; indexer.AddPatient(patient); } // end of patient table info reader.Close(); // Get all of the patient's history cmd.CommandText = "SELECT Patient.PatientId, h.Name FROM History h JOIN PatientHistory " + "ON h.HistoryId = PatientHistory.HistoryId JOIN Patient " + "ON Patient.PatientId = PatientHistory.PatientId"; reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Classes.Patient patient = indexer[Convert.ToInt32(reader[0])]; patient.History.Add(reader[1].ToString()); } } reader.Close(); // Get all of the patient's symptoms cmd.CommandText = "SELECT Patient.PatientId, s.Name FROM Symptom s JOIN PatientSymptom " + "ON s.SymptomId = PatientSymptom.SymptomId JOIN Patient " + "ON Patient.PatientId = PatientSymptom.PatientId "; reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Classes.Patient patient = indexer[Convert.ToInt32(reader[0])]; patient.Symptoms.Add(reader[1].ToString()); } } reader.Close(); } } }