public IActionResult ReceptionView() { ViewData["Context"] = _context; var viewModel = new ReceptionViewModel(_context); return(View(viewModel)); }
public async Task <IActionResult> ReceptionCheckedIn(DateTime searchDate) { var vm = new ReceptionViewModel(); var bookings = from b in _context.Bookings select b; var CheckinQuery = from c in _context.Bookings select c.Date.Date; vm.CheckList = await CheckinQuery.Distinct().ToListAsync(); if (CheckinQuery != null) { bookings = bookings.Where(c => c.Date.Date.Equals(searchDate.Date)); } vm.bookings = await bookings.ToListAsync(); foreach (var booking in bookings) { if (booking.Checkedin == true) { vm.TotalAmountOgChecked += booking.AmountAdults + booking.AmountChildren; } vm.TotalAmountOfGuest += booking.AmountAdults + booking.AmountChildren; } return(View(vm)); }
public async Task <ActionResult <Reception> > PostReception(ReceptionViewModel receptionViewModel) { var reception = receptionViewModel.ToReception(); if (_context.Receptions.Where(r => r.DoctorId == reception.DoctorId).ToList().Any()) { var doctorsReceptions = new List <Reception>(); foreach (var r in _context.Receptions.Where(r => r.DoctorId == reception.DoctorId).ToList()) { if (r.DoctorId == reception.DoctorId && DateTime.Compare(r.Date.Date, reception.Date.Date) == 0 && ((r.Time <= reception.Time && r.Time + r.Duration >= reception.Time) || (reception.Time <= r.Time && reception.Time + reception.Duration >= r.Time))) { doctorsReceptions.Add(r); } } if (doctorsReceptions.Any()) { return(BadRequest("Reception of this time is already set")); } } reception.IsPayed = false; reception.PatientId = Utils.GetPatient(_caller, _context).PatientId; reception.DayOfWeek = reception.Date.DayOfWeek.ToString(); _context.Receptions.Add(reception); await _context.SaveChangesAsync(); return(CreatedAtAction("GetReception", new { id = reception.ReceptionId }, reception)); }
// GET: Bookings reception public async Task <IActionResult> ReceptionMain() { var vm = new ReceptionViewModel(); var bookings = from b in _context.Bookings select b; vm.bookings = await bookings.ToListAsync(); return(View(vm)); }
private int CalculateLeftSum(ReceptionViewModel reception) { int sum = reception.TotalSum; int paidSum = _payment.Read(new PaymentBindingModel { ReceptionId = reception.Id }).Select(rec => rec.Sum).Sum(); return(sum - paidSum); }
public void SaveReceptionServicesToExcelFile(string fileName, ReceptionViewModel reception, string email) { string title = "Список кружков по записи №" + reception.Id; SaveToExcel.CreateDoc(new ExcelInfo { FileName = fileName, Title = title, Services = GetReceptionServices(reception) }); SendMail(email, fileName, title); }
public ActionResult Reception(ReceptionViewModel visit) { if (ModelState.IsValid) { Service serv = new Service(); serv.AddVisite(visit); ViewBag.DoctorName = serv.GetDoctorBySpecializationId(visit.MedicalSpecializationId); ViewBag.DoctorSpecialization = serv.GetMedicalSpecialization(visit.MedicalSpecializationId); ViewBag.PatientName = serv.GetPatienName(visit.PatientId); } return(Redirect("Administration/Reception")); }
public List <ServiceViewModel> GetReceptionServices(ReceptionViewModel reception) { var services = new List <ServiceViewModel>(); foreach (var service in reception.ReceptionServices) { services.Add(serviceLogic.Read(new ServiceBindingModel { Id = service.ServiceId }).FirstOrDefault()); } return(services); }
public void AddVisite(ReceptionViewModel visit) { string date = visit.VisiteDate + " " + visit.VisiteTime; db.Visites.Add(new Visite { PatientId = visit.PatientId, VisiteDate = DateTime.Parse(date), Description = visit.Description, DoctorId = visit.DoctorId }); db.SaveChanges(); }
public ActionResult Payment(PaymentModel model) { ReceptionViewModel reception = _reception.Read(new ReceptionBindingModel { Id = model.ReceptionId }).FirstOrDefault(); int leftSum = CalculateLeftSum(reception); if (!ModelState.IsValid) { ViewBag.Reception = reception; ViewBag.LeftSum = leftSum; return(View(model)); } if (leftSum < model.Sum) { ViewBag.Reception = reception; ViewBag.LeftSum = leftSum; return(View(model)); } _payment.CreateOrUpdate(new PaymentBindingModel { ReceptionId = reception.Id, ClientId = Program.Client.Id, DatePayment = DateTime.Now, Sum = model.Sum }); leftSum -= model.Sum; _reception.CreateOrUpdate(new ReceptionBindingModel { Id = reception.Id, ClientId = reception.ClientId, DateCreate = reception.DateCreate, ReceptionStatus = leftSum > 0 ? ReceptionStatus.ОплаченЧастично : ReceptionStatus.Оплачен, TotalSum = reception.TotalSum, ReceptionServices = reception.ReceptionServices.Select(rec => new ReceptionServiceBindingModel { Id = rec.Id, ReceptionId = rec.ReceptionId, ServiceId = rec.ServiceId, Count = rec.Count }).ToList() }); return(RedirectToAction("Reception")); }
//[Authorize(Roles = "patient")] public IActionResult InsertReception(ReceptionViewModel reception) { if (ModelState.IsValid) { var userId = Convert.ToInt32(User.FindFirstValue(ClaimTypes.NameIdentifier)); var receptionDto = _mapper.Map <ReceptionWorkDayDTO>(reception); receptionDto.PatientId = userId; var result = _receptionService.CreateVisit(receptionDto); if (result) { TempData["message"] = string.Format("Вы записаны на прием!"); return(RedirectToAction("Index", "Home")); } else { TempData["message"] = string.Format("Упс! Кто-то уже записался в это время!"); } } return(View()); }
public ActionResult Create(ReceptionViewModel entity) { if (string.IsNullOrWhiteSpace(entity.FullName)) { ViewBag.Error = "Chưa nhập họ tên bệnh nhân"; return(View(entity)); } // Create string newstr = Utilities.RemoveUnicode(entity.FullName); string[] split = newstr.Split(' '); StringBuilder builder = new StringBuilder(); if (split.Length > 2) { if (!string.IsNullOrWhiteSpace(split[2])) { builder.Append(split[2]); } } if (split.Length > 1) { if (!string.IsNullOrWhiteSpace(split[1])) { builder.Append(split[1]); } } builder.Append('.'); if (!string.IsNullOrWhiteSpace(split[0])) { builder.Append(split[0]); } if (entity.BirthYear > 0) { builder.Append(entity.BirthYear); } string username = builder.ToString().ToLower(); TempData["UserName"] = username;; // Create password string password = "******"; TempData["Password"] = password; //long temp = 0; if (entity.PhoneNumber.Length < 10 || !IsNumbers(entity.PhoneNumber)) { ViewBag.Error = "Số điện thoại phải là số có độ dài >=10"; return(View(entity)); } if (UserManager.FindByName(entity.PhoneNumber) != null) { ViewBag.Error = "Số điện thoại này đã đăng ký"; return(View(entity)); } // Create new User var user = new ApplicationUser { UserName = entity.PhoneNumber, PhoneNumber = entity.PhoneNumber, FullName = entity.FullName, Email = username + "@gmail.com", Gender = entity.Gender, DateOfBirth = new DateTime(entity.BirthYear, 1, 1), LastLogin = DateTime.Now }; var createdUser = UserManager.Create(user, password); // Assign user to role PATIENT_GROUP IdentityResult createdRole = null; if (createdUser.Succeeded) { // Assign user to Patien role createdRole = UserManager.AddToRole(user.Id, "PATIENT_GROUP"); } else { ViewBag.Error = "Không tạo được user"; return(View(entity)); } // Update database ReceptionRegisterSp_Result result = null; if (createdRole.Succeeded) { // Create input model SpReceptionRegisterViewModel model = new SpReceptionRegisterViewModel(); model.UserId = user.Id; model.Address = entity.Address; model.WardId = entity.WardId; model.Syptom = entity.Symptom; model.DoctorId = entity.DoctorId; result = new ReceptionDao().CreateNewOrder(model); ViewBag.Result = result; } else { ViewBag.Error = "Không tạo được Role"; return(View(entity)); } if (result == null) { ViewBag.Error = "Không tạo được Order"; return(View(entity)); } // Send Notify to doctor // Notify to doctor TM_Notification noty = new TM_Notification(); noty.Title = "Yêu cầu chẩn đoán từ " + User.Identity.GetFullName(); noty.Link = (int)result.OrderId; noty.CreatedDate = DateTime.Now; noty.Contents = "Bệnh nhân gửi yêu cầu chẩn đoán cho bác sĩ"; noty.Type = 1; // yêu cầu chẩn đoán noty.ReceiverId = entity.DoctorId; noty.Status = false; var notiResult = new NotificationDao().Create(noty); if (notiResult < 1) { ModelState.AddModelError("", "Không thêm được thông báo"); return(Json(new { loi = "Không thêm được thông báo" })); } return(RedirectToAction("Index")); }