public HttpResponseMessage GetDashboardDetails(string Type, string pageId, string searchDate = null) { var HospitalId = ""; if (Type.ToLower() == "secretary") { HospitalId = _secretaryRepo.Find(s => s.SecretaryId == pageId).FirstOrDefault().HospitalId; } else if (Type.ToLower() == "doctor") { HospitalId = _doctorRepo.Find(d => d.DoctorId == pageId).FirstOrDefault().HospitalId; } else if (Type.ToLower() == "hospital") { HospitalId = pageId; } DashboardTypeModel DashboardTypeModel = new DashboardTypeModel(); DashboardModel dashboardModel = new DashboardModel(); List <DashboardAppointmentListModel> lstDashboardAppointmentListModel = new List <DashboardAppointmentListModel>(); if (Type.ToLower() != "patient") { if (!string.IsNullOrEmpty(HospitalId)) { DashboardTypeModel.HospitalId = HospitalId; DashboardTypeModel.TotalFeedback = _feedbackRepo.Find(x => x.PageId == HospitalId).ToList().Count(); DashboardTypeModel.TotalDoctor = _doctorRepo.Find(d => d.HospitalId == HospitalId).ToList().Count(); DashboardTypeModel.BookedAppointment = _appointmentRepo.Find(a => a.HospitalId == HospitalId && a.Status == "booked").ToList().Count(); DashboardTypeModel.CancelAppointment = _appointmentRepo.Find(a => a.HospitalId == HospitalId && a.Status == "cancel").ToList().Count(); DashboardTypeModel.NewAppointment = _appointmentRepo.Find(a => a.HospitalId == HospitalId && a.Status == "pending").ToList().Count(); DashboardTypeModel.TodayAppointment = _appointmentRepo.Find(a => a.HospitalId == HospitalId && a.Status == "booked" && a.AppointmentDate == searchDate).ToList().Count(); } foreach (var item in _appointmentRepo.Find(a => a.HospitalId == HospitalId).ToList()) { DashboardAppointmentListModel DashboardAppointmentListModel = new DashboardAppointmentListModel(); DashboardAppointmentListModel.AppointmentDate = item.AppointmentDate; DashboardAppointmentListModel.Status = item.Status; DashboardAppointmentListModel.TimeId = item.TimingId; int appointmentTimeId = Convert.ToInt32(item.TimingId); if (_timeMasterRepo != null) { var timeDetails = _timeMasterRepo.Find(t => t.Id == appointmentTimeId && t.IsActive == true).FirstOrDefault(); if (timeDetails != null) { DashboardAppointmentListModel.AppointmentTime = timeDetails.TimeFrom.Trim() + "-" + timeDetails.TimeTo.Trim() + " " + timeDetails.AM_PM.Trim(); } } var clientDetail = _clientDetailRepo.Find(x => x.ClientId == item.ClientId).FirstOrDefault(); if (clientDetail != null) { DashboardAppointmentListModel.DOB = clientDetail.DOB; DashboardAppointmentListModel.PatientName = clientDetail.FirstName; DashboardAppointmentListModel.NoorCareNumber = clientDetail.ClientId; DashboardAppointmentListModel.Gender = clientDetail.Gender.ToString(); } var doctorDetails = _doctorRepo.Find(d => d.DoctorId == item.DoctorId).FirstOrDefault(); if (doctorDetails != null) { DashboardAppointmentListModel.DoctorName = doctorDetails.FirstName; } lstDashboardAppointmentListModel.Add(DashboardAppointmentListModel); } } else if (Type.ToLower() == "patient") { DashboardTypeModel.BookedAppointment = _appointmentRepo.Find(a => a.ClientId == pageId && a.Status == "booked").ToList().Count(); DashboardTypeModel.TotalFeedback = _feedbackRepo.Find(x => x.ClientID == pageId).ToList().Count(); DashboardTypeModel.TotalDoctorPrescription = _patientPrescriptionRepo.Find(p => p.PatientId == pageId).ToList().Count(); DashboardTypeModel.TotalMedicalFile = _quickUploadRepo.Find(q => q.ClientId == pageId).ToList().Count(); } dashboardModel.DashboardTypeModel = DashboardTypeModel; dashboardModel.DashboardAppointmentListModel = lstDashboardAppointmentListModel; return(Request.CreateResponse(HttpStatusCode.Accepted, dashboardModel)); }
public HttpResponseMessage GetDoctorDashboardDetails(string pageId) { var HospitalId = ""; if (_doctorRepo.Find(d => d.DoctorId == pageId).FirstOrDefault() != null) { HospitalId = _doctorRepo.Find(d => d.DoctorId == pageId).FirstOrDefault().HospitalId; } DashboardTypeModel DashboardTypeModel = new DashboardTypeModel(); DashboardModel dashboardModel = new DashboardModel(); List <DashboardAppointmentListModel> lstDashboardAppointmentListModel = new List <DashboardAppointmentListModel>(); DashboardTypeModel.HospitalId = HospitalId; DashboardTypeModel.TotalFeedback = _feedbackRepo.Find(x => x.PageId == pageId).ToList().Count(); DashboardTypeModel.TotalDoctor = _doctorRepo.Find(d => d.HospitalId == pageId).ToList().Count(); DashboardTypeModel.BookedAppointment = _appointmentRepo.Find(a => a.DoctorId == pageId && a.Status == "Booked").ToList().Count(); DashboardTypeModel.CancelAppointment = _appointmentRepo.Find(a => a.DoctorId == pageId && a.Status == "Cancel").ToList().Count(); var apDate = _appointmentRepo.Find(a => a.DoctorId == pageId).ToList(); int TodayAppointmentCount = 0; foreach (var apt in apDate) { var dbDate = Convert.ToDateTime(apt.AppointmentDate); if (dbDate == DateTime.Today) { TodayAppointmentCount = TodayAppointmentCount + 1; } } DashboardTypeModel.TodayAppointment = TodayAppointmentCount; // DashboardTypeModel.TodayAppointment = _appointmentRepo.Find(a => a.DoctorId == pageId && a.AppointmentDate.ToString() == DateTime.Today.ToString("yyyy-MM-dd")).ToList().Count(); DashboardTypeModel.NewAppointment = _appointmentRepo.Find(a => a.DoctorId == pageId && a.Status == "0").ToList().Count(); foreach (var item in _appointmentRepo.Find(a => a.HospitalId == HospitalId).ToList()) { DashboardAppointmentListModel DashboardAppointmentListModel = new DashboardAppointmentListModel(); DashboardAppointmentListModel.AppointmentDate = Convert.ToDateTime(item.AppointmentDate); DashboardAppointmentListModel.AppointmentId = item.AppointmentId; DashboardAppointmentListModel.Status = item.Status; DashboardAppointmentListModel.TimeId = item.TimingId; int appointmentTimeId = Convert.ToInt32(item.TimingId); if (_timeMasterRepo != null) { var timeDetails = _timeMasterRepo.Find(t => t.Id == appointmentTimeId && t.IsActive == true).FirstOrDefault(); if (timeDetails != null) { DashboardAppointmentListModel.AppointmentTime = timeDetails.TimeFrom.Trim() + "-" + timeDetails.TimeTo.Trim() + " " + timeDetails.AM_PM.Trim(); } } var clientDetail = _clientDetailRepo.Find(x => x.ClientId == item.ClientId).FirstOrDefault(); if (clientDetail != null) { DashboardAppointmentListModel.DOB = clientDetail.DOB; DashboardAppointmentListModel.PatientName = clientDetail.FirstName; DashboardAppointmentListModel.NoorCareNumber = clientDetail.ClientId; DashboardAppointmentListModel.Gender = clientDetail.Gender.ToString(); } var doctorDetails = _doctorRepo.Find(d => d.DoctorId == item.DoctorId).FirstOrDefault(); if (doctorDetails != null) { DashboardAppointmentListModel.DoctorName = doctorDetails.FirstName; } lstDashboardAppointmentListModel.Add(DashboardAppointmentListModel); } dashboardModel.DashboardTypeModel = DashboardTypeModel; dashboardModel.DashboardAppointmentListModel = lstDashboardAppointmentListModel; return(Request.CreateResponse(HttpStatusCode.Accepted, dashboardModel)); }