public CustomMessage(MessagesTable m) { if (UtilitiesClass.getPatient(m.MessageTO) != null) { PatientsTable messageTo = UtilitiesClass.getPatient(m.MessageTO); DoctorsTable messageFrom = UtilitiesClass.getDoctor(m.MessageFROM); this.From = $"{messageFrom.FirstName.Trim()} {messageFrom.LastName.Trim()}"; this.To = $"{messageTo.FirstName.Trim()} {messageTo.LastName.Trim()}"; } else { DoctorsTable messageTo = UtilitiesClass.getDoctor(m.MessageTO); PatientsTable messageFrom = UtilitiesClass.getPatient(m.MessageFROM); this.From = $"{messageFrom.FirstName.Trim()} {messageFrom.LastName.Trim()}"; this.To = $"{messageTo.FirstName.Trim()} {messageTo.LastName.Trim()}"; } this.Date = m.Date; this.MessagePreview = Regex.Replace(m.Message.Remove(40), @"\s+", " "); //CHECK if (m.Message.Length > 40) { this.MessagePreview += "..."; } this.Read = Convert.ToInt32(m.IsRead) == 0 ? "Unread" : ""; this.MessageID = m.MessageID; }
protected void Page_Load(object sender, EventArgs e) { string ourUser = User.Identity.Name; myDbcon1.PatientsTables.Load(); myDbcon2.DoctorsTables.Load(); PatientsTable myPatient = (from x in myDbcon1.PatientsTables.Local where x.UserLoginName.Trim().Equals(ourUser) select x).First(); int patID = myPatient.PatientsID; int docID = myPatient.DoctorID; DoctorsTable myDoctor = (from x in myDbcon2.DoctorsTables.Local where x.DoctorID == docID select x).First(); Label1.Text = "Name: " + myPatient.FirstName + " " + myPatient.LastName; Label2.Text = "Doctor: " + myDoctor.FirstName + " " + myDoctor.LastName; myDbcon3.TestTables.Load(); TestTable test = (from x in myDbcon3.TestTables.Local where x.PatientID == patID select x).First(); ListBox1.Items.Add(test.TestDate + " " + test.TestResults); }
protected void Page_Load(object sender, EventArgs e) { string ourUser = User.Identity.Name; myDbcon1.PatientsTables.Load(); myDbcon2.DoctorsTables.Load(); PatientsTable myPatient = (from x in myDbcon1.PatientsTables.Local where x.UserLoginName.Trim().Equals(ourUser) select x).First(); int patID = myPatient.PatientsID; int docID = myPatient.DoctorID; DoctorsTable myDoctor = (from x in myDbcon2.DoctorsTables.Local where x.DoctorID == docID select x).First(); Label1.Text = "Name: " + myPatient.FirstName + " " + myPatient.LastName; Label2.Text = "Doctor: " + myDoctor.FirstName + " " + myDoctor.LastName; myDbcon3.MessagesTables.Load(); var myMessages = from x in myDbcon3.MessagesTables.Local where x.MessageTO.Trim() == myPatient.UserLoginName.Trim() select x; GridView1.DataSource = myMessages.ToList(); GridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { if (DropDownList1.SelectedValue == null) { MessageBox.Show("Need to select a doctor."); } else { MessagesTable myMessage = new MessagesTable(); string ourUser = User.Identity.Name; myDbcon1.PatientsTables.Load(); myDbcon2.DoctorsTables.Load(); PatientsTable myPatient = (from x in myDbcon1.PatientsTables.Local where x.UserLoginName.Trim().Equals(ourUser) select x).First(); myMessage.MessageFROM = myPatient.UserLoginName.Trim(); myMessage.MessageTO = DropDownList1.SelectedValue.Trim(); myMessage.Date = DateTime.Now; myMessage.Message = TextBox1.Text.Trim(); //Add data to the table myDbcon1.MessagesTables.Add(myMessage); myDbcon1.SaveChanges(); } }
public static void Initialize() { Appointments = new AppointmentsTable(); Doctors = new DoctorsTable(); Patients = new PatientsTable(); AppointmentsConflicts = new AppointmentConflictsTable(); AppointmentsOpLog = new AppointmentsOpLogTable(); Patients.Add(new PatientModel() { PatientId = "19860813-XXXX", PatientName = "Henrik Karlsson" }); Patients.Add(new PatientModel() { PatientId = "19750612-XXXX", PatientName = "Erik Henriksson" }); Patients.Add(new PatientModel() { PatientId = "19600519-XXXX", PatientName = "Cecilia Eliasson" }); Doctors.Add(new DoctorModel() { DoctorId = "201012-1425", DoctorName = "Mikael Seström" }); Doctors.Add(new DoctorModel() { DoctorId = "200911-1758", DoctorName = "Carina Axel" }); Doctors.Add(new DoctorModel() { DoctorId = "199005-1875", DoctorName = "Martin Eriksson" }); }
protected void Button1_Click(object sender, EventArgs e) { if (GridView1.SelectedIndex >= 0) { dbcon.PatientsTables.Load(); // load up the database dbcon.TestsTables.Load(); dbcon.MedicationListTables.Load(); // find the patient based on the PatientID PatientsTable patient = dbcon.PatientsTables.Find(Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text)); //Fill in Name label Name.Text = patient.FirstName + " " + patient.LastName; //Fill in Email label Email.Text = patient.Email; //Fill in Tests label if (patient.TestID != null) { var tests = (from x in dbcon.TestsTables.Local where x.TestID == patient.TestID select x).First(); Tests.Text = "TestID: " + tests.TestID.ToString() + " Test Results: " + tests.TestResults.ToString() + " Test Date: " + tests.TestDate.ToString(); } else { Tests.Text = "No tests"; } //Fill in Medications label if (patient.TestID != null) { var meds = (from x in dbcon.MedicationListTables.Local where x.PatientID == patient.PatientID select x).First(); Medications.Text = "Medication ID: " + meds.MedicationID.ToString() + " Description: " + meds.Description.ToString(); } else { Medications.Text = "No medications"; } } }
protected void Button2_Click(object sender, EventArgs e) { string ourUser = User.Identity.Name; myDbcon1.PatientsTables.Load(); myDbcon2.DoctorsTables.Load(); PatientsTable myPatient = (from x in myDbcon1.PatientsTables.Local where x.UserLoginName.Trim().Equals(ourUser) select x).First(); int patID = myPatient.PatientsID; int docID = myPatient.DoctorID; myDbcon3.MessagesTables.Load(); var myMessages = from x in myDbcon3.MessagesTables.Local where x.MessageFROM.Trim() == myPatient.UserLoginName.Trim() select x; GridView1.DataSource = myMessages.ToList(); GridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { if (Calendar1.SelectedDate <= DateTime.Now) { MessageBox.Show("Date has to be after current day!"); } else { AppointmentsTable myAppointment = new AppointmentsTable(); string ourUser = User.Identity.Name; myDbcon1.PatientsTables.Load(); myDbcon2.DoctorsTables.Load(); PatientsTable myPatient = (from x in myDbcon1.PatientsTables.Local where x.UserLoginName.Trim().Equals(ourUser) select x).First(); int patID = myPatient.PatientsID; /* myDbcon2.DoctorsTables.Load(); * * var myApp = from x in myDbcon2.DoctorsTables.Local * where x.Department == DropDownList2.SelectedValue * select x; * * DropDownList3.DataSource = myApp.ToList(); * DropDownList3.DataBind(); */ /*myDbcon3.DoctorsTables.Load(); * DoctorsTable myDoc = (from x in myDbcon3.DoctorsTables.Local * where (x.FirstName + x.LastName) == DropDownList3.SelectedValue * select x).First();*/ myAppointment.PatientID = patID; myAppointment.Purpose = TextBox1.Text; myAppointment.DoctorID = Convert.ToInt32(DropDownList3.SelectedValue); myAppointment.VisitSummary = TextBox2.Text; myAppointment.Date = Calendar1.SelectedDate; int hours = Convert.ToInt32(TextBox3.Text); int mins = Convert.ToInt32(DropDownList1.SelectedValue); myAppointment.Time = new TimeSpan(hours, mins, 0); //Check for conflicting appointments bool timeconflict = false; foreach (var x in myDbcon1.AppointmentsTables) { if (myAppointment.Date == x.Date && myAppointment.Time == x.Time) { timeconflict = true; } } if (timeconflict == true) { //Display error message MessageBox.Show("Time conflicts with an existing appointment."); } else { //Add data to the table myDbcon1.AppointmentsTables.Add(myAppointment); myDbcon1.SaveChanges(); MessageBox.Show("Appointment successfully created."); } } }
protected void Page_Load(object sender, EventArgs e) { // If Patient, do this if (Convert.ToInt32(Session["IsDoctor"]) == 0) { // Doctor's appointments not visible to patient ShowDoctorAppointments.Visible = false; // Create Patient Object myPatient = UtilitiesClass.getPatient(Session["LoginName"].ToString()); Session["AppointmentPatientID"] = myPatient.PatientID; // Create a Doctor object that is paired to the patient myDoctor = UtilitiesClass.getPatientsDoctor(myPatient); // Adds users appointments to appointments list allAppointments = dbcon.AppointmentsTables.ToList(); foreach (AppointmentsTable appointment in allAppointments) { if (appointment.PatientID == myPatient.PatientID) { userAppointments.Add(appointment); } } // If no appointments are set up, display message if (userAppointments.Count == 0) { DisplayNoAppointMessage.Text = "You have no appointments set up yet."; DeletePatientAppointButton.Visible = false; } else // display patients appointments { DisplayNoAppointMessage.Visible = false; DeletePatientAppointButton.Visible = true; } } else // if Doctor, do this { AddAppointmentHyperLink.Visible = false; ShowDoctorAppointments.Visible = true; ShowPatientAppointments.Visible = false; DoctorsTable myDoctor = UtilitiesClass.getDoctor(Session["LoginName"].ToString()); Session["AppointmentDoctorID"] = myDoctor.DoctorID; allAppointments = dbcon.AppointmentsTables.ToList(); foreach (AppointmentsTable appointment in allAppointments) { if (appointment.DoctorID == myDoctor.DoctorID) { userAppointments.Add(appointment); } } if (userAppointments.Count == 0) { DisplayNoAppointMessage.Text = "You have no appointments set up yet."; DeleteDoctorAppointButton.Visible = false; } else { DisplayNoAppointMessage.Visible = false; DeleteDoctorAppointButton.Visible = true; } } }