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 <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; } }