private void btnAddAppointment_Click(object sender, EventArgs e) { try { DateTime newAppointment = dpAddAppointment.Value.Date + dpAppointmentTime.Value.TimeOfDay; if (newAppointment.Date == DateTime.Today.Date) { throw new Exception("Appointment cannot be today"); } appointment = new clsAppointment(); appointment.Save(patient.PatientId, newAppointment); Navigation(); if (patient != null || patient.PatientId != 0) { AssignValue(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Save patient details /// </summary> private void SavePatient() { int patientId = 0; patientDetails = new clsPatientDetails(); patientId = patientDetails.Save(patient.PatientDetails); if (patientId == 0) { throw new Exception("Cannot save patient"); } dateEntry = new clsDateEntry(); dateEntry.Save(patientId, patient.DateEntry); if (patient.Appointments.Count > 0) { var selectedAppointment = patient.Appointments.First(); if (selectedAppointment.Appointment.Date != DateTime.Today.Date) { appointment = new clsAppointment(); appointment.Save(patientId, selectedAppointment.Appointment); } } medicalRecord = new clsMedicalRecord(); medicalRecord.Save(patientId, patient.MedicalRecords); assessment = new clsAssessment(); assessment.Save(patientId, patient.Assessment); prescription = new clsPrescription(); prescription.Save(patientId, patient.Prescription); }
private void btnSearch_Click(object sender, EventArgs e) { try { patients = new List <clsPatientModel>(); appointment = new clsAppointment(); patientDetails = new clsPatientDetails(); DateTime from = Convert.ToDateTime(dpFrom.Value); DateTime to = Convert.ToDateTime(dpTo.Value); if ((from > to) || (from == to)) { throw new Exception("Invalid date"); } var patientsRow = appointment.Retrieve(); if (patientsRow.Count > 0) { foreach (var item in patientsRow) { item.PatientDetails = new clsPatientDetailsModel(); item.PatientDetails = patientDetails.GetByPatientId(item.PatientId); } } foreach (var item in patientsRow) { foreach (var appointment in item.Appointments) { if ((appointment.Appointment.Date >= from.Date) && (appointment.Appointment.Date <= to.Date)) { clsPatientModel sort = new clsPatientModel { PatientDetails = new clsPatientDetailsModel(), Appointments = new List <clsAppointmentModel>(), PatientId = item.PatientId }; sort.PatientDetails = item.PatientDetails; sort.Appointments.Add(appointment); patients.Add(sort); } } } AssignToGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Navigation /// </summary> private void Navigation() { if (selectedPatient == 0) { this.Close(); } patientDetail = new clsPatientDetails(); dateEntry = new clsDateEntry(); medicalRecord = new clsMedicalRecord(); assessment = new clsAssessment(); appointment = new clsAppointment(); prescription = new clsPrescription(); patient = new clsPatientModel() { Appointments = new List <clsAppointmentModel>(), Assessment = new List <clsAssessmentModel>(), DateEntry = new clsDateEntryModel(), MedicalRecords = new clsPatientMedicalRecordModel(), PatientDetails = new clsPatientDetailsModel(), PatientId = selectedPatient, Prescription = new clsPrescriptionModel() }; switch (navigateFrom) { case NavigationType.Appointments: case NavigationType.Patients: case NavigationType.Search: patient.PatientDetails = patientDetail.GetByPatientId(selectedPatient); patient.DateEntry = dateEntry.GetbyPatientId(selectedPatient); patient.MedicalRecords = medicalRecord.GetByPatientId(selectedPatient); patient.Prescription = prescription.GetByPatientId(selectedPatient); patient.Assessment = assessment.GetByPatientId(selectedPatient); patient.Appointments = appointment.GetByPatientId(selectedPatient); break; case NavigationType.NewPatient: break; case NavigationType.RnageOfMotion: break; case NavigationType.ViewPatient: break; default: break; } }
//private void xuiButton1_Click(object sender, EventArgs e) //{ // RangeOfMotion range = new RangeOfMotion(this, NavigationType.Appointments); // range.ShowDialog(); //} //public void SetLabel(string label) //{ // //lblTest.Text = label; //} private void RetrieveTodayAppointment() { patients = new List <clsPatientModel>(); appointment = new clsAppointment(); patientDetails = new clsPatientDetails(); var patientsRow = appointment.Retrieve(); if (patientsRow.Count > 0) { foreach (var item in patientsRow) { item.PatientDetails = new clsPatientDetailsModel(); item.PatientDetails = patientDetails.GetByPatientId(item.PatientId); } } foreach (var item in patientsRow) { foreach (var appointment in item.Appointments) { if (appointment.Appointment.Date == DateTime.Today.Date) { clsPatientModel sort = new clsPatientModel { PatientDetails = new clsPatientDetailsModel(), Appointments = new List <clsAppointmentModel>(), PatientId = item.PatientId }; sort.PatientDetails = item.PatientDetails; sort.Appointments.Add(appointment); patients.Add(sort); } } } }
private void btnDeleteAppointment_Click(object sender, EventArgs e) { try { if (selectedAppointmentId == 0) { throw new Exception("Select appointment to delete"); } appointment = new clsAppointment(); appointment.DeleteByAppointmentId(selectedAppointmentId); Navigation(); if (patient != null || patient.PatientId != 0) { AssignValue(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }