private AppointmentWithDoctorViewModel GetFilledAppointmentWithDoctorViewModel(Yamed_Service.Patient currentPatient, string paginationType) { AppointmentWithDoctorViewModel viewModel = new AppointmentWithDoctorViewModel(); PatientViewModel patient = new PatientViewModel { FIO = HttpContext.Session.GetString("fioPatient"), Birthday = DateTime.Parse(HttpContext.Session.GetString("birthdayPatient")), NPolis = currentPatient.NPolis, SexPat = currentPatient.SexPat, IdPatient = HttpContext.Session.GetString("idPatient") }; LpuViewModel lpu = new LpuViewModel { IdLpu = HttpContext.Session.GetString("idCurrentLpu"), NameLpu = HttpContext.Session.GetString("nameCurrentLpu"), AddressLpu = HttpContext.Session.GetString("addressCurrentLpu") }; LpuViewModel selectLpu = new LpuViewModel { IdLpu = HttpContext.Session.GetString("idSelectLpu"), NameLpu = HttpContext.Session.GetString("nameSelectLpu"), AddressLpu = HttpContext.Session.GetString("addressSelectLpu") }; SpesialityViewModel spesiality = new SpesialityViewModel { IdSpesiality = HttpContext.Session.GetString("idSpesiality"), NameSpesiality = HttpContext.Session.GetString("nameSpesiality"), CountFreeTicketSpesiality = HttpContext.Session.GetString("countFreeTicketSpesiality") }; DoctorViewModel doctor = new DoctorViewModel { IdDoctor = HttpContext.Session.GetString("idDoctor"), NameDoctor = HttpContext.Session.GetString("nameDoctor"), CountFreeTicketDoctor = HttpContext.Session.GetString("countFreeTicketDoctor") }; SelectedDayViewModel selectedDay = new SelectedDayViewModel { DayName = HttpContext.Session.GetString("selectDayName"), DayDate = HttpContext.Session.GetString("selectDayDate") }; string selectedTime = HttpContext.Session.GetString("selectTime"); string roomNumber = HttpContext.Session.GetString("roomNumber"); string idSelectAppointment = HttpContext.Session.GetString("idSelectAppointment"); bool isAppointmentCOVID = false; if (HttpContext.Session.GetString("nextPathKey") == "AppointmentWithCOVID19") { isAppointmentCOVID = true; } viewModel = viewModelHelper.FillAppointmentWithDoctorViewModel(patient, lpu, selectLpu, spesiality, doctor, selectedDay, selectedTime, roomNumber, idSelectAppointment, currentPatient, paginationType, isAppointmentCOVID); return(viewModel); }
public AppointmentWithDoctorViewModel FillAppointmentWithDoctorViewModel(PatientViewModel currentPatientModel, LpuViewModel currentLpuModel, LpuViewModel selectLpuModel, SpesialityViewModel selectSpesialityModel, DoctorViewModel selectDoctorModel, SelectedDayViewModel selectedDayViewModel, string selectTime, string roomNumber, string idSelectAppointment, Yamed_Service.Patient currentPatient_service, string paginationType, bool isAppointmentCOVID = false) { PatientViewModel currentPatient = currentPatientModel; LpuViewModel currentLpu = currentLpuModel; LpuViewModel selectLpu = selectLpuModel; SpesialityViewModel selectSpesiality = selectSpesialityModel; DoctorViewModel selectDoctor = selectDoctorModel; SelectedDayViewModel selectDay = selectedDayViewModel; Dictionary <int, string> selectableLpuList = null; List <NetricaTestService.Spesiality> specialitiesList = null; List <NetricaTestService.Doctor1> doctorsList = null; List <AvialableDateModel> avialableDatesAppointmentList = null; List <NetricaTestService.Appointment> appointmentsList = null; PaginationViewModel pageViewModel = null; if (currentPatient_service != null) { selectableLpuList = attachmentServiceHelper.GetSelectableLpuList(currentPatient_service); if (currentLpu.IdLpu == "267") // Для Щигровской ЦРБ сделан фильтр от ФАПов { var selectableLpuListNoFAP = attachmentServiceHelper.RemoveFAPs(selectableLpuList); selectableLpuList = selectableLpuListNoFAP; } if (isAppointmentCOVID) { var newSelectableLpuList = dataHelper.GetCOVIDLpuList(selectableLpuList); selectableLpuList = newSelectableLpuList; } } if (selectLpu.IdLpu != null) { specialitiesList = netricaHelper.GetSpesialityList(int.Parse(selectLpu?.IdLpu?.ToString())); if (isAppointmentCOVID) { var newSpecialitiesList = dataHelper.GetCOVIDSpecialityList(specialitiesList); specialitiesList = newSpecialitiesList; } if (selectSpesiality.IdSpesiality != null) { doctorsList = netricaHelper.GetDoctorList(int.Parse(selectLpu.IdLpu), selectSpesiality.IdSpesiality); } if (selectDoctor.IdDoctor != null) { DateTime dayStart = DateTime.Now.AddDays(1); DateTime dayEnd = DateTime.Now.AddDays(17); List <AvialableDateModel> availableDatesList = netricaHelper.GetAvailableDates(int.Parse(selectLpu.IdLpu), selectDoctor.IdDoctor, currentPatient.IdPatient, dayStart, dayEnd); avialableDatesAppointmentList = dateHelper.GetTwoWeekAvialableDyas(dayStart, dayEnd, availableDatesList); appointmentsList = netricaHelper.GetAvailableAppointment(int.Parse(selectLpu.IdLpu), selectDoctor.IdDoctor, currentPatient.IdPatient, selectDay.DayDate); } } int startPage = 1; int itemPageCount = 5; switch (paginationType) { case "SelectLpu": if (selectableLpuList != null) { var count = selectableLpuList.Count(); selectableLpuList = selectableLpuList.Skip((startPage - 1) * itemPageCount).Take(itemPageCount).ToDictionary(d => d.Key, d => d.Value); pageViewModel = new PaginationViewModel(count, startPage, itemPageCount); } else { pageViewModel = new PaginationViewModel(0, startPage, itemPageCount); } break; case "SelectSpesiality": if (specialitiesList != null) { var count = specialitiesList.Count(); specialitiesList = specialitiesList.Skip((startPage - 1) * itemPageCount).Take(itemPageCount).ToList(); pageViewModel = new PaginationViewModel(count, startPage, itemPageCount); } else { pageViewModel = new PaginationViewModel(0, startPage, itemPageCount); } break; case "SelectDoctor": if (doctorsList != null) { var count = doctorsList.Count(); doctorsList = doctorsList.Skip((startPage - 1) * itemPageCount).Take(itemPageCount).ToList(); pageViewModel = new PaginationViewModel(count, startPage, itemPageCount); } else { pageViewModel = new PaginationViewModel(0, startPage, itemPageCount); } break; default: pageViewModel = new PaginationViewModel(0, 0, 0); break; } AppointmentWithDoctorViewModel viewModel = new AppointmentWithDoctorViewModel() { Patient = currentPatient, Lpu = currentLpu, SelectLpu = selectLpu, Spesiality = selectSpesiality, Doctor = selectDoctor, SelectedDay = selectDay, SelectedTime = selectTime, RoomNumber = roomNumber, IdSelectAppointment = idSelectAppointment, LpusList = selectableLpuList, SpesialitiesList = specialitiesList, DoctorsList = doctorsList, AvailableDatesAppointment = avialableDatesAppointmentList, AppointmentList = appointmentsList, PaginationViewModel = pageViewModel }; return(viewModel); }