public Appointment GetAppointmentById(int appointmentId) { try { appointmentDataLayer = new AppointmentDataLayer(); return(appointmentDataLayer.GetAppointmentsById(appointmentId)); }catch (Exception e) { Database.ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
public List <AppointmentListViewModel> GetAppointmentListView(int?id) { try { if (id == null) { id = -1; } List <Appointment> appointmentList = patientBusinessLayer.GetPatientAppointments((int)id); appointmentListViewModelList = new List <AppointmentListViewModel>(); appointmentDataLayer = new AppointmentDataLayer(); foreach (var appointment in appointmentList) { MedicinesQuantity invoice = appointmentDataLayer.GetInvoiceByAppointmentId(appointment.Id); appointmentListViewModel = new AppointmentListViewModel(); appointmentListViewModel.Id = appointment.Id; appointmentListViewModel.PatientName = patientBusinessLayer.GetPatientNameById(appointment.PatientId); appointmentListViewModel.DoctorName = doctorBusinessLayer.GetDoctorNameById(appointment.DoctorId); appointmentListViewModel.Date = appointment.Date.ToString().Split(' ')[0]; if (appointment.Time == -1) { appointmentListViewModel.Time = "---"; } else { appointmentListViewModel.Time = TimeSlots.Timings[appointment.Time]; } appointmentListViewModel.Status = appointment.Status; if (invoice != null) { appointmentListViewModel.showMedicineButton = false; //appointmentListViewModelList.Add(appointmentListViewModel); } else if (invoice == null) { appointmentListViewModel.showMedicineButton = true; } appointmentListViewModelList.Add(appointmentListViewModel); } return(appointmentListViewModelList); }catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
public void CancelPastAppointments() { try { appointmentDataLayer = new AppointmentDataLayer(); var previousDay = DateTime.Today.AddDays(-1); appointmentDataLayer.GetPastAppointments(previousDay); //for (int i=0;i<appointments.Count;i++) //{ // if(appointments[i].Status == AppointmentStatus.Pending || appointments[i].Status == AppointmentStatus.Approved) // { // appointments[i].Status = AppointmentStatus.Cancelled; // } //} //appointmentDataLayer.UpdateAppointments(appointments); } catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }
public List <MedicalHistoryViewModel> GetMedicalHistory(int?id) { try { medicalHistoryViewModelList = new List <MedicalHistoryViewModel>(); patientBusinessLayer = new PatientBusinessLayer(); doctorBusinessLayer = new DoctorBusinessLayer(); List <MedicalHistory> medicalHistories; if (id == null) { medicalHistories = historyDataLayer.GetAllMedicalHistory(); } else { patientDataLayer = new PatientDataLayer(); medicalHistories = patientDataLayer.GetPatientMedicalHistory((int)id); } foreach (var medicalHistory in medicalHistories) { appointmentList = new List <Appointment>(); appointmentDataLayer = new AppointmentDataLayer(); appointmentList = appointmentDataLayer.GetAppointmentsById(medicalHistory.PatientId, medicalHistory.AppointmentId); if (medicalHistory.AppointmentId != 0) { foreach (var appointment in appointmentList) { medicalHistoryViewModel = new MedicalHistoryViewModel { AppointmentId = medicalHistory.AppointmentId, PatientName = patientBusinessLayer.GetPatientNameById(appointment.PatientId), DoctorName = doctorBusinessLayer.GetDoctorNameById(appointment.DoctorId), Date = appointment.Date.ToShortDateString(), Dignosis = medicalHistory.Dignosis, Medicine = medicalHistory.Medicine, ClinicRemark = medicalHistory.ClinicRemark }; medicalHistoryViewModelList.Add(medicalHistoryViewModel); } } else { medicalHistoryViewModel = new MedicalHistoryViewModel { AppointmentId = -1, PatientName = patientBusinessLayer.GetPatientNameById(medicalHistory.PatientId), DoctorName = "-", Dignosis = medicalHistory.Dignosis, Medicine = medicalHistory.Medicine, ClinicRemark = medicalHistory.ClinicRemark }; medicalHistoryViewModelList.Add(medicalHistoryViewModel); } } return(medicalHistoryViewModelList); } catch (Exception e) { ExceptionHandler.PrintException(e, new StackTrace(true)); throw e; } }